3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/build-support/build-fhs-chrootenv/default.nix

49 lines
1.3 KiB
Nix
Raw Normal View History

{ stdenv } : { env, extraInstallCommands ? "" } :
let
# References to shell scripts that set up or tear down the environment
2014-04-23 00:03:14 +01:00
initSh = ./init.sh.in;
mountSh = ./mount.sh.in;
loadSh = ./load.sh.in;
umountSh = ./umount.sh.in;
destroySh = ./destroy.sh.in;
2014-04-23 00:03:14 +01:00
name = env.pname;
2014-04-23 00:03:14 +01:00
in stdenv.mkDerivation {
2015-02-05 17:39:01 +00:00
name = "${name}-chrootenv";
preferLocalBuild = true;
2014-04-23 00:03:14 +01:00
buildCommand = ''
mkdir -p $out/bin
cd $out/bin
2014-04-23 00:03:14 +01:00
sed -e "s|@chrootEnv@|${env}|g" \
-e "s|@name@|${name}|g" \
-e "s|@shell@|${stdenv.shell}|g" \
${initSh} > init-${name}-chrootenv
chmod +x init-${name}-chrootenv
2014-04-23 00:03:14 +01:00
sed -e "s|@shell@|${stdenv.shell}|g" \
-e "s|@name@|${name}|g" \
${mountSh} > mount-${name}-chrootenv
chmod +x mount-${name}-chrootenv
2014-04-23 00:03:14 +01:00
sed -e "s|@shell@|${stdenv.shell}|g" \
-e "s|@name@|${name}|g" \
${loadSh} > load-${name}-chrootenv
chmod +x load-${name}-chrootenv
2014-04-23 00:03:14 +01:00
sed -e "s|@shell@|${stdenv.shell}|g" \
-e "s|@name@|${name}|g" \
${umountSh} > umount-${name}-chrootenv
chmod +x umount-${name}-chrootenv
2014-04-23 00:03:14 +01:00
sed -e "s|@chrootEnv@|${env}|g" \
-e "s|@shell@|${stdenv.shell}|g" \
-e "s|@name@|${name}|g" \
${destroySh} > destroy-${name}-chrootenv
chmod +x destroy-${name}-chrootenv
${extraInstallCommands}
'';
}