From 5e49fbc4a0a225013e9d916afb9ddc06b4a88fb2 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 4 Apr 2018 16:19:32 -0500 Subject: [PATCH] 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 --- default.nix | 26 +++++++++++--------------- nix-bundle.sh | 2 +- nix-user-chroot/Makefile | 4 +--- nix-user-chroot/main.cpp | 2 -- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/default.nix b/default.nix index 6a7978c..4d628c6 100644 --- a/default.nix +++ b/default.nix @@ -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; }; diff --git a/nix-bundle.sh b/nix-bundle.sh index 12d4015..8bece2a 100755 --- a/nix-bundle.sh +++ b/nix-bundle.sh @@ -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 diff --git a/nix-user-chroot/Makefile b/nix-user-chroot/Makefile index f987f8e..30cec36 100644 --- a/nix-user-chroot/Makefile +++ b/nix-user-chroot/Makefile @@ -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 diff --git a/nix-user-chroot/main.cpp b/nix-user-chroot/main.cpp index 95b067f..de4a2e8 100644 --- a/nix-user-chroot/main.cpp +++ b/nix-user-chroot/main.cpp @@ -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::iterator it = envMappings.begin();