2015-02-05 16:12:14 +01:00
|
|
|
{ stdenv } : { env } :
|
2014-04-26 19:38:03 +02:00
|
|
|
|
2013-09-13 23:58:59 +02:00
|
|
|
let
|
|
|
|
# References to shell scripts that set up or tear down the environment
|
2014-04-23 01:03:14 +02:00
|
|
|
initSh = ./init.sh.in;
|
|
|
|
mountSh = ./mount.sh.in;
|
|
|
|
loadSh = ./load.sh.in;
|
|
|
|
umountSh = ./umount.sh.in;
|
2014-04-18 13:30:24 +02:00
|
|
|
destroySh = ./destroy.sh.in;
|
2014-04-23 01:03:14 +02:00
|
|
|
|
2015-02-05 16:12:14 +01:00
|
|
|
name = env.pname;
|
2014-04-23 01:03:14 +02:00
|
|
|
|
|
|
|
in stdenv.mkDerivation {
|
2015-02-05 18:39:01 +01:00
|
|
|
name = "${name}-chrootenv";
|
|
|
|
preferLocalBuild = true;
|
2014-04-23 01:03:14 +02:00
|
|
|
buildCommand = ''
|
2015-02-05 16:12:14 +01:00
|
|
|
mkdir -p $out/bin
|
|
|
|
cd $out/bin
|
2014-04-23 01:03:14 +02:00
|
|
|
|
2015-02-05 16:12:14 +01:00
|
|
|
sed -e "s|@chrootEnv@|${env}|g" \
|
2013-09-13 23:58:59 +02:00
|
|
|
-e "s|@name@|${name}|g" \
|
|
|
|
-e "s|@shell@|${stdenv.shell}|g" \
|
|
|
|
${initSh} > init-${name}-chrootenv
|
|
|
|
chmod +x init-${name}-chrootenv
|
2014-04-23 01:03:14 +02:00
|
|
|
|
2013-09-13 23:58:59 +02: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 01:03:14 +02:00
|
|
|
|
2013-09-13 23:58:59 +02: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 01:03:14 +02:00
|
|
|
|
2013-09-13 23:58:59 +02: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 01:03:14 +02:00
|
|
|
|
2015-02-05 16:12:14 +01:00
|
|
|
sed -e "s|@chrootEnv@|${env}|g" \
|
2013-09-13 23:58:59 +02:00
|
|
|
-e "s|@shell@|${stdenv.shell}|g" \
|
|
|
|
-e "s|@name@|${name}|g" \
|
|
|
|
${destroySh} > destroy-${name}-chrootenv
|
|
|
|
chmod +x destroy-${name}-chrootenv
|
|
|
|
'';
|
|
|
|
}
|