mirror of
https://github.com/ilyakooo0/nix-bundle.git
synced 2024-10-26 08:42:01 +03:00
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:
parent
a5060764cb
commit
5e49fbc4a0
26
default.nix
26
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;
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user