on master help sign in
nix-bundle.sh: Add a default for --bin
commit138ff3a39569e4b5a28e764079f4baf4bb861d2b authorhaslersn <sebastian.hasler@gmx.net> dateMon 24 Jun 2019, 20:01 (7 years ago) parent14157e0
1 file changed+9−9
nix-bundle.sh+9−9
nix-bundle.sh+9−9
@@ -67,7 +67,8 @@ Flags:
6767 --argstr <NAME> <STRING> string-valued argument to be passed to Nix functions
6868 -f, --file <FILE> evaluate FILE rather than the default
6969 -I, --include <PATH> add a path to the list of locations used to look up <...> file names
70− --bin <BINARY> the binary to bundle, relative to TARGET's output path
70+ --bin <BINARY> the binary to bundle, relative to TARGET's output path; defaults to
71+ the lexicographically first file inside /bin
7172
7273Examples:
7374
@@ -100,14 +101,6 @@ do
100101 shift
101102done
102103
103−# Check if all required arguments were passed
104−
105−if [ -z ${bin+x} ]
106−then
107− echo "error: flag '--bin' is required" >&2
108− fail
109−fi
110−
111104# Create tmp directory for the links produced by `nix build`
112105
113106linkdir=$(mktemp -d)
@@ -136,6 +129,13 @@ then
136129 target_path="$(readlink "$linkdir/result")"
137130fi
138131
132+# Apply default for --bin
133+
134+if [ -z ${bin+x} ]
135+then
136+ bin=$(ls "$target_path/bin" | head -1)
137+fi
138+
139139# Determine bootstrap function -- This seems like a total hack!
140140
141141bootstrap=nix-bootstrap