Cleanup Nix bundling

The special case of Nix bundling is useful for handling the hidden
dependencies of Nix. It will automatically add them for you when you
do this:

$ nix-bundle nix /bin/nix
This commit is contained in:
Matthew Bauer 2018-04-04 16:19:32 -05:00
parent a5060764cb
commit 5e49fbc4a0
4 changed files with 13 additions and 21 deletions

View File

@ -32,6 +32,8 @@ rec {
name = "nix-user-chroot-2c52b5f";
src = ./nix-user-chroot;
makeFlags = [];
# hack to use when /nix/store is not available
postFixup = ''
exe=$out/bin/nix-user-chroot
@ -72,26 +74,20 @@ rec {
targets = [ "${script}" ] ++ 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'; };
nix-bootstrap-nix = {target, run, extraTargets ? []}:
nix-bootstrap-path {
inherit target run;
extraTargets = [ gnutar bzip2 xz gzip coreutils bash ];
};
# special case adding path to the environment before launch
nix-bootstrap-path = let
nix-user-chroot'' = targets: nix-user-chroot.override {
buildInputs = targets;
makeFlags = [
nix-user-chroot'' = targets: nix-user-chroot.overrideDerivation (o: {
buildInputs = o.buildInputs ++ targets;
makeFlags = o.makeFlags ++ [
''ENV_PATH="${stdenv.lib.makeBinPath targets}"''
];
}; in { target, extraTargets ? [], run }: nix-bootstrap {
}); in { target, extraTargets ? [], run }: nix-bootstrap {
inherit target extraTargets run;
nix-user-chroot' = nix-user-chroot'' extraTargets;
};

View File

@ -36,7 +36,7 @@ exec="$1"
shift
bootstrap=nix-bootstrap
if [ "$target" = "nix-bundle" ] || [ "$target" = "nixStable" ] || [ "$target" = "nixUnstable" ]; then
if [ "$target" = "nix-bundle" ] || [ "$target" = "nixStable" ] || [ "$target" = "nixUnstable" ] || [ "$target" = "nix" ]; then
bootstrap=nix-bootstrap-nix
elif ! [ -z "$extraTargets" ]; then
bootstrap=nix-bootstrap-path

View File

@ -1,6 +1,4 @@
NIX_PATH ?= "nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz"
NIX_SSL_CERT_FILE ?= "/homeless-shelter"
ENV_PATH ?= ""
nix-user-chroot: main.cpp
g++ -o nix-user-chroot -DNIX_PATH='$(NIX_PATH)' -DNIX_SSL_CERT_FILE='$(NIX_SSL_CERT_FILE)' -DENV_HOME='$(ENV_HOME)' -DENV_PATH='$(ENV_PATH)' main.cpp
g++ -o nix-user-chroot -DENV_PATH='$(ENV_PATH)' main.cpp

View File

@ -219,8 +219,6 @@ int main(int argc, char *argv[]) {
chdir("/");
if (clear_env) clearenv();
setenv("NIX_PATH", NIX_PATH, 1);
setenv("NIX_SSL_CERT_FILE", NIX_SSL_CERT_FILE, 1);
setenv("PATH", ENV_PATH, 1);
for (list<struct SetEnv>::iterator it = envMappings.begin();