mirror of
https://github.com/ilyakooo0/nix-bundle.git
synced 2024-09-11 06:55:53 +03:00
support store paths
Allow to pass a store path as a target. This is useful when combining nix-bundle with the output of another build. Eg: nix-bundle.sh $(nix-build "<nixpkgs>" -A hello) /bin/hello
This commit is contained in:
parent
cc47fa353c
commit
cb765ad91c
16
default.nix
16
default.nix
@ -10,6 +10,16 @@ let
|
||||
'';
|
||||
});
|
||||
in rec {
|
||||
toStorePath = target:
|
||||
# If a store path has been given, transform it to a string. And make sure
|
||||
# to capture the store path in its context.
|
||||
if lib.isStorePath target then
|
||||
let path = toString target; in
|
||||
builtins.appendContext path { "${path}" = { path = true; }; }
|
||||
# Otherwise, add to the store. This takes care of appending the store path
|
||||
# in the context automatically.
|
||||
else "${target}";
|
||||
|
||||
arx = { archive, startup}:
|
||||
stdenv.mkDerivation {
|
||||
name = "arx";
|
||||
@ -71,9 +81,13 @@ in rec {
|
||||
};
|
||||
|
||||
makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run }:
|
||||
let
|
||||
# Avoid re-adding a store path into the store
|
||||
path = toStorePath target;
|
||||
in
|
||||
writeScript "startup" ''
|
||||
#!/bin/sh
|
||||
.${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${target}${run} "$@"
|
||||
.${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${path}${run} "$@"
|
||||
'';
|
||||
|
||||
nix-bootstrap = { target, extraTargets ? [], run, nix-user-chroot' ? nix-user-chroot, nixUserChrootFlags ? "" }:
|
||||
|
@ -8,6 +8,9 @@ Usage: $0 TARGET EXECUTABLE
|
||||
Create a single-file bundle from the nixpkgs attribute "TARGET".
|
||||
EXECUTABLE should be relative to the TARGET's output path.
|
||||
|
||||
The TARGET is either an attribute in nixpkgs, or an absolute path to the
|
||||
store.
|
||||
|
||||
For example:
|
||||
|
||||
$ $0 hello /bin/hello
|
||||
|
Loading…
Reference in New Issue
Block a user