anchor.diff:        cd $out/etc
   
         # environment variables
  -      cat >> profile << "EOF"
  +      cat >> 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'
  +      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
   
  
positive.code:     mkdir -p $out
      cd $out
      ${setupTargetProfile}
      ${setupMultiProfile}
      cd $out
      ${extraBuildCommands}
      cd $out
  
negative.code: { nixpkgs, nixpkgs_i686, system
  } :
  { name, profile ? ""
  , pkgs ? null, targetPkgs ? pkgs: [], multiPkgs ? pkgs: []
  , extraBuildCommands ? "", extraBuildCommandsMulti ? ""
  }:
  
  # HOWTO:
  # All packages (most likely programs) returned from targetPkgs will only be
  # installed once--matching the host's architecture (64bit on x86_64 and 32bit on
  # x86).
  #
  # Packages (most likely libraries) returned from multiPkgs are installed
  # once on x86 systems and twice on x86_64 systems.
  # On x86 they are merged with packages from targetPkgs.
  # On x86_64 they are added to targetPkgs and in addition their 32bit
  # versions are also installed. The final directory structure looks as
  # follows:
  # /lib32 will include 32bit libraries from multiPkgs
  # /lib64 will include 64bit libraries from multiPkgs and targetPkgs
  # /lib will link to /lib32
  
  let
    isMultiBuild  = pkgs == null && multiPkgs != null && system == "x86_64-linux";
    isTargetBuild = !isMultiBuild;
  
    # support deprecated "pkgs" option.
    targetPkgs' =
      if pkgs != null
        then builtins.trace "buildFHSEnv: 'pkgs' option is deprecated, use 'targetPkgs'" (pkgs': pkgs)
        else targetPkgs;
  
    # list of packages (usually programs) which are only be installed for the
    # host's architecture
    targetPaths = targetPkgs' nixpkgs ++ (if multiPkgs == null then [] else multiPkgs nixpkgs);
  
    # list of packages which are installed for both x86 and x86_64 on x86_64
    # systems
    multiPaths = if isMultiBuild
                    then multiPkgs nixpkgs_i686
                    else [];
  
    # base packages of the chroot
    # these match the host's architecture, gcc/glibc_multi are used for multilib
    # builds.
    chosenGcc = if isMultiBuild then nixpkgs.gcc_multi else nixpkgs.gcc;
    basePkgs = with nixpkgs;
      [ (if isMultiBuild then glibc_multi else glibc)
  