on master help sign in
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

commit5e49fbc4a0a225013e9d916afb9ddc06b4a88fb2 authorMatthew Bauer <mjbauer95@gmail.com> dateWed 4 Apr 2018, 16:19 (9 years ago) parenta506076
4 files changed+13−21
default.nix+11−15 nix-bundle.sh+1−1 nix-user-chroot/Makefile+1−3 nix-user-chroot/main.cpp−2
default.nix+11−15
@@ -32,6 +32,8 @@ rec {
3232 name = "nix-user-chroot-2c52b5f";
3333 src = ./nix-user-chroot;
3434
35+ makeFlags = [];
36+
3537 # hack to use when /nix/store is not available
3638 postFixup = ''
3739 exe=$out/bin/nix-user-chroot
@@ -72,26 +74,20 @@ rec {
7274 targets = [ "${script}" ] ++ extraTargets;
7375 };
7476
75− # special case handling because of impurities in nix bootstrap
76− # anything that needs Nix will have to have these setup before they can be run
77− nix-bootstrap-nix = let
78− nix-user-chroot' = nix-user-chroot.override {
79− buildInputs = [ cacert gnutar bzip2 gzip coreutils ];
80− makeFlags = [
81− ''NIX_SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt"''
82− ''NIX_PATH="nixpkgs=https://github.com/matthewbauer/nixpkgs/archive/nix-bundle.tar.gz"''
83− ''ENV_PATH="${stdenv.lib.makeBinPath [ coreutils gnutar bzip2 gzip bash ]}"''
84− ];
85− }; in { target, extraTargets ? [], run }: nix-bootstrap { inherit target extraTargets run nix-user-chroot'; };
77+ nix-bootstrap-nix = {target, run, extraTargets ? []}:
78+ nix-bootstrap-path {
79+ inherit target run;
80+ extraTargets = [ gnutar bzip2 xz gzip coreutils bash ];
81+ };
8682
8783 # special case adding path to the environment before launch
8884 nix-bootstrap-path = let
89− nix-user-chroot'' = targets: nix-user-chroot.override {
90− buildInputs = targets;
91− makeFlags = [
85+ nix-user-chroot'' = targets: nix-user-chroot.overrideDerivation (o: {
86+ buildInputs = o.buildInputs ++ targets;
87+ makeFlags = o.makeFlags ++ [
9288 ''ENV_PATH="${stdenv.lib.makeBinPath targets}"''
9389 ];
94− }; in { target, extraTargets ? [], run }: nix-bootstrap {
90+ }); in { target, extraTargets ? [], run }: nix-bootstrap {
9591 inherit target extraTargets run;
9692 nix-user-chroot' = nix-user-chroot'' extraTargets;
9793 };
nix-bundle.sh+1−1
@@ -36,7 +36,7 @@ exec="$1"
3636shift
3737
3838bootstrap=nix-bootstrap
39−if [ "$target" = "nix-bundle" ] || [ "$target" = "nixStable" ] || [ "$target" = "nixUnstable" ]; then
39+if [ "$target" = "nix-bundle" ] || [ "$target" = "nixStable" ] || [ "$target" = "nixUnstable" ] || [ "$target" = "nix" ]; then
4040 bootstrap=nix-bootstrap-nix
4141elif ! [ -z "$extraTargets" ]; then
4242 bootstrap=nix-bootstrap-path
nix-user-chroot/Makefile+1−3
@@ -1,6 +1,4 @@
1−NIX_PATH ?= "nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz"
2−NIX_SSL_CERT_FILE ?= "/homeless-shelter"
31ENV_PATH ?= ""
42
53nix-user-chroot: main.cpp
6− 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
4+ g++ -o nix-user-chroot -DENV_PATH='$(ENV_PATH)' main.cpp
nix-user-chroot/main.cpp−2
@@ -219,8 +219,6 @@ int main(int argc, char *argv[]) {
219219 chdir("/");
220220
221221 if (clear_env) clearenv();
222− setenv("NIX_PATH", NIX_PATH, 1);
223− setenv("NIX_SSL_CERT_FILE", NIX_SSL_CERT_FILE, 1);
224222 setenv("PATH", ENV_PATH, 1);
225223
226224 for (list<struct SetEnv>::iterator it = envMappings.begin();