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-10-21 15:57:58 +0300
committerNikolay Amiantov <ab@fmap.me>2015-10-21 16:02:08 +0300
commitda38314be64fe75979964ed245f7d598c517de93 (patch)
tree873f46f25d485c7202a777e7b67f16fe769b941a /pkgs/build-support/build-fhs-chrootenv/env.nix
parentdb0589b9fc36ad4961a7aca2af5bb5a284b9ffca (diff)
downloadnixpkgs-da38314be64fe75979964ed245f7d598c517de93.tar
nixpkgs-da38314be64fe75979964ed245f7d598c517de93.tar.gz
nixpkgs-da38314be64fe75979964ed245f7d598c517de93.tar.bz2
nixpkgs-da38314be64fe75979964ed245f7d598c517de93.tar.lz
nixpkgs-da38314be64fe75979964ed245f7d598c517de93.tar.xz
nixpkgs-da38314be64fe75979964ed245f7d598c517de93.tar.zst
nixpkgs-da38314be64fe75979964ed245f7d598c517de93.zip
buildFHSEnv: create /etc/profile with writeText
This should avoid accidential expansion of variables, i.e. in
"export PATH=/some/path:$PATH"
$PATH would have been expanded in the environment builder!
Diffstat (limited to 'pkgs/build-support/build-fhs-chrootenv/env.nix')
-rw-r--r--pkgs/build-support/build-fhs-chrootenv/env.nix16
1 files changed, 9 insertions, 7 deletions
diff --git a/pkgs/build-support/build-fhs-chrootenv/env.nix b/pkgs/build-support/build-fhs-chrootenv/env.nix
index 3acb0c8e6b7..a245778bf38 100644
--- a/pkgs/build-support/build-fhs-chrootenv/env.nix
+++ b/pkgs/build-support/build-fhs-chrootenv/env.nix
@@ -52,6 +52,14 @@ let
       gnutar gzip bzip2 xz glibcLocales
     ];
 
+  etcProfile = nixpkgs.writeText "profile" ''
+    export PS1='${name}-chrootenv:\u@\h:\w\$ '
+    export LOCALE_ARCHIVE='/usr/lib${if isMultiBuild then "64" else ""}/locale/locale-archive'
+    export LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver-32/lib:/lib:/lib64
+    export PATH='/usr/bin:/usr/sbin'
+    ${profile}
+  '';
+
   # Compose /etc for the chroot environment
   etcPkg = nixpkgs.stdenv.mkDerivation {
     name         = "${name}-chrootenv-etc";
@@ -60,13 +68,7 @@ let
       cd $out/etc
 
       # environment variables
-      cat >> profile <<EOF
-      export PS1='${name}-chrootenv:\u@\h:\w\$ '
-      export LOCALE_ARCHIVE='/usr/lib${if isMultiBuild then "64" else ""}/locale/locale-archive'
-      export LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver-32/lib:/lib:/lib64
-      export PATH='/usr/bin:/usr/sbin'
-      ${profile}
-      EOF
+      ln -s ${etcProfile} profile
 
       # compatibility with NixOS
       ln -s /host-etc/static static