forked from mirrors/nixpkgs
chroot-env: build /etc
This commit is contained in:
parent
95cd118d4f
commit
4aba7639c8
|
@ -89,7 +89,7 @@ let
|
|||
};
|
||||
|
||||
linkProfile = profile: ''
|
||||
for i in ${profile}/{etc,bin,sbin,share,var}; do
|
||||
for i in ${profile}/{bin,sbin,share,var}; do
|
||||
if [ -x "$i" ]
|
||||
then
|
||||
ln -s "$i"
|
||||
|
@ -158,6 +158,40 @@ let
|
|||
cp -rsf ${chosenGcc.cc}/lib64/* lib64/
|
||||
'';
|
||||
|
||||
setupEtc = ''
|
||||
mkdir -m0755 etc
|
||||
|
||||
# copy profile content
|
||||
cp -rsf ${staticUsrProfileTarget}/etc/* etc/ && chmod u+w -R etc/
|
||||
[ -d ${staticUsrProfileMulti}/etc ] && cp -rsf ${staticUsrProfileMulti}/etc/* etc/ && chmod u+w -R etc/
|
||||
|
||||
# compatibility with NixOS
|
||||
ln -s /host-etc/static etc/static
|
||||
|
||||
# symlink some NSS stuff
|
||||
ln -s /host-etc/passwd etc/passwd
|
||||
ln -s /host-etc/group etc/group
|
||||
ln -s /host-etc/shadow etc/shadow
|
||||
ln -s /host-etc/hosts etc/hosts
|
||||
ln -s /host-etc/resolv.conf etc/resolv.conf
|
||||
ln -s /host-etc/nsswitch.conf etc/nsswitch.conf
|
||||
|
||||
# symlink other core stuff
|
||||
ln -s /host-etc/localtime etc/localtime
|
||||
ln -s /host-etc/machine-id etc/machine-id
|
||||
|
||||
# symlink PAM stuff
|
||||
rm -rf etc/pam.d
|
||||
ln -s /host-etc/pam.d etc/pam.d
|
||||
|
||||
# symlink fonts stuff
|
||||
rm -rf etc/fonts
|
||||
ln -s /host-etc/fonts etc/fonts
|
||||
|
||||
# symlink ALSA stuff
|
||||
ln -s /host-etc/asound.conf etc/asound.conf
|
||||
'';
|
||||
|
||||
in nixpkgs.stdenv.mkDerivation {
|
||||
name = "${name}-fhs";
|
||||
buildCommand = ''
|
||||
|
@ -165,6 +199,7 @@ in nixpkgs.stdenv.mkDerivation {
|
|||
cd $out
|
||||
${setupTargetProfile}
|
||||
${setupMultiProfile}
|
||||
${setupEtc}
|
||||
cd $out
|
||||
${extraBuildCommands}
|
||||
cd $out
|
||||
|
|
|
@ -8,39 +8,12 @@ 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" ]
|
||||
if [ "$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
|
||||
|
||||
|
|
|
@ -17,20 +17,6 @@ mounts = [ ['/nix/store', nil],
|
|||
mkdirs = ['tmp',
|
||||
]
|
||||
|
||||
# Symlinks: [from, to (dir)]
|
||||
symlinks =
|
||||
# /etc symlinks: [file name, prefix in host-etc]
|
||||
[ ['passwd', ''],
|
||||
['group', ''],
|
||||
['shadow', ''],
|
||||
['hosts', ''],
|
||||
['resolv.conf', ''],
|
||||
['nsswitch.conf', ''],
|
||||
['pam.d', 'static'],
|
||||
['fonts/fonts.conf', 'static'],
|
||||
['fonts/conf.d/00-nixos.conf', 'static'],
|
||||
].map! { |x| [ "host-etc/#{x[1]}/#{x[0]}", "etc/#{File.dirname x[0]}" ] }
|
||||
|
||||
require 'tmpdir'
|
||||
require 'fileutils'
|
||||
require 'pathname'
|
||||
|
@ -111,12 +97,6 @@ if $cpid == 0
|
|||
Dir.chroot root
|
||||
Dir.chdir '/'
|
||||
|
||||
# Do symlinks
|
||||
symlinks.each do |x|
|
||||
FileUtils.mkdir_p x[1]
|
||||
FileUtils.ln_s x[0], x[1]
|
||||
end
|
||||
|
||||
# Symlink swdir hierarchy
|
||||
mount_dirs = Set.new mounts.map { |x| Pathname.new x[1] }
|
||||
link_swdir = lambda do |swdir, prefix|
|
||||
|
|
Loading…
Reference in a new issue