on 5672912 help sign in
7 files changed+24−52
since splitsnapshots
unifiedsplit
appdir.nix+2−2 appimagetool.nix+2−2 default.nix+8−23 flake.nix+1−1 nix-bundle.sh+1−4 nix-run.sh+10−10 test.sh−10
appdir.nix+2−2
@@ -1,4 +1,4 @@
1−{ stdenv, lib, fetchurl, muslPkgs, perl, pathsFromGraph, fetchFromGitHub, coreutils, bash }:
1+{ stdenv, fetchurl, muslPkgs, perl, pathsFromGraph, fetchFromGitHub, coreutils, bash }:
22
33let
44 AppRun = targets: muslPkgs.stdenv.mkDerivation {
@@ -8,7 +8,7 @@ let
88
99 buildPhase = ''
1010 CC="$CC -O2 -Wall -Wno-deprecated-declarations -Wno-unused-result -static"
11− $CC ${./AppRun.c} -o AppRun -DENV_PATH='"${lib.makeBinPath targets}"'
11+ $CC ${./AppRun.c} -o AppRun -DENV_PATH='"${stdenv.lib.makeBinPath targets}"'
1212 '';
1313
1414 installPhase = ''
appimagetool.nix+2−2
@@ -1,4 +1,4 @@
1−{ stdenv, lib, fetchurl, fuse, zlib, squashfsTools, glib }:
1+{ stdenv, fetchurl, fuse, zlib, squashfsTools, glib }:
22
33# This is from some binaries.
44
@@ -37,7 +37,7 @@ in stdenv.mkDerivation rec {
3737 for x in $out/bin/*; do
3838 patchelf \
3939 --set-interpreter ${dynamicLinker} \
40− --set-rpath ${lib.makeLibraryPath [ zlib stdenv.glibc.out fuse glib ]} \
40+ --set-rpath ${stdenv.lib.makeLibraryPath [ zlib stdenv.glibc.out fuse glib ]} \
4141 $x
4242 done
4343 '';
default.nix+8−23
@@ -10,16 +10,6 @@ let
1010 '';
1111 });
1212in rec {
13− toStorePath = target:
14− # If a store path has been given but is not a derivation, add the missing context
15− # to it so it will be propagated properly as a build input.
16− if !(lib.isDerivation target) && lib.isStorePath target then
17− let path = toString target; in
18− builtins.appendContext path { "${path}" = { path = true; }; }
19− # Otherwise, add to the store. This takes care of appending the store path
20− # in the context automatically.
21− else "${target}";
22−
2313 arx = { archive, startup}:
2414 stdenv.mkDerivation {
2515 name = "arx";
@@ -45,7 +35,7 @@ in rec {
4535 };
4636
4737 # TODO: eventually should this go in nixpkgs?
48− nix-user-chroot = lib.makeOverridable stdenv.mkDerivation {
38+ nix-user-chroot = stdenv.lib.makeOverridable stdenv.mkDerivation {
4939 name = "nix-user-chroot-2c52b5f";
5040 src = ./nix-user-chroot;
5141
@@ -80,20 +70,15 @@ in rec {
8070 };
8171 };
8272
83− makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run, initScript }:
84− let
85− # Avoid re-adding a store path into the store
86− path = toStorePath target;
87− in
73+ makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run }:
8874 writeScript "startup" ''
8975 #!/bin/sh
90− ${initScript}
91− .${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${path}${run} "$@"
76+ .${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${target}${run} $@
9277 '';
9378
94− nix-bootstrap = { target, extraTargets ? [], run, nix-user-chroot' ? nix-user-chroot, nixUserChrootFlags ? "", initScript ? "" }:
79+ nix-bootstrap = { target, extraTargets ? [], run, nix-user-chroot' ? nix-user-chroot, nixUserChrootFlags ? "" }:
9580 let
96− script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run initScript; };
81+ script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run; };
9782 in makebootstrap {
9883 startup = ".${script} '\"$@\"'";
9984 targets = [ "${script}" ] ++ extraTargets;
@@ -110,10 +95,10 @@ in rec {
11095 nix-user-chroot'' = targets: nix-user-chroot.overrideDerivation (o: {
11196 buildInputs = o.buildInputs ++ targets;
11297 makeFlags = o.makeFlags ++ [
113− ''ENV_PATH="${lib.makeBinPath targets}"''
98+ ''ENV_PATH="${stdenv.lib.makeBinPath targets}"''
11499 ];
115− }); in { target, extraTargets ? [], run, initScript ? "" }: nix-bootstrap {
116− inherit target extraTargets run initScript;
100+ }); in { target, extraTargets ? [], run }: nix-bootstrap {
101+ inherit target extraTargets run;
117102 nix-user-chroot' = nix-user-chroot'' extraTargets;
118103 };
119104}
flake.nix+1−1
@@ -13,7 +13,7 @@
1313 nix-bundle = import self { nixpkgs = nixpkgs'; };
1414 script = nixpkgs'.writeScript "startup" ''
1515 #!/bin/sh
16− .${nix-bundle.nix-user-chroot}/bin/nix-user-chroot -n ./nix -- ${program} "$@"
16+ .${nix-bundle.nix-user-chroot}/bin/nix-user-chroot -n ./nix -- ${program} $@
1717 '';
1818 in nix-bundle.makebootstrap {
1919 targets = [ script ];
nix-bundle.sh+1−4
@@ -8,9 +8,6 @@ Usage: $0 TARGET EXECUTABLE
88Create a single-file bundle from the nixpkgs attribute "TARGET".
99EXECUTABLE should be relative to the TARGET's output path.
1010
11−The TARGET is either an attribute in nixpkgs, or an absolute path to the
12−store.
13−
1411For example:
1512
1613$ $0 hello /bin/hello
@@ -59,5 +56,5 @@ elif [ -t 1 ]; then
5956 echo "Nix bundle created at $filename."
6057 cp -f "$out" "$filename"
6158else
62− echo "$out"
59+ cat "$out"
6360fi
nix-run.sh+10−10
@@ -22,7 +22,7 @@ pkg="$1"
2222shift
2323
2424# A second argument will provide a hint to run
25−if [ -n "$1" ]; then
25+if ! [ -z "$1" ]; then
2626 name="$1"
2727 shift
2828else
@@ -53,11 +53,11 @@ run_linux_desktop_app () {
5353 file="$1"
5454 shift
5555
56− cmd=$(grep '^Exec' "$file" | tail -1 | \
56+ cmd=$(grep '^Exec' $file | tail -1 | \
5757 sed 's/Exec=//;s/^"//;s/" *$//')
5858
59− if [ "$#" -gt 0 ]; then
60− cmd=$(echo "$cmd" | sed "s/%[fu]/$1/;s/%[FU]/$*/")
59+ if ! [ -z "$@" ]; then
60+ cmd=$(echo "$cmd" | sed "s/%[fu]/$1/;s/%[FU]/$@/")
6161 fi
6262
6363 cmd=$(echo "$cmd" | sed "s/%k/$desktop/;s/%.//")
@@ -79,20 +79,20 @@ elif [ -x "$out/bin/run" ]; then
7979 run_bin "$out/bin/run" "$@"
8080elif [ "$(uname)" = Darwin ] && [ -d "$out/Applications/$name.app" ]; then
8181 run_darwin_app "$out/Applications/$name.app" "$@"
82−elif [ "$(uname)" = Darwin ] && [ -d "$out"/Applications/*.app ]; then
83− for f in "$out"/Applications/*.app; do
82+elif [ "$(uname)" = Darwin ] && [ -d $out/Applications/*.app ]; then
83+ for f in $out/Applications/*.app; do
8484 run_darwin_app "$f" "$@"
8585 done
8686elif [ -f "$out/share/applications/$name.desktop" ]; then
87− run_linux_desktop_app "$out/share/applications/$name.desktop" "$@"
88−elif [ -d "$out"/share/applications ]; then
89− for f in "$out"/share/applications/*.desktop; do
87+ run_linux_desktop_app "$out/share/applications/$name.desktop" $@
88+elif [ -d $out/share/applications ]; then
89+ for f in $out/share/applications/*.desktop; do
9090 run_linux_desktop_app "$f"
9191 done
9292elif [ -x "$out/bin/$name" ]; then
9393 run_bin "$out/bin/$name" "$@"
9494elif [ -d "$out/bin" ]; then
95− for bin in "$out"/bin/*; do
95+ for bin in $out/bin/*; do
9696 run_bin "$bin" "$@"
9797 done
9898else
test.shdeleted−10
@@ -1,10 +0,0 @@
1−#!/usr/bin/env bash
2−set -euo pipefail
3−export NIX_PATH=channel:nixos-20.09
4−
5−echo "Test with attribute name"
6−./nix-bundle.sh hello /bin/hello
7−
8−echo "Test with store path"
9−out=$(nix-build --no-out-link --expr '(import <nixpkgs> {})' -A hello)
10−./nix-bundle.sh "$out" /bin/hello