nixpkgs/pkgs/build-support/build-fhs-chrootenv/init.sh.in
2015-02-05 19:46:00 +03:00

49 lines
1.4 KiB
Bash

#! @shell@ -e
chrootenvDest=/run/chrootenv/@name@
# Create some mount points for stuff that must be bind mounted
mkdir -p $chrootenvDest/{nix/store,dev,proc,sys,host-etc,home,var,run}
# Symlink the software that should be part of the chroot system profile
for i in @chrootEnv@/*
do
if [ "$i" != "@chrootEnv@/etc" ] && [ "$i" != "@chrootEnv@/var" ]
then
ln -s "$i" "$chrootenvDest"
fi
done
# Symlink the contents of the chroot software's /etc
mkdir $chrootenvDest/etc
for i in @chrootEnv@/etc/*
do
ln -s "$i" $chrootenvDest/etc
done
# Symlink some NSS stuff
ln -s ../host-etc/passwd $chrootenvDest/etc/passwd
ln -s ../host-etc/group $chrootenvDest/etc/group
ln -s ../host-etc/shadow $chrootenvDest/etc/shadow
ln -s ../host-etc/hosts $chrootenvDest/etc/hosts
ln -s ../host-etc/resolv.conf $chrootenvDest/etc/resolv.conf
ln -s ../host-etc/nsswitch.conf $chrootenvDest/etc/nsswitch.conf
# Symlink PAM stuff
rm $chrootenvDest/etc/pam.d
ln -s ../host-etc/static/pam.d $chrootenvDest/etc/pam.d
# Symlink Font stuff
mkdir -p $chrootenvDest/etc/fonts
ln -s ../../host-etc/static/fonts/fonts.conf $chrootenvDest/etc/fonts
mkdir -p $chrootenvDest/etc/fonts/conf.d
ln -s ../../../host-etc/static/fonts/conf.d/00-nixos.conf $chrootenvDest/etc/fonts/conf.d
# Create root folder
mkdir $chrootenvDest/root
# Create tmp folder
mkdir -m1777 $chrootenvDest/tmp
mkdir -m1777 -p /tmp/chrootenv-@name@