2015-12-03 21:25:59 +00:00
|
|
|
{ stdenv } : { env, extraInstallCommands ? "" } :
|
2014-04-26 18:38:03 +01:00
|
|
|
|
2013-09-13 22:58:59 +01:00
|
|
|
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;
|
2014-04-18 12:30:24 +01:00
|
|
|
destroySh = ./destroy.sh.in;
|
2014-04-23 00:03:14 +01:00
|
|
|
|
2015-02-05 15:12:14 +00: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 = ''
|
2015-02-05 15:12:14 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
cd $out/bin
|
2014-04-23 00:03:14 +01:00
|
|
|
|
2015-02-05 15:12:14 +00:00
|
|
|
sed -e "s|@chrootEnv@|${env}|g" \
|
2013-09-13 22:58:59 +01:00
|
|
|
-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
|
|
|
|
2013-09-13 22:58:59 +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
|
|
|
|
2013-09-13 22:58:59 +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
|
|
|
|
2013-09-13 22:58:59 +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
|
|
|
|
2015-02-05 15:12:14 +00:00
|
|
|
sed -e "s|@chrootEnv@|${env}|g" \
|
2013-09-13 22:58:59 +01:00
|
|
|
-e "s|@shell@|${stdenv.shell}|g" \
|
|
|
|
-e "s|@name@|${name}|g" \
|
|
|
|
${destroySh} > destroy-${name}-chrootenv
|
|
|
|
chmod +x destroy-${name}-chrootenv
|
2015-12-03 21:25:59 +00:00
|
|
|
${extraInstallCommands}
|
2013-09-13 22:58:59 +01:00
|
|
|
'';
|
|
|
|
}
|