mirror of
https://github.com/ilyakooo0/nix-bundle.git
synced 2024-10-26 08:42:01 +03:00
Allow multiple targets in nix-bundle
This commit is contained in:
parent
608f2457b9
commit
1584ab8dc4
37
default.nix
37
default.nix
@ -28,7 +28,7 @@ rec {
|
||||
};
|
||||
|
||||
# TODO: eventually should this go in nixpkgs?
|
||||
nix-user-chroot = stdenv.mkDerivation {
|
||||
nix-user-chroot = stdenv.lib.makeOverridable stdenv.mkDerivation {
|
||||
name = "nix-user-chroot-2b144e";
|
||||
src = fetchFromGitHub {
|
||||
owner = "matthewbauer";
|
||||
@ -37,6 +37,7 @@ rec {
|
||||
sha256 = "16bmshhvk6941w04rx78i5a1305876qni2n2rvm7rkziz49j158n";
|
||||
};
|
||||
|
||||
# hack to use when /nix/store is not available
|
||||
postFixup = ''
|
||||
exe=$out/bin/nix-user-chroot
|
||||
patchelf \
|
||||
@ -46,8 +47,12 @@ rec {
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin/
|
||||
cp nix-user-chroot $out/bin/nix-user-chroot
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
@ -59,9 +64,33 @@ rec {
|
||||
};
|
||||
};
|
||||
|
||||
nix-bootstrap = { target, run }:
|
||||
nix-bootstrap = { target, extraTargets ? [], run, nix-user-chroot' ? nix-user-chroot }:
|
||||
makebootstrap {
|
||||
startup = ''.${nix-user-chroot}/bin/nix-user-chroot ./nix ${target}${run} \$@'';
|
||||
targets = [ nix-user-chroot target ];
|
||||
startup = ''.${nix-user-chroot'}/bin/nix-user-chroot ./nix ${target}${run} \$@'';
|
||||
targets = [ nix-user-chroot' target ] ++ extraTargets;
|
||||
};
|
||||
|
||||
# special case handling because of impurities in nix bootstrap
|
||||
# anything that needs Nix will have to have these setup before they can be run
|
||||
nix-bootstrap-nix = let
|
||||
nix-user-chroot' = nix-user-chroot.override {
|
||||
buildInputs = [ cacert gnutar bzip2 gzip coreutils ];
|
||||
makeFlags = [
|
||||
''NIX_SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt"''
|
||||
''NIX_PATH="nixpkgs=https://github.com/matthewbauer/nixpkgs/archive/nix-bundle.tar.gz"''
|
||||
''ENV_PATH="${stdenv.lib.makeBinPath [ coreutils gnutar bzip2 gzip bash ]}"''
|
||||
];
|
||||
}; in { target, extraTargets ? [], run }: nix-bootstrap { inherit target extraTargets run nix-user-chroot'; };
|
||||
|
||||
# special case adding path to the environment before launch
|
||||
nix-bootstrap-path = let
|
||||
nix-user-chroot'' = targets: nix-user-chroot.override {
|
||||
buildInputs = targets;
|
||||
makeFlags = [
|
||||
''ENV_PATH="${stdenv.lib.makeBinPath targets}"''
|
||||
];
|
||||
}; in { target, extraTargets ? [], run }: nix-bootstrap {
|
||||
inherit target extraTargets run;
|
||||
nix-user-chroot' = nix-user-chroot'' extraTargets;
|
||||
};
|
||||
}
|
||||
|
@ -19,12 +19,30 @@ EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
target="$1"
|
||||
exec="$2"
|
||||
|
||||
nix_file=`dirname $0`/default.nix
|
||||
|
||||
expr="with import <nixpkgs> {}; with import $nix_file {}; nix-bootstrap { target = $target; run = \"$exec\"; }"
|
||||
target="$1"
|
||||
shift
|
||||
|
||||
extraTargets=
|
||||
if [ "$#" -gt 1 ]; then
|
||||
while [ "$#" -gt 1 ]; do
|
||||
extraTargets="$extraTargets $1"
|
||||
shift
|
||||
done
|
||||
fi
|
||||
|
||||
exec="$1"
|
||||
shift
|
||||
|
||||
bootstrap=nix-bootstrap
|
||||
if [ "$target" = "nix-bundle" ] || [ "$target" = "nixStable" ] || [ "$target" = "nixUnstable" ]; then
|
||||
bootstrap=nix-bootstrap-nix
|
||||
elif ! [ -z "$extraTargets" ]; then
|
||||
bootstrap=nix-bootstrap-path
|
||||
fi
|
||||
|
||||
expr="with import <nixpkgs> {}; with import $nix_file {}; $bootstrap { target = $target; extraTargets = [ $extraTargets ]; run = \"$exec\"; }"
|
||||
|
||||
out=$(nix-store --no-gc-warning -r $(nix-instantiate --no-gc-warning -E "$expr"))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user