git.iko.soy/typeable/nixpkgs
on master help sign in
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!

commitda38314be64fe75979964ed245f7d598c517de93 authorNikolay Amiantov <ab@fmap.me> dateWed 21 Oct 2015, 15:57 (11 years ago) parentdb0589b
1 file changed+9−7
pkgs/build-support/build-fhs-chrootenv/env.nix+9−7
pkgs/build-support/build-fhs-chrootenv/env.nix+9−7
@@ -52,6 +52,14 @@ let
5252 gnutar gzip bzip2 xz glibcLocales
5353 ];
5454
55+ etcProfile = nixpkgs.writeText "profile" ''
56+ export PS1='${name}-chrootenv:\u@\h:\w\$ '
57+ export LOCALE_ARCHIVE='/usr/lib${if isMultiBuild then "64" else ""}/locale/locale-archive'
58+ export LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver-32/lib:/lib:/lib64
59+ export PATH='/usr/bin:/usr/sbin'
60+ ${profile}
61+ '';
62+
5563 # Compose /etc for the chroot environment
5664 etcPkg = nixpkgs.stdenv.mkDerivation {
5765 name = "${name}-chrootenv-etc";
@@ -60,13 +68,7 @@ let
6068 cd $out/etc
6169
6270 # environment variables
63− cat >> profile <<EOF
64− export PS1='${name}-chrootenv:\u@\h:\w\$ '
65− export LOCALE_ARCHIVE='/usr/lib${if isMultiBuild then "64" else ""}/locale/locale-archive'
66− export LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver-32/lib:/lib:/lib64
67− export PATH='/usr/bin:/usr/sbin'
68− ${profile}
69− EOF
71+ ln -s ${etcProfile} profile
7072
7173 # compatibility with NixOS
7274 ln -s /host-etc/static static