summary refs log tree commit diff
path: root/pkgs/build-support/build-fhs-chrootenv/env.nix
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2015-03-09 17:13:27 +0300
committerNikolay Amiantov <ab@fmap.me>2015-03-09 17:29:43 +0300
commit4aba7639c898f66e91ee71f8ed6df1df14f2419d (patch)
tree002e79bca542296ee73850a6618ddeb1ba3612c5 /pkgs/build-support/build-fhs-chrootenv/env.nix
parent95cd118d4f52aef3c0ef46e8f6e71e8e2daa84be (diff)
downloadnixpkgs-4aba7639c898f66e91ee71f8ed6df1df14f2419d.tar
nixpkgs-4aba7639c898f66e91ee71f8ed6df1df14f2419d.tar.gz
nixpkgs-4aba7639c898f66e91ee71f8ed6df1df14f2419d.tar.bz2
nixpkgs-4aba7639c898f66e91ee71f8ed6df1df14f2419d.tar.lz
nixpkgs-4aba7639c898f66e91ee71f8ed6df1df14f2419d.tar.xz
nixpkgs-4aba7639c898f66e91ee71f8ed6df1df14f2419d.tar.zst
nixpkgs-4aba7639c898f66e91ee71f8ed6df1df14f2419d.zip
chroot-env: build /etc
Diffstat (limited to 'pkgs/build-support/build-fhs-chrootenv/env.nix')
-rw-r--r--pkgs/build-support/build-fhs-chrootenv/env.nix37
1 files changed, 36 insertions, 1 deletions
diff --git a/pkgs/build-support/build-fhs-chrootenv/env.nix b/pkgs/build-support/build-fhs-chrootenv/env.nix
index ee18f86893b..19be38d1a01 100644
--- a/pkgs/build-support/build-fhs-chrootenv/env.nix
+++ b/pkgs/build-support/build-fhs-chrootenv/env.nix
@@ -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