Created
May 12, 2018 14:50
-
-
Save FRidh/a2e3553ba6391a0cb2e32039c494cda6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
pkgs = import (fetchTarball channel:nixos-18.03) {}; | |
custom-store = "/home/freddy/nix_custom_store"; | |
# Run nix in a mount namespace | |
nix-wrapped = pkgs.writeShellScriptBin "nix" '' | |
${pkgs.bubblewrap}/bin/bwrap \ | |
--unshare-all \ | |
--proc /proc \ | |
--dev /dev \ | |
--tmpfs /run \ | |
--bind /nix /nix \ | |
--bind /home /home \ | |
--setenv NIX_DAEMON "" \ | |
--setenv NIX_STORE_DIR ${custom-store}/nix/store \ | |
--setenv NIX_STATE_DIR ${custom-store}/nix/var \ | |
--setenv NIX_SSL_CERT_FILE ${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt \ | |
${pkgs.nix}/bin/nix $@ | |
''; | |
nix-wrapped-bundled = pkgs.runCommand "nix-bundled" {} '' | |
${pkgs.nix-bundle}/bin/nix-bundle ${nix-wrapped} /bin/nix | |
mkdir -p $out | |
mv nix $out/ | |
''; | |
in nix-wrapped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment