mirror of
https://github.com/ilyakooo0/nix-bundle.git
synced 2024-10-05 19:17:16 +03:00
Allow to run an init script on startup.
This allows for example to set specific environment variables, before starting the script without needing to modify the target.
This commit is contained in:
parent
223f4ffc41
commit
b7c5c58cb4
11
default.nix
11
default.nix
@ -80,19 +80,20 @@ in rec {
|
||||
};
|
||||
};
|
||||
|
||||
makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run }:
|
||||
makeStartup = { target, nixUserChrootFlags, nix-user-chroot', run, initScript }:
|
||||
let
|
||||
# Avoid re-adding a store path into the store
|
||||
path = toStorePath target;
|
||||
in
|
||||
writeScript "startup" ''
|
||||
#!/bin/sh
|
||||
${initScript}
|
||||
.${nix-user-chroot'}/bin/nix-user-chroot -n ./nix ${nixUserChrootFlags} -- ${path}${run} "$@"
|
||||
'';
|
||||
|
||||
nix-bootstrap = { target, extraTargets ? [], run, nix-user-chroot' ? nix-user-chroot, nixUserChrootFlags ? "" }:
|
||||
nix-bootstrap = { target, extraTargets ? [], run, nix-user-chroot' ? nix-user-chroot, nixUserChrootFlags ? "", initScript ? "" }:
|
||||
let
|
||||
script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run; };
|
||||
script = makeStartup { inherit target nixUserChrootFlags nix-user-chroot' run initScript; };
|
||||
in makebootstrap {
|
||||
startup = ".${script} '\"$@\"'";
|
||||
targets = [ "${script}" ] ++ extraTargets;
|
||||
@ -111,8 +112,8 @@ in rec {
|
||||
makeFlags = o.makeFlags ++ [
|
||||
''ENV_PATH="${lib.makeBinPath targets}"''
|
||||
];
|
||||
}); in { target, extraTargets ? [], run }: nix-bootstrap {
|
||||
inherit target extraTargets run;
|
||||
}); in { target, extraTargets ? [], run, initScript ? "" }: nix-bootstrap {
|
||||
inherit target extraTargets run initScript;
|
||||
nix-user-chroot' = nix-user-chroot'' extraTargets;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user