diff options
author | Peter Simons <simons@cryp.to> | 2015-03-10 12:09:43 +0100 |
---|---|---|
committer | Peter Simons <simons@cryp.to> | 2015-03-10 12:09:43 +0100 |
commit | 6694ef42a9aba02a16dba72378a73122cbbafc75 (patch) | |
tree | 9473bd4d1e3ebaee30e7e689ba7dd4ddaf849513 /pkgs/build-support | |
parent | de892761cf10a161663fbf97c80f17281ed5e65f (diff) | |
parent | 8196130a1d922f24e77026d88859b824b15e40ba (diff) | |
download | nixlib-6694ef42a9aba02a16dba72378a73122cbbafc75.tar nixlib-6694ef42a9aba02a16dba72378a73122cbbafc75.tar.gz nixlib-6694ef42a9aba02a16dba72378a73122cbbafc75.tar.bz2 nixlib-6694ef42a9aba02a16dba72378a73122cbbafc75.tar.lz nixlib-6694ef42a9aba02a16dba72378a73122cbbafc75.tar.xz nixlib-6694ef42a9aba02a16dba72378a73122cbbafc75.tar.zst nixlib-6694ef42a9aba02a16dba72378a73122cbbafc75.zip |
Merge branch 'master' into staging.
Conflicts: pkgs/development/libraries/gtk+/2.x.nix pkgs/tools/security/gnupg/21.nix pkgs/top-level/all-packages.nix
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/autonix/default.nix | 6 | ||||
-rw-r--r-- | pkgs/build-support/build-fhs-chrootenv/env.nix | 52 | ||||
-rw-r--r-- | pkgs/build-support/build-fhs-chrootenv/init.sh.in | 29 | ||||
-rw-r--r-- | pkgs/build-support/build-fhs-chrootenv/load.sh.in | 8 | ||||
-rwxr-xr-x | pkgs/build-support/build-fhs-userenv/chroot-user.rb | 32 |
5 files changed, 64 insertions, 63 deletions
diff --git a/pkgs/build-support/autonix/default.nix b/pkgs/build-support/autonix/default.nix index 66e2700f192a..02862abca498 100644 --- a/pkgs/build-support/autonix/default.nix +++ b/pkgs/build-support/autonix/default.nix @@ -146,7 +146,11 @@ let mkDerivation = drv: stdenv.mkDerivation (drv // { src = fetchurl drv.src; }); - resolveDeps = scope: map (dep: scope."${dep}" or null); + resolveDeps = scope: + let resolveDeps_go = dep: + let res = scope."${dep}" or []; + in if isList res then res else [res]; + in concatMap resolveDeps_go; userEnvPkg = dep: mapAttrs diff --git a/pkgs/build-support/build-fhs-chrootenv/env.nix b/pkgs/build-support/build-fhs-chrootenv/env.nix index ee18f86893bb..d80e2869e5e6 100644 --- a/pkgs/build-support/build-fhs-chrootenv/env.nix +++ b/pkgs/build-support/build-fhs-chrootenv/env.nix @@ -62,7 +62,7 @@ let chosenGcc bashInteractive coreutils less shadow su gawk diffutils findutils gnused gnugrep - gnutar gzip bzip2 xz + gnutar gzip bzip2 xz glibcLocales ]; # Compose a global profile for the chroot environment @@ -72,6 +72,9 @@ let mkdir -p $out/etc cat >> $out/etc/profile << "EOF" export PS1='${name}-chrootenv:\u@\h:\w\$ ' + export LOCALE_ARCHIVE='/usr/lib${if is64Bit then "64" else ""}/locale/locale-archive' + export LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver-32/lib:/lib:/lib32:/lib64 + export PATH='/bin:/sbin' ${profile} EOF ''; @@ -81,15 +84,17 @@ let staticUsrProfileTarget = nixpkgs.buildEnv { name = "system-profile-target"; paths = basePkgs ++ [ profilePkg ] ++ targetPaths; + ignoreCollisions = true; }; staticUsrProfileMulti = nixpkgs.buildEnv { name = "system-profile-multi"; paths = multiPaths; + ignoreCollisions = true; }; 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" @@ -129,7 +134,7 @@ let mkdir -m0755 lib # copy content of targetPaths - cp -rsf ${staticUsrProfileTarget}/lib/* lib/ + cp -rsf ${staticUsrProfileTarget}/lib/* lib/ && chmod u+w -R lib/ ''; # setup /lib, /lib32 and /lib64 @@ -142,22 +147,56 @@ let cp -rsf ${staticUsrProfileTarget}/lib/32/* lib/ # copy content of multiPaths (32bit libs) - [ -d ${staticUsrProfileMulti}/lib ] && cp -rsf ${staticUsrProfileMulti}/lib/* lib/ + [ -d ${staticUsrProfileMulti}/lib ] && cp -rsf ${staticUsrProfileMulti}/lib/* lib/ && chmod u+w -R lib/ # copy content of targetPaths (64bit libs) - cp -rsf ${staticUsrProfileTarget}/lib/* lib64/ + cp -rsf ${staticUsrProfileTarget}/lib/* lib64/ && chmod u+w -R lib64/ # most 64bit only libs put their stuff into /lib # some pkgs (like gcc_multi) put 32bit libs into and /lib 64bit libs into /lib64 # by overwriting these we will hopefully catch all these cases # in the end /lib should only contain 32bit and /lib64 only 64bit libs - cp -rsf ${staticUsrProfileTarget}/lib64/* lib64/ + cp -rsf ${staticUsrProfileTarget}/lib64/* lib64/ && chmod u+w -R lib64/ # copy gcc libs (and may overwrite exitsting wrongly placed libs) cp -rsf ${chosenGcc.cc}/lib/* lib/ 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 +204,7 @@ in nixpkgs.stdenv.mkDerivation { cd $out ${setupTargetProfile} ${setupMultiProfile} + ${setupEtc} cd $out ${extraBuildCommands} cd $out diff --git a/pkgs/build-support/build-fhs-chrootenv/init.sh.in b/pkgs/build-support/build-fhs-chrootenv/init.sh.in index f3bdad85fa74..9078a31fe46a 100644 --- a/pkgs/build-support/build-fhs-chrootenv/init.sh.in +++ b/pkgs/build-support/build-fhs-chrootenv/init.sh.in @@ -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 diff --git a/pkgs/build-support/build-fhs-chrootenv/load.sh.in b/pkgs/build-support/build-fhs-chrootenv/load.sh.in index 6089fa275855..99da20c34b21 100644 --- a/pkgs/build-support/build-fhs-chrootenv/load.sh.in +++ b/pkgs/build-support/build-fhs-chrootenv/load.sh.in @@ -3,4 +3,10 @@ chrootenvDest=/run/chrootenv/@name@ # Enter the LFS chroot environment -sudo chroot --userspec "$USER:${GROUPS[0]}" --groups "${GROUPS[0]}" $chrootenvDest /usr/bin/env -i PS1="$PS1" TERM="$TERM" DISPLAY="$DISPLAY" HOME="$HOME" PATH="/bin:/sbin" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" /bin/bash --login +sudo chroot --userspec "$USER:${GROUPS[0]}" --groups "${GROUPS[0]}" $chrootenvDest /usr/bin/env -i \ + TERM="$TERM" \ + DISPLAY="$DISPLAY" \ + HOME="$HOME" \ + XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" \ + LANG="$LANG" \ + /bin/bash --login diff --git a/pkgs/build-support/build-fhs-userenv/chroot-user.rb b/pkgs/build-support/build-fhs-userenv/chroot-user.rb index 857ccd58cd7f..35608bd3eb60 100755 --- a/pkgs/build-support/build-fhs-userenv/chroot-user.rb +++ b/pkgs/build-support/build-fhs-userenv/chroot-user.rb @@ -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| @@ -136,13 +116,11 @@ if $cpid == 0 link_swdir.call swdir, Pathname.new('') # New environment - oldenv = ENV.to_h - ENV.replace({ 'PS1' => oldenv['PS1'], - 'TERM' => oldenv['TERM'], - 'DISPLAY' => oldenv['DISPLAY'], - 'HOME' => oldenv['HOME'], - 'PATH' => '/bin:/sbin', - 'XDG_RUNTIME_DIR' => oldenv['XDG_RUNTIME_DIR'], + ENV.replace({ 'TERM' => ENV['TERM'], + 'DISPLAY' => ENV['DISPLAY'], + 'HOME' => ENV['HOME'], + 'XDG_RUNTIME_DIR' => ENV['XDG_RUNTIME_DIR'], + 'LANG' => ENV['LANG'], }) # Finally, exec! |