Merge branch 'p/orig-modular-stdenv' of github.com:vcunat/nixpkgs into staging

+508 -410
+1 -1
pkgs/applications/science/math/R/setup-hook.sh
··· 2 addToSearchPath R_LIBS_SITE $1/library 3 } 4 5 - envHooks=(${envHooks[@]} addRLibPath)
··· 2 addToSearchPath R_LIBS_SITE $1/library 3 } 4 5 + envHooks+=(addRLibPath)
+3 -1
pkgs/build-support/clang-wrapper/setup-hook.sh
··· 1 addCVars () { 2 if test -d $1/include; then 3 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include" ··· 12 fi 13 } 14 15 - envHooks=(${envHooks[@]} addCVars) 16 17 # Note: these come *after* $out in the PATH (see setup.sh). 18
··· 1 + export NIX_GCC=@out@ 2 + 3 addCVars () { 4 if test -d $1/include; then 5 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include" ··· 14 fi 15 } 16 17 + envHooks+=(addCVars) 18 19 # Note: these come *after* $out in the PATH (see setup.sh). 20
+1 -3
pkgs/build-support/fetchzip/default.nix
··· 13 , ... } @ args: 14 15 fetchurl ({ 16 - # Remove the extension, because otherwise unpackPhase will get 17 - # confused. FIXME: fix unpackPhase. 18 - name = args.name or lib.removeSuffix ".zip" (lib.removeSuffix ".tar.gz" (baseNameOf url)); 19 20 recursiveHash = true; 21
··· 13 , ... } @ args: 14 15 fetchurl ({ 16 + name = args.name or (baseNameOf url); 17 18 recursiveHash = true; 19
+1 -1
pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
··· 11 fi 12 } 13 14 - crossEnvHooks=(${crossEnvHooks[@]} crossAddCVars) 15 16 crossStripDirs() { 17 local dirs="$1"
··· 11 fi 12 } 13 14 + crossEnvHooks+=(crossAddCVars) 15 16 crossStripDirs() { 17 local dirs="$1"
+3 -1
pkgs/build-support/gcc-wrapper/setup-hook.sh
··· 1 addCVars () { 2 if test -d $1/include; then 3 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include" ··· 12 fi 13 } 14 15 - envHooks=(${envHooks[@]} addCVars) 16 17 # Note: these come *after* $out in the PATH (see setup.sh). 18
··· 1 + export NIX_GCC=@out@ 2 + 3 addCVars () { 4 if test -d $1/include; then 5 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include" ··· 14 fi 15 } 16 17 + envHooks+=(addCVars) 18 19 # Note: these come *after* $out in the PATH (see setup.sh). 20
+27
pkgs/build-support/setup-hooks/compress-man-pages.sh
···
··· 1 + fixupOutputHooks+=('if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; fi') 2 + 3 + compressManPages() { 4 + local dir="$1" 5 + 6 + echo "gzipping man pages in $dir" 7 + 8 + GLOBIGNORE=.:..:*.gz:*.bz2 9 + 10 + for f in "$dir"/share/man/*/* "$dir"/share/man/*/*/*; do 11 + if [ -f "$f" -a ! -L "$f" ]; then 12 + if gzip -c -n "$f" > "$f".gz; then 13 + rm "$f" 14 + else 15 + rm "$f".gz 16 + fi 17 + fi 18 + done 19 + 20 + for f in "$dir"/share/man/*/* "$dir"/share/man/*/*/*; do 21 + if [ -L "$f" -a -f `readlink -f "$f"`.gz ]; then 22 + ln -sf `readlink "$f"`.gz "$f".gz && rm "$f" 23 + fi 24 + done 25 + 26 + unset GLOBIGNORE 27 + }
+50
pkgs/build-support/setup-hooks/move-docs.sh
···
··· 1 + # This setup hook moves $out/{man,doc,info} to $out/share; moves 2 + # $out/share/man to $man/share/man; and moves $out/share/doc to 3 + # $man/share/doc. 4 + 5 + preFixupHooks+=(_moveDocs) 6 + 7 + _moveToShare() { 8 + forceShare=${forceShare:=man doc info} 9 + if [ -z "$forceShare" -o -z "$out" ]; then return; fi 10 + 11 + for d in $forceShare; do 12 + if [ -d "$out/$d" ]; then 13 + if [ -d "$out/share/$d" ]; then 14 + echo "both $d/ and share/$d/ exist!" 15 + else 16 + echo "moving $out/$d to $out/share/$d" 17 + mkdir -p $out/share 18 + mv $out/$d $out/share/ 19 + fi 20 + fi 21 + done 22 + } 23 + 24 + _moveToOutput() { 25 + local d="$1" 26 + local dst="$2" 27 + if [ -z "$dst" -a ! -e $dst/$d ]; then return; fi 28 + local output 29 + for output in $outputs; do 30 + if [ "${!output}" = "$dst" ]; then continue; fi 31 + if [ -d "${!output}/$d" ]; then 32 + echo "moving ${!output}/$d to $dst/$d" 33 + mkdir -p $dst/share 34 + mv ${!output}/$d $dst/$d 35 + break 36 + fi 37 + done 38 + } 39 + 40 + _moveDocs() { 41 + _moveToShare 42 + _moveToOutput share/man "$man" 43 + _moveToOutput share/info "$info" 44 + _moveToOutput share/doc "$doc" 45 + 46 + # Remove empty share directory. 47 + if [ -d "$out/share" ]; then 48 + rmdir $out/share 2> /dev/null || true 49 + fi 50 + }
+62
pkgs/build-support/setup-hooks/patch-shebangs.sh
···
··· 1 + # This setup hook causes the fixup phase to rewrite all script 2 + # interpreter file names (`#! /path') to paths found in $PATH. E.g., 3 + # /bin/sh will be rewritten to /nix/store/<hash>-some-bash/bin/sh. 4 + # /usr/bin/env gets special treatment so that ".../bin/env python" is 5 + # rewritten to /nix/store/<hash>/bin/python. Interpreters that are 6 + # already in the store are left untouched. 7 + 8 + fixupOutputHooks+=('if [ -z "$dontPatchShebangs" ]; then patchShebangs "$prefix"; fi') 9 + 10 + patchShebangs() { 11 + local dir="$1" 12 + header "patching script interpreter paths in $dir" 13 + local f 14 + local oldPath 15 + local newPath 16 + local arg0 17 + local args 18 + local oldInterpreterLine 19 + local newInterpreterLine 20 + 21 + find "$dir" -type f -perm +0100 | while read f; do 22 + if [ "$(head -1 "$f" | head -c +2)" != '#!' ]; then 23 + # missing shebang => not a script 24 + continue 25 + fi 26 + 27 + oldInterpreterLine=$(head -1 "$f" | tail -c +3) 28 + read -r oldPath arg0 args <<< "$oldInterpreterLine" 29 + 30 + if $(echo "$oldPath" | grep -q "/bin/env$"); then 31 + # Check for unsupported 'env' functionality: 32 + # - options: something starting with a '-' 33 + # - environment variables: foo=bar 34 + if $(echo "$arg0" | grep -q -- "^-.*\|.*=.*"); then 35 + echo "unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" 36 + exit 1 37 + fi 38 + newPath="$(command -v "$arg0" || true)" 39 + else 40 + if [ "$oldPath" = "" ]; then 41 + # If no interpreter is specified linux will use /bin/sh. Set 42 + # oldpath="/bin/sh" so that we get /nix/store/.../sh. 43 + oldPath="/bin/sh" 44 + fi 45 + newPath="$(command -v "$(basename "$oldPath")" || true)" 46 + args="$arg0 $args" 47 + fi 48 + 49 + newInterpreterLine="$newPath $args" 50 + 51 + if [ -n "$oldPath" -a "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then 52 + if [ -n "$newPath" -a "$newPath" != "$oldPath" ]; then 53 + echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\"" 54 + # escape the escape chars so that sed doesn't interpret them 55 + escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g') 56 + sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f" 57 + fi 58 + fi 59 + done 60 + 61 + stopNest 62 + }
+1 -1
pkgs/build-support/setup-hooks/set-java-classpath.sh
··· 10 done 11 } 12 13 - envHooks=(''${envHooks[@]} addPkgToClassPath)
··· 10 done 11 } 12 13 + envHooks+=(addPkgToClassPath)
+36
pkgs/build-support/setup-hooks/strip.sh
···
··· 1 + # This setup hook strips libraries and executables in the fixup phase. 2 + 3 + fixupOutputHooks+=(_doStrip) 4 + 5 + _doStrip() { 6 + if [ -z "$dontStrip" ]; then 7 + stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin} 8 + if [ -n "$stripDebugList" ]; then 9 + stripDirs "$stripDebugList" "${stripDebugFlags:--S}" 10 + fi 11 + 12 + stripAllList=${stripAllList:-} 13 + if [ -n "$stripAllList" ]; then 14 + stripDirs "$stripAllList" "${stripAllFlags:--s}" 15 + fi 16 + fi 17 + } 18 + 19 + stripDirs() { 20 + local dirs="$1" 21 + local stripFlags="$2" 22 + local dirsNew= 23 + 24 + for d in ${dirs}; do 25 + if [ -d "$prefix/$d" ]; then 26 + dirsNew="${dirsNew} $prefix/$d " 27 + fi 28 + done 29 + dirs=${dirsNew} 30 + 31 + if [ -n "${dirs}" ]; then 32 + header "stripping (with flags $stripFlags) in$dirs" 33 + find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} strip $commonStripFlags $stripFlags || true 34 + stopNest 35 + fi 36 + }
+1 -1
pkgs/desktops/e17/e_dbus/setup-hook.sh
··· 5 fi 6 } 7 8 - envHooks=(${envHooks[@]} addDbusIncludePath)
··· 5 fi 6 } 7 8 + envHooks+=(addDbusIncludePath)
+1 -1
pkgs/development/interpreters/guile/setup-hook-2.0.sh
··· 10 fi 11 } 12 13 - envHooks=(${envHooks[@]} addGuileLibPath)
··· 10 fi 11 } 12 13 + envHooks+=(addGuileLibPath)
+1 -1
pkgs/development/interpreters/guile/setup-hook.sh
··· 5 fi 6 } 7 8 - envHooks=(${envHooks[@]} addGuileLibPath)
··· 5 fi 6 } 7 8 + envHooks+=(addGuileLibPath)
+1 -1
pkgs/development/interpreters/perl/5.14/setup-hook.sh
··· 2 addToSearchPath PERL5LIB $1/lib/perl5/site_perl 3 } 4 5 - envHooks=(${envHooks[@]} addPerlLibPath)
··· 2 addToSearchPath PERL5LIB $1/lib/perl5/site_perl 3 } 4 5 + envHooks+=(addPerlLibPath)
+1 -1
pkgs/development/interpreters/perl/5.16/setup-hook.sh
··· 2 addToSearchPath PERL5LIB $1/lib/perl5/site_perl 3 } 4 5 - envHooks=(${envHooks[@]} addPerlLibPath)
··· 2 addToSearchPath PERL5LIB $1/lib/perl5/site_perl 3 } 4 5 + envHooks+=(addPerlLibPath)
+1 -1
pkgs/development/interpreters/perl/5.20/setup-hook.sh
··· 2 addToSearchPath PERL5LIB $1/lib/perl5/site_perl 3 } 4 5 - envHooks=(${envHooks[@]} addPerlLibPath)
··· 2 addToSearchPath PERL5LIB $1/lib/perl5/site_perl 3 } 4 5 + envHooks+=(addPerlLibPath)
+1 -1
pkgs/development/interpreters/perl/sys-perl/setup-hook.sh
··· 2 addToSearchPath PERL5LIB $1/@libPrefix@ 3 } 4 5 - envHooks=(${envHooks[@]} addPerlLibPath)
··· 2 addToSearchPath PERL5LIB $1/@libPrefix@ 3 } 4 5 + envHooks+=(addPerlLibPath)
+1 -1
pkgs/development/interpreters/pypy/2.3/setup-hook.sh
··· 12 echo $result 13 } 14 15 - envHooks=(${envHooks[@]} addPythonPath)
··· 12 echo $result 13 } 14 15 + envHooks+=(addPythonPath)
+1 -1
pkgs/development/interpreters/python/2.6/setup-hook.sh
··· 12 echo $result 13 } 14 15 - envHooks=(${envHooks[@]} addPythonPath)
··· 12 echo $result 13 } 14 15 + envHooks+=(addPythonPath)
+1 -1
pkgs/development/interpreters/python/2.7/setup-hook.sh
··· 12 echo $result 13 } 14 15 - envHooks=(${envHooks[@]} addPythonPath)
··· 12 echo $result 13 } 14 15 + envHooks+=(addPythonPath)
+1 -1
pkgs/development/interpreters/python/3.2/setup-hook.sh
··· 12 echo $result 13 } 14 15 - envHooks=(${envHooks[@]} addPythonPath)
··· 12 echo $result 13 } 14 15 + envHooks+=(addPythonPath)
+1 -1
pkgs/development/interpreters/python/3.3/setup-hook.sh
··· 12 echo $result 13 } 14 15 - envHooks=(${envHooks[@]} addPythonPath)
··· 12 echo $result 13 } 14 15 + envHooks+=(addPythonPath)
+1 -1
pkgs/development/interpreters/python/3.4/setup-hook.sh
··· 12 echo $result 13 } 14 15 - envHooks=(${envHooks[@]} addPythonPath)
··· 12 echo $result 13 } 14 15 + envHooks+=(addPythonPath)
+1 -1
pkgs/development/libraries/gstreamer/core/setup-hook.sh
··· 5 fi 6 } 7 8 - envHooks=(${envHooks[@]} addGstreamer1LibPath) 9
··· 5 fi 6 } 7 8 + envHooks+=(addGstreamer1LibPath) 9
+1 -1
pkgs/development/libraries/gstreamer/legacy/gstreamer/setup-hook.sh
··· 5 fi 6 } 7 8 - envHooks=(${envHooks[@]} addGstreamerLibPath)
··· 5 fi 6 } 7 8 + envHooks+=(addGstreamerLibPath)
+1 -1
pkgs/development/libraries/libxml2/setup-hook.sh
··· 23 # xmllint and xsltproc from looking in /etc/xml/catalog. 24 export XML_CATALOG_FILES 25 if test -z "$XML_CATALOG_FILES"; then XML_CATALOG_FILES=" "; fi 26 - envHooks=(${envHooks[@]} addXMLCatalogs) 27 fi
··· 23 # xmllint and xsltproc from looking in /etc/xml/catalog. 24 export XML_CATALOG_FILES 25 if test -z "$XML_CATALOG_FILES"; then XML_CATALOG_FILES=" "; fi 26 + envHooks+=(addXMLCatalogs) 27 fi
+1 -1
pkgs/development/libraries/slib/setup-hook.sh
··· 10 fi 11 } 12 13 - envHooks=(${envHooks[@]} addSlibPath)
··· 10 fi 11 } 12 13 + envHooks+=(addSlibPath)
+1 -1
pkgs/development/lisp-modules/clwrapper/setup-hook.sh
··· 33 34 export NIX_LISP_COMMAND NIX_LISP CL_SOURCE_REGISTRY NIX_LISP_ASDF 35 36 - envHooks=(envHooks[@] addASDFPaths setLisp collectNixLispLDLP) 37 38 mkdir -p "$HOME"/.cache/common-lisp || HOME="$TMP/.temp-$USER-home" 39 mkdir -p "$HOME"/.cache/common-lisp
··· 33 34 export NIX_LISP_COMMAND NIX_LISP CL_SOURCE_REGISTRY NIX_LISP_ASDF 35 36 + envHooks+=(addASDFPaths setLisp collectNixLispLDLP) 37 38 mkdir -p "$HOME"/.cache/common-lisp || HOME="$TMP/.temp-$USER-home" 39 mkdir -p "$HOME"/.cache/common-lisp
+1 -1
pkgs/development/ocaml-modules/ocamlmake/setup-hook.sh
··· 2 export OCAMLMAKEFILE="@out@/include/OCamlMakefile" 3 } 4 5 - envHooks=(${envHooks[@]} addOcamlMakefile)
··· 2 export OCAMLMAKEFILE="@out@/include/OCamlMakefile" 3 } 4 5 + envHooks+=(addOcamlMakefile)
+1 -1
pkgs/development/tools/misc/automake/setup-hook.sh
··· 2 addToSearchPathWithCustomDelimiter : ACLOCAL_PATH $1/share/aclocal 3 } 4 5 - envHooks=(${envHooks[@]} addAclocals)
··· 2 addToSearchPathWithCustomDelimiter : ACLOCAL_PATH $1/share/aclocal 3 } 4 5 + envHooks+=(addAclocals)
+2
pkgs/development/tools/misc/patchelf/default.nix
··· 8 sha256 = "c99f84d124347340c36707089ec8f70530abd56e7827c54d506eb4cc097a17e7"; 9 }; 10 11 meta = { 12 homepage = http://nixos.org/patchelf.html; 13 license = "GPL";
··· 8 sha256 = "c99f84d124347340c36707089ec8f70530abd56e7827c54d506eb4cc097a17e7"; 9 }; 10 11 + setupHook = [ ./setup-hook.sh ]; 12 + 13 meta = { 14 homepage = http://nixos.org/patchelf.html; 15 license = "GPL";
+16
pkgs/development/tools/misc/patchelf/setup-hook.sh
···
··· 1 + # This setup hook calls patchelf to automatically remove unneeded 2 + # directories from the RPATH of every library or executable in every 3 + # output. 4 + 5 + fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi') 6 + 7 + patchELF() { 8 + header "patching ELF executables and libraries in $prefix" 9 + if [ -e "$prefix" ]; then 10 + find "$prefix" \( \ 11 + \( -type f -a -name "*.so*" \) -o \ 12 + \( -type f -a -perm +0100 \) \ 13 + \) -print -exec patchelf --shrink-rpath '{}' \; 14 + fi 15 + stopNest 16 + }
+2 -2
pkgs/development/tools/misc/pkgconfig/setup-hook.sh
··· 4 } 5 6 if test -n "$crossConfig"; then 7 - crossEnvHooks=(${crossEnvHooks[@]} addPkgConfigPath) 8 else 9 - envHooks=(${envHooks[@]} addPkgConfigPath) 10 fi
··· 4 } 5 6 if test -n "$crossConfig"; then 7 + crossEnvHooks+=(addPkgConfigPath) 8 else 9 + envHooks+=(addPkgConfigPath) 10 fi
+2 -2
pkgs/development/tools/ocaml/findlib/default.nix
··· 42 mkdir -p $OCAMLFIND_DESTDIR 43 fi 44 } 45 - 46 - envHooks=(''${envHooks[@]} addOCamlPath) 47 ''; 48 49 meta = {
··· 42 mkdir -p $OCAMLFIND_DESTDIR 43 fi 44 } 45 + 46 + envHooks+=(addOCamlPath) 47 ''; 48 49 meta = {
+1 -1
pkgs/development/web/nodejs/setup-hook.sh
··· 2 addToSearchPath NODE_PATH $1/lib/node_modules 3 } 4 5 - envHooks=(${envHooks[@]} addNodePath)
··· 2 addToSearchPath NODE_PATH $1/lib/node_modules 3 } 4 5 + envHooks+=(addNodePath)
+2
pkgs/os-specific/linux/paxctl/default.nix
··· 18 "MANDIR=share/man/man1" 19 ]; 20 21 meta = with stdenv.lib; { 22 description = "A tool for controlling PaX flags on a per binary basis"; 23 homepage = "https://pax.grsecurity.net";
··· 18 "MANDIR=share/man/man1" 19 ]; 20 21 + setupHook = ./setup-hook.sh; 22 + 23 meta = with stdenv.lib; { 24 description = "A tool for controlling PaX flags on a per binary basis"; 25 homepage = "https://pax.grsecurity.net";
+8
pkgs/os-specific/linux/paxctl/setup-hook.sh
···
··· 1 + # PaX-mark binaries. 2 + paxmark() { 3 + local flags="$1" 4 + shift 5 + 6 + paxctl -c "$@" 7 + paxctl -zex -${flags} "$@" 8 + }
+3 -3
pkgs/stdenv/default.nix
··· 5 # Posix utilities, the GNU C compiler, and so on. On other systems, 6 # we use the native C library. 7 8 - { system, allPackages ? import ../.., platform, config }: 9 10 11 rec { ··· 28 29 # The Nix build environment. 30 stdenvNix = import ./nix { 31 - inherit config; 32 stdenv = stdenvNative; 33 pkgs = stdenvNativePkgs; 34 }; 35 36 37 # Linux standard environment. 38 - stdenvLinux = (import ./linux { inherit system allPackages platform config;}).stdenvLinux; 39 40 41 # Select the appropriate stdenv for the platform `system'.
··· 5 # Posix utilities, the GNU C compiler, and so on. On other systems, 6 # we use the native C library. 7 8 + { system, allPackages ? import ../.., platform, config, lib }: 9 10 11 rec { ··· 28 29 # The Nix build environment. 30 stdenvNix = import ./nix { 31 + inherit config lib; 32 stdenv = stdenvNative; 33 pkgs = stdenvNativePkgs; 34 }; 35 36 37 # Linux standard environment. 38 + stdenvLinux = (import ./linux { inherit system allPackages platform config lib; }).stdenvLinux; 39 40 41 # Select the appropriate stdenv for the platform `system'.
+3 -8
pkgs/stdenv/generic/builder.sh
··· 6 7 mkdir $out 8 9 - echo "$preHook" > $out/setup 10 cat "$setup" >> $out/setup 11 - 12 - sed -e "s^@initialPath@^$initialPath^g" \ 13 - -e "s^@gcc@^$gcc^g" \ 14 - -e "s^@shell@^$shell^g" \ 15 - -e "s^@needsPax@^$needsPax^g" \ 16 - < $out/setup > $out/setup.tmp 17 - mv $out/setup.tmp $out/setup 18 19 # Allow the user to install stdenv using nix-env and get the packages 20 # in stdenv.
··· 6 7 mkdir $out 8 9 + echo "export SHELL=$shell" > $out/setup 10 + echo "initialPath=\"$initialPath\"" >> $out/setup 11 + echo "$preHook" >> $out/setup 12 cat "$setup" >> $out/setup 13 14 # Allow the user to install stdenv using nix-env and get the packages 15 # in stdenv.
+86 -81
pkgs/stdenv/generic/default.nix
··· 10 , setupScript ? ./setup.sh 11 12 , extraBuildInputs ? [] 13 - 14 - , skipPaxMarking ? false 15 }: 16 17 let ··· 23 # {pkgs, ...}: 24 # { 25 # allowUnfree = false; 26 - # allowUnfreePredicate = (x: pkgs.lib.hasPrefix "flashplayero-" x.name); 27 # } 28 allowUnfreePredicate = config.allowUnfreePredicate or (x: false); 29 ··· 41 42 unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null); 43 44 # The stdenv that we are producing. 45 result = 46 ··· 50 builder = shell; 51 52 args = ["-e" ./builder.sh]; 53 - /* TODO: special-cased @var@ substitutions are ugly. 54 - However, using substituteAll* from setup.sh seems difficult, 55 - as setup.sh can't be directly sourced. 56 - Suggestion: split similar utility functions into a separate script. 57 - */ 58 59 setup = setupScript; 60 61 - inherit preHook initialPath gcc shell; 62 - 63 - # Whether we should run paxctl to pax-mark binaries 64 - needsPax = result.isLinux && !skipPaxMarking; 65 66 propagatedUserEnvPkgs = [gcc] ++ 67 lib.filter lib.isDerivation initialPath; ··· 69 70 // rec { 71 72 - meta = { 73 - description = "The default build environment for Unix packages in Nixpkgs"; 74 - }; 75 - 76 - # Add a utility function to produce derivations that use this 77 - # stdenv and its shell. 78 - mkDerivation = attrs: 79 - let 80 - pos = 81 - if attrs.meta.description or null != null then 82 - unsafeGetAttrPos "description" attrs.meta 83 - else 84 - unsafeGetAttrPos "name" attrs; 85 - pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»"; 86 - in 87 - if !allowUnfree && (let l = lib.lists.toList attrs.meta.license or []; in lib.lists.elem "unfree" l || lib.lists.elem "unfree-redistributable" l) && !(allowUnfreePredicate attrs) then 88 - throw '' 89 - Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. 90 - ${forceEvalHelp "Unfree"}'' 91 - else if !allowBroken && attrs.meta.broken or false then 92 - throw '' 93 - Package ‘${attrs.name}’ in ${pos'} is marked as broken, refusing to evaluate. 94 - ${forceEvalHelp "Broken"}'' 95 - else if !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem result.system attrs.meta.platforms then 96 - throw '' 97 - Package ‘${attrs.name}’ in ${pos'} is not supported on ‘${result.system}’, refusing to evaluate. 98 - ${forceEvalHelp "Broken"}'' 99 - else 100 - lib.addPassthru (derivation ( 101 - (removeAttrs attrs ["meta" "passthru" "crossAttrs"]) 102 - // (let 103 - buildInputs = attrs.buildInputs or []; 104 - nativeBuildInputs = attrs.nativeBuildInputs or []; 105 - propagatedBuildInputs = attrs.propagatedBuildInputs or []; 106 - propagatedNativeBuildInputs = attrs.propagatedNativeBuildInputs or []; 107 - crossConfig = attrs.crossConfig or null; 108 - in 109 - { 110 - builder = attrs.realBuilder or shell; 111 - args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)]; 112 - stdenv = result; 113 - system = result.system; 114 - userHook = config.stdenv.userHook or null; 115 - __ignoreNulls = true; 116 - 117 - # Inputs built by the cross compiler. 118 - buildInputs = lib.optionals (crossConfig != null) (buildInputs ++ extraBuildInputs); 119 - propagatedBuildInputs = lib.optionals (crossConfig != null) propagatedBuildInputs; 120 - # Inputs built by the usual native compiler. 121 - nativeBuildInputs = nativeBuildInputs ++ lib.optionals (crossConfig == null) (buildInputs ++ extraBuildInputs); 122 - propagatedNativeBuildInputs = propagatedNativeBuildInputs ++ 123 - lib.optionals (crossConfig == null) propagatedBuildInputs; 124 - }))) ( 125 - { 126 - # The meta attribute is passed in the resulting attribute set, 127 - # but it's not part of the actual derivation, i.e., it's not 128 - # passed to the builder and is not a dependency. But since we 129 - # include it in the result, it *is* available to nix-env for 130 - # queries. We also a meta.position attribute here to 131 - # identify the source location of the package. 132 - meta = attrs.meta or {} // (if pos != null then { 133 - position = pos.file + ":" + (toString pos.line); 134 - } else {}); 135 - passthru = attrs.passthru or {}; 136 - } // 137 - # Pass through extra attributes that are not inputs, but 138 - # should be made available to Nix expressions using the 139 - # derivation (e.g., in assertions). 140 - (attrs.passthru or {})); 141 142 # Utility flags to test the type of platform. 143 isDarwin = system == "x86_64-darwin"; ··· 185 || system == "armv6l-linux" 186 || system == "armv7l-linux"; 187 188 # For convenience, bring in the library functions in lib/ so 189 # packages don't have to do that themselves. 190 inherit lib; ··· 192 inherit fetchurlBoot; 193 194 inherit overrides; 195 } 196 197 # Propagate any extra attributes. For instance, we use this to
··· 10 , setupScript ? ./setup.sh 11 12 , extraBuildInputs ? [] 13 }: 14 15 let ··· 21 # {pkgs, ...}: 22 # { 23 # allowUnfree = false; 24 + # allowUnfreePredicate = (x: pkgs.lib.hasPrefix "flashplayer-" x.name); 25 # } 26 allowUnfreePredicate = config.allowUnfreePredicate or (x: false); 27 ··· 39 40 unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null); 41 42 + extraBuildInputs' = extraBuildInputs ++ 43 + [ ../../build-support/setup-hooks/move-docs.sh 44 + ../../build-support/setup-hooks/compress-man-pages.sh 45 + ../../build-support/setup-hooks/strip.sh 46 + ../../build-support/setup-hooks/patch-shebangs.sh 47 + gcc 48 + ]; 49 + 50 + # Add a utility function to produce derivations that use this 51 + # stdenv and its shell. 52 + mkDerivation = attrs: 53 + let 54 + pos = 55 + if attrs.meta.description or null != null then 56 + unsafeGetAttrPos "description" attrs.meta 57 + else 58 + unsafeGetAttrPos "name" attrs; 59 + pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»"; 60 + in 61 + if !allowUnfree 62 + && (let l = lib.lists.toList attrs.meta.license or []; in lib.lists.elem "unfree" l || lib.lists.elem "unfree-redistributable" l) 63 + && !allowUnfreePredicate attrs then 64 + throw '' 65 + Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. 66 + ${forceEvalHelp "Unfree"}'' 67 + else if !allowBroken && attrs.meta.broken or false then 68 + throw '' 69 + Package ‘${attrs.name}’ in ${pos'} is marked as broken, refusing to evaluate. 70 + ${forceEvalHelp "Broken"}'' 71 + else if !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem result.system attrs.meta.platforms then 72 + throw '' 73 + Package ‘${attrs.name}’ in ${pos'} is not supported on ‘${result.system}’, refusing to evaluate. 74 + ${forceEvalHelp "Broken"}'' 75 + else 76 + lib.addPassthru (derivation ( 77 + (removeAttrs attrs ["meta" "passthru" "crossAttrs"]) 78 + // (let 79 + buildInputs = attrs.buildInputs or []; 80 + nativeBuildInputs = attrs.nativeBuildInputs or []; 81 + propagatedBuildInputs = attrs.propagatedBuildInputs or []; 82 + propagatedNativeBuildInputs = attrs.propagatedNativeBuildInputs or []; 83 + crossConfig = attrs.crossConfig or null; 84 + in 85 + { 86 + builder = attrs.realBuilder or shell; 87 + args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)]; 88 + stdenv = result; 89 + system = result.system; 90 + userHook = config.stdenv.userHook or null; 91 + __ignoreNulls = true; 92 + 93 + # Inputs built by the cross compiler. 94 + buildInputs = lib.optionals (crossConfig != null) (buildInputs ++ extraBuildInputs'); 95 + propagatedBuildInputs = lib.optionals (crossConfig != null) propagatedBuildInputs; 96 + # Inputs built by the usual native compiler. 97 + nativeBuildInputs = nativeBuildInputs ++ lib.optionals (crossConfig == null) (buildInputs ++ extraBuildInputs'); 98 + propagatedNativeBuildInputs = propagatedNativeBuildInputs ++ 99 + lib.optionals (crossConfig == null) propagatedBuildInputs; 100 + }))) ( 101 + { 102 + # The meta attribute is passed in the resulting attribute set, 103 + # but it's not part of the actual derivation, i.e., it's not 104 + # passed to the builder and is not a dependency. But since we 105 + # include it in the result, it *is* available to nix-env for 106 + # queries. We also a meta.position attribute here to 107 + # identify the source location of the package. 108 + meta = attrs.meta or {} // (if pos != null then { 109 + position = pos.file + ":" + (toString pos.line); 110 + } else {}); 111 + passthru = attrs.passthru or {}; 112 + } // 113 + # Pass through extra attributes that are not inputs, but 114 + # should be made available to Nix expressions using the 115 + # derivation (e.g., in assertions). 116 + (attrs.passthru or {})); 117 + 118 # The stdenv that we are producing. 119 result = 120 ··· 124 builder = shell; 125 126 args = ["-e" ./builder.sh]; 127 128 setup = setupScript; 129 130 + inherit preHook initialPath shell; 131 132 propagatedUserEnvPkgs = [gcc] ++ 133 lib.filter lib.isDerivation initialPath; ··· 135 136 // rec { 137 138 + meta.description = "The default build environment for Unix packages in Nixpkgs"; 139 140 # Utility flags to test the type of platform. 141 isDarwin = system == "x86_64-darwin"; ··· 183 || system == "armv6l-linux" 184 || system == "armv7l-linux"; 185 186 + # Whether we should run paxctl to pax-mark binaries. 187 + needsPax = isLinux; 188 + 189 + inherit mkDerivation; 190 + 191 # For convenience, bring in the library functions in lib/ so 192 # packages don't have to do that themselves. 193 inherit lib; ··· 195 inherit fetchurlBoot; 196 197 inherit overrides; 198 + 199 + inherit gcc; 200 } 201 202 # Propagate any extra attributes. For instance, we use this to
+146 -252
pkgs/stdenv/generic/setup.sh
··· 1 - # Run the named hook, either by calling the function with that name or 2 - # by evaluating the variable with that name. This allows convenient 3 - # setting of hooks both from Nix expressions (as attributes / 4 - # environment variables) and from shell scripts (as functions). 5 runHook() { 6 local hookName="$1" 7 case "$(type -t $hookName)" in 8 (function|alias|builtin) $hookName;; 9 (file) source $hookName;; 10 (keyword) :;; 11 - (*) eval "${!hookName}";; 12 esac 13 } 14 15 16 exitHandler() { 17 exitCode=$? 18 set +e ··· 55 56 57 ###################################################################### 58 - # Helper functions that might be useful in setup hooks. 59 60 61 addToSearchPathWithCustomDelimiter() { ··· 74 } 75 76 77 - ###################################################################### 78 - # Initialisation. 79 80 - set -e 81 82 - [ -z $NIX_GCC ] && NIX_GCC=@gcc@ 83 84 85 # Wildcard expansions that don't match should expand to an empty list. ··· 90 91 # Set up the initial path. 92 PATH= 93 - for i in $NIX_GCC @initialPath@; do 94 if [ "$i" = / ]; then i=; fi 95 addToSearchPath PATH $i/bin 96 addToSearchPath PATH $i/sbin ··· 101 fi 102 103 104 - # Execute the pre-hook. 105 - export SHELL=@shell@ 106 - export CONFIG_SHELL="$SHELL" 107 - if [ -z "$shell" ]; then export shell=@shell@; fi 108 - runHook preHook 109 - 110 - 111 # Check that the pre-hook initialised SHELL. 112 if [ -z "$SHELL" ]; then echo "SHELL not set"; exit 1; fi 113 114 - # Hack: run gcc's setup hook. 115 - envHooks=() 116 - crossEnvHooks=() 117 - if [ -f $NIX_GCC/nix-support/setup-hook ]; then 118 - source $NIX_GCC/nix-support/setup-hook 119 - fi 120 121 - 122 - # Ensure that the given directories exists. 123 - ensureDir() { 124 - echo "warning: ‘ensureDir’ is deprecated; use ‘mkdir’ instead" >&2 125 - local dir 126 - for dir in "$@"; do 127 - if ! [ -x "$dir" ]; then mkdir -p "$dir"; fi 128 - done 129 - } 130 - 131 - installBin() { 132 - mkdir -p $out/bin 133 - cp "$@" $out/bin 134 - } 135 136 137 # Allow the caller to augment buildInputs (it's not always possible to ··· 154 155 eval $var="'${!var} $pkg '" 156 157 if [ -f $pkg/nix-support/setup-hook ]; then 158 source $pkg/nix-support/setup-hook 159 fi ··· 178 179 # Set the relevant environment variables to point to the build inputs 180 # found above. 181 - addToNativeEnv() { 182 local pkg=$1 183 184 if [ -d $1/bin ]; then ··· 186 fi 187 188 # Run the package-specific hooks set by the setup-hook scripts. 189 - for i in "${envHooks[@]}"; do 190 - $i $pkg 191 - done 192 } 193 194 for i in $nativePkgs; do 195 - addToNativeEnv $i 196 done 197 198 - addToCrossEnv() { 199 local pkg=$1 200 201 # Some programs put important build scripts (freetype-config and similar) ··· 206 fi 207 208 # Run the package-specific hooks set by the setup-hook scripts. 209 - for i in "${crossEnvHooks[@]}"; do 210 - $i $pkg 211 - done 212 } 213 214 for i in $crossPkgs; do 215 - addToCrossEnv $i 216 done 217 218 ··· 273 export NIX_BUILD_CORES 274 275 276 - ###################################################################### 277 - # Misc. helper functions. 278 279 280 - stripDirs() { 281 - local dirs="$1" 282 - local stripFlags="$2" 283 - local dirsNew= 284 - 285 - for d in ${dirs}; do 286 - if [ -d "$prefix/$d" ]; then 287 - dirsNew="${dirsNew} $prefix/$d " 288 - fi 289 - done 290 - dirs=${dirsNew} 291 - 292 - if [ -n "${dirs}" ]; then 293 - header "stripping (with flags $stripFlags) in $dirs" 294 - find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} strip $commonStripFlags $stripFlags || true 295 - stopNest 296 - fi 297 - } 298 - 299 - # PaX-mark binaries 300 - paxmark() { 301 - local flags="$1" 302 - shift 303 - 304 - if [ -z "@needsPax@" ]; then 305 - return 306 - fi 307 - 308 - paxctl -c "$@" 309 - paxctl -zex -${flags} "$@" 310 - } 311 - 312 ###################################################################### 313 # Textual substitution functions. 314 ··· 439 } 440 441 442 - unpackFile() { 443 - curSrc="$1" 444 - local cmd 445 446 - header "unpacking source archive $curSrc" 3 447 448 - case "$curSrc" in 449 - *.tar.xz | *.tar.lzma) 450 - # Don't rely on tar knowing about .xz. 451 - xz -d < $curSrc | tar xf - 452 - ;; 453 - *.tar | *.tar.* | *.tgz | *.tbz2) 454 - # GNU tar can automatically select the decompression method 455 - # (info "(tar) gzip"). 456 - tar xf $curSrc 457 - ;; 458 - *.zip) 459 - unzip -qq $curSrc 460 - ;; 461 - *) 462 - if [ -d "$curSrc" ]; then 463 - stripHash $curSrc 464 - cp -prd --no-preserve=timestamps $curSrc $strippedName 465 - else 466 - if [ -z "$unpackCmd" ]; then 467 - echo "source archive $curSrc has unknown type" 468 - exit 1 469 - fi 470 - runHook unpackCmd 471 - fi 472 - ;; 473 - esac 474 475 stopNest 476 } 477 ··· 505 506 # Find the source directory. 507 if [ -n "$setSourceRoot" ]; then 508 - runHook setSourceRoot 509 elif [ -z "$sourceRoot" ]; then 510 sourceRoot= 511 for i in *; do ··· 654 } 655 656 657 - patchELF() { 658 - # Patch all ELF executables and shared libraries. 659 - header "patching ELF executables and libraries" 660 - if [ -e "$prefix" ]; then 661 - find "$prefix" \( \ 662 - \( -type f -a -name "*.so*" \) -o \ 663 - \( -type f -a -perm +0100 \) \ 664 - \) -print -exec patchelf --shrink-rpath '{}' \; 665 - fi 666 - stopNest 667 - } 668 - 669 - 670 - patchShebangs() { 671 - # Rewrite all script interpreter file names (`#! /path') under the 672 - # specified directory tree to paths found in $PATH. E.g., 673 - # /bin/sh will be rewritten to /nix/store/<hash>-some-bash/bin/sh. 674 - # /usr/bin/env gets special treatment so that ".../bin/env python" is 675 - # rewritten to /nix/store/<hash>/bin/python. 676 - # Interpreters that are already in the store are left untouched. 677 - header "patching script interpreter paths" 678 - local dir="$1" 679 - local f 680 - local oldPath 681 - local newPath 682 - local arg0 683 - local args 684 - local oldInterpreterLine 685 - local newInterpreterLine 686 - 687 - find "$dir" -type f -perm +0100 | while read f; do 688 - if [ "$(head -1 "$f" | head -c +2)" != '#!' ]; then 689 - # missing shebang => not a script 690 - continue 691 - fi 692 - 693 - oldInterpreterLine=$(head -1 "$f" | tail -c +3) 694 - read -r oldPath arg0 args <<< "$oldInterpreterLine" 695 - 696 - if $(echo "$oldPath" | grep -q "/bin/env$"); then 697 - # Check for unsupported 'env' functionality: 698 - # - options: something starting with a '-' 699 - # - environment variables: foo=bar 700 - if $(echo "$arg0" | grep -q -- "^-.*\|.*=.*"); then 701 - echo "unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" 702 - exit 1 703 - fi 704 - newPath="$(command -v "$arg0" || true)" 705 - else 706 - if [ "$oldPath" = "" ]; then 707 - # If no interpreter is specified linux will use /bin/sh. Set 708 - # oldpath="/bin/sh" so that we get /nix/store/.../sh. 709 - oldPath="/bin/sh" 710 - fi 711 - newPath="$(command -v "$(basename "$oldPath")" || true)" 712 - args="$arg0 $args" 713 - fi 714 - 715 - newInterpreterLine="$newPath $args" 716 - 717 - if [ -n "$oldPath" -a "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then 718 - if [ -n "$newPath" -a "$newPath" != "$oldPath" ]; then 719 - echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\"" 720 - # escape the escape chars so that sed doesn't interpret them 721 - escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g') 722 - sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f" 723 - fi 724 - fi 725 - done 726 - 727 - stopNest 728 - } 729 - 730 - 731 installPhase() { 732 runHook preInstall 733 ··· 743 } 744 745 746 - # The fixup phase performs generic, package-independent, Nix-related 747 - # stuff, like running patchelf and setting the 748 - # propagated-build-inputs. It should rarely be overriden. 749 fixupPhase() { 750 - runHook preFixup 751 - 752 # Make sure everything is writable so "strip" et al. work. 753 - if [ -e "$prefix" ]; then chmod -R u+w "$prefix"; fi 754 - 755 - # Put man/doc/info under $out/share. 756 - forceShare=${forceShare:=man doc info} 757 - if [ -n "$forceShare" ]; then 758 - for d in $forceShare; do 759 - if [ -d "$prefix/$d" ]; then 760 - if [ -d "$prefix/share/$d" ]; then 761 - echo "both $d/ and share/$d/ exists!" 762 - else 763 - echo "fixing location of $d/ subdirectory" 764 - mkdir -p $prefix/share 765 - if [ -w $prefix/share ]; then 766 - mv -v $prefix/$d $prefix/share 767 - ln -sv share/$d $prefix 768 - fi 769 - fi 770 - fi 771 - done; 772 - fi 773 774 - if [ -z "$dontGzipMan" ]; then 775 - echo "gzipping man pages" 776 - GLOBIGNORE=.:..:*.gz:*.bz2 777 - for f in "$out"/share/man/*/* "$out"/share/man/*/*/*; do 778 - if [ -f "$f" -a ! -L "$f" ]; then 779 - if gzip -c -n "$f" > "$f".gz; then 780 - rm "$f" 781 - else 782 - rm "$f".gz 783 - fi 784 - fi 785 - done 786 - for f in "$out"/share/man/*/* "$out"/share/man/*/*/*; do 787 - if [ -L "$f" -a -f `readlink -f "$f"`.gz ]; then 788 - ln -sf `readlink "$f"`.gz "$f".gz && rm "$f" 789 - fi 790 - done 791 - unset GLOBIGNORE 792 - fi 793 794 - # TODO: strip _only_ ELF executables, and return || fail here... 795 - if [ -z "$dontStrip" ]; then 796 - stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin} 797 - if [ -n "$stripDebugList" ]; then 798 - stripDirs "$stripDebugList" "${stripDebugFlags:--S}" 799 - fi 800 - 801 - stripAllList=${stripAllList:-} 802 - if [ -n "$stripAllList" ]; then 803 - stripDirs "$stripAllList" "${stripAllFlags:--s}" 804 - fi 805 - fi 806 - 807 - if [ "$havePatchELF" = 1 -a -z "$dontPatchELF" ]; then 808 - patchELF "$prefix" 809 - fi 810 - 811 - if [ -z "$dontPatchShebangs" ]; then 812 - patchShebangs "$prefix" 813 - fi 814 815 if [ -n "$propagatedBuildInputs" ]; then 816 mkdir -p "$out/nix-support" ··· 935 936 937 # Execute the post-hooks. 938 - for i in "${postHooks[@]}"; do $i; done 939 runHook postHook 940 941
··· 1 + set -e 2 + 3 + : ${outputs:=out} 4 + 5 + 6 + ###################################################################### 7 + # Hook handling. 8 + 9 + 10 + # Run all hooks with the specified name in the order in which they 11 + # were added, stopping if any fails (returns a non-zero exit 12 + # code). The hooks for <hookName> are the shell function or variable 13 + # <hookName>, and the values of the shell array ‘<hookName>Hooks’. 14 runHook() { 15 local hookName="$1" 16 + shift 17 + local var="$hookName" 18 + if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi 19 + eval "local -a dummy=(\"\${$var[@]}\")" 20 + for hook in "_callImplicitHook 0 $hookName" "${dummy[@]}"; do 21 + if ! _eval "$hook" "$@"; then return 1; fi 22 + done 23 + return 0 24 + } 25 + 26 + 27 + # Run all hooks with the specified name, until one succeeds (returns a 28 + # zero exit code). If none succeed, return a non-zero exit code. 29 + runOneHook() { 30 + local hookName="$1" 31 + shift 32 + local var="$hookName" 33 + if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi 34 + eval "local -a dummy=(\"\${$var[@]}\")" 35 + for hook in "_callImplicitHook 1 $hookName" "${dummy[@]}"; do 36 + if _eval "$hook" "$@"; then 37 + return 0 38 + fi 39 + done 40 + return 1 41 + } 42 + 43 + 44 + # Run the named hook, either by calling the function with that name or 45 + # by evaluating the variable with that name. This allows convenient 46 + # setting of hooks both from Nix expressions (as attributes / 47 + # environment variables) and from shell scripts (as functions). If you 48 + # want to allow multiple hooks, use runHook instead. 49 + _callImplicitHook() { 50 + local def="$1" 51 + local hookName="$2" 52 case "$(type -t $hookName)" in 53 (function|alias|builtin) $hookName;; 54 (file) source $hookName;; 55 (keyword) :;; 56 + (*) if [ -z "${!hookName}" ]; then return "$def"; else eval "${!hookName}"; fi;; 57 esac 58 } 59 60 61 + # A function wrapper around ‘eval’ that ensures that ‘return’ inside 62 + # hooks exits the hook, not the caller. 63 + _eval() { 64 + local code="$1" 65 + shift 66 + if [ "$(type -t $code)" = function ]; then 67 + eval "$code \"\$@\"" 68 + else 69 + eval "$code" 70 + fi 71 + } 72 + 73 + 74 + ###################################################################### 75 + # Error handling. 76 + 77 exitHandler() { 78 exitCode=$? 79 set +e ··· 116 117 118 ###################################################################### 119 + # Helper functions. 120 121 122 addToSearchPathWithCustomDelimiter() { ··· 135 } 136 137 138 + ensureDir() { 139 + echo "warning: ‘ensureDir’ is deprecated; use ‘mkdir’ instead" >&2 140 + local dir 141 + for dir in "$@"; do 142 + if ! [ -x "$dir" ]; then mkdir -p "$dir"; fi 143 + done 144 + } 145 + 146 + 147 + installBin() { 148 + mkdir -p $out/bin 149 + cp "$@" $out/bin 150 + } 151 152 153 + ###################################################################### 154 + # Initialisation. 155 156 157 # Wildcard expansions that don't match should expand to an empty list. ··· 162 163 # Set up the initial path. 164 PATH= 165 + for i in $initialPath; do 166 if [ "$i" = / ]; then i=; fi 167 addToSearchPath PATH $i/bin 168 addToSearchPath PATH $i/sbin ··· 173 fi 174 175 176 # Check that the pre-hook initialised SHELL. 177 if [ -z "$SHELL" ]; then echo "SHELL not set"; exit 1; fi 178 179 180 + # Execute the pre-hook. 181 + export CONFIG_SHELL="$SHELL" 182 + if [ -z "$shell" ]; then export shell=$SHELL; fi 183 184 185 # Allow the caller to augment buildInputs (it's not always possible to ··· 202 203 eval $var="'${!var} $pkg '" 204 205 + if [ -f $pkg ]; then 206 + source $pkg 207 + fi 208 + 209 if [ -f $pkg/nix-support/setup-hook ]; then 210 source $pkg/nix-support/setup-hook 211 fi ··· 230 231 # Set the relevant environment variables to point to the build inputs 232 # found above. 233 + _addToNativeEnv() { 234 local pkg=$1 235 236 if [ -d $1/bin ]; then ··· 238 fi 239 240 # Run the package-specific hooks set by the setup-hook scripts. 241 + runHook envHook "$pkg" 242 } 243 244 for i in $nativePkgs; do 245 + _addToNativeEnv $i 246 done 247 248 + _addToCrossEnv() { 249 local pkg=$1 250 251 # Some programs put important build scripts (freetype-config and similar) ··· 256 fi 257 258 # Run the package-specific hooks set by the setup-hook scripts. 259 + runHook crossEnvHook "$pkg" 260 } 261 262 for i in $crossPkgs; do 263 + _addToCrossEnv $i 264 done 265 266 ··· 321 export NIX_BUILD_CORES 322 323 324 + # Dummy implementation of the paxmark function. On Linux, this is 325 + # overwritten by paxctl's setup hook. 326 + paxmark() { true; } 327 328 329 ###################################################################### 330 # Textual substitution functions. 331 ··· 456 } 457 458 459 + unpackCmdHooks+=(_defaultUnpack) 460 + _defaultUnpack() { 461 + local fn="$1" 462 463 + if [ -d "$fn" ]; then 464 465 + stripHash "$fn" 466 + cp -prd --no-preserve=timestamps "$fn" $strippedName 467 + 468 + else 469 470 + case "$fn" in 471 + *.tar.xz | *.tar.lzma) 472 + # Don't rely on tar knowing about .xz. 473 + xz -d < "$fn" | tar xf - 474 + ;; 475 + *.tar | *.tar.* | *.tgz | *.tbz2) 476 + # GNU tar can automatically select the decompression method 477 + # (info "(tar) gzip"). 478 + tar xf "$fn" 479 + ;; 480 + *) 481 + return 1 482 + ;; 483 + esac 484 + 485 + fi 486 + } 487 + 488 + 489 + unpackFile() { 490 + curSrc="$1" 491 + header "unpacking source archive $curSrc" 3 492 + if ! runOneHook unpackCmd "$curSrc"; then 493 + echo "do not know how to unpack source archive $curSrc" 494 + exit 1 495 + fi 496 stopNest 497 } 498 ··· 526 527 # Find the source directory. 528 if [ -n "$setSourceRoot" ]; then 529 + runOneHook setSourceRoot 530 elif [ -z "$sourceRoot" ]; then 531 sourceRoot= 532 for i in *; do ··· 675 } 676 677 678 installPhase() { 679 runHook preInstall 680 ··· 690 } 691 692 693 + # The fixup phase performs generic, package-independent stuff, like 694 + # stripping binaries, running patchelf and setting 695 + # propagated-build-inputs. 696 fixupPhase() { 697 # Make sure everything is writable so "strip" et al. work. 698 + for output in $outputs; do 699 + if [ -e "${!output}" ]; then chmod -R u+w "${!output}"; fi 700 + done 701 702 + runHook preFixup 703 704 + # Apply fixup to each output. 705 + local output 706 + for output in $outputs; do 707 + prefix=${!output} runHook fixupOutput 708 + done 709 710 if [ -n "$propagatedBuildInputs" ]; then 711 mkdir -p "$out/nix-support" ··· 830 831 832 # Execute the post-hooks. 833 runHook postHook 834 835
+8 -14
pkgs/stdenv/linux/default.nix
··· 7 # The function defaults are for easy testing. 8 { system ? builtins.currentSystem 9 , allPackages ? import ../../top-level/all-packages.nix 10 - , platform ? null, config ? {} }: 11 12 rec { 13 - 14 - lib = import ../../../lib; 15 16 bootstrapFiles = 17 if system == "i686-linux" then import ./bootstrap/i686.nix ··· 26 commonPreHook = 27 '' 28 export NIX_ENFORCE_PURITY=1 29 - havePatchELF=1 30 ${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""} 31 ${if system == "mips64el-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""} 32 ''; ··· 209 extraAttrs = { 210 glibc = stage2.pkgs.glibc; # Required by gcc47 build 211 }; 212 - extraPath = [ stage2.pkgs.paxctl ]; 213 }; 214 215 ··· 223 coreutils = bootstrapTools; 224 name = ""; 225 }; 226 - extraPath = [ stage3.pkgs.xz ]; 227 overrides = pkgs: { 228 - # Zlib has to be inherited and not rebuilt in this stage, 229 - # because gcc (since JAR support) already depends on zlib, and 230 - # then if we already have a zlib we want to use that for the 231 - # other purposes (binutils and top-level pkgs) too. 232 - inherit (stage3.pkgs) gettext gnum4 gmp perl glibc zlib; 233 }; 234 }; 235 ··· 253 ''; 254 255 initialPath = 256 - ((import ../common-path.nix) {pkgs = stage4.pkgs;}) 257 - ++ [stage4.pkgs.patchelf stage4.pkgs.paxctl ]; 258 259 shell = stage4.pkgs.bash + "/bin/bash"; 260 ··· 278 inherit (stage4.pkgs) 279 gzip bzip2 xz bash binutils coreutils diffutils findutils gawk 280 glibc gnumake gnused gnutar gnugrep gnupatch patchelf 281 - attr acl paxctl zlib; 282 }; 283 }; 284
··· 7 # The function defaults are for easy testing. 8 { system ? builtins.currentSystem 9 , allPackages ? import ../../top-level/all-packages.nix 10 + , platform ? null, config ? {}, lib }: 11 12 rec { 13 14 bootstrapFiles = 15 if system == "i686-linux" then import ./bootstrap/i686.nix ··· 24 commonPreHook = 25 '' 26 export NIX_ENFORCE_PURITY=1 27 ${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""} 28 ${if system == "mips64el-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""} 29 ''; ··· 206 extraAttrs = { 207 glibc = stage2.pkgs.glibc; # Required by gcc47 build 208 }; 209 + extraPath = [ stage2.pkgs.patchelf stage2.pkgs.paxctl ]; 210 }; 211 212 ··· 220 coreutils = bootstrapTools; 221 name = ""; 222 }; 223 + extraPath = [ stage2.pkgs.patchelf stage3.pkgs.xz ]; 224 overrides = pkgs: { 225 + inherit (stage3.pkgs) gettext gnum4 gmp perl glibc; 226 }; 227 }; 228 ··· 246 ''; 247 248 initialPath = 249 + ((import ../common-path.nix) {pkgs = stage4.pkgs;}); 250 + 251 + extraBuildInputs = [ stage4.pkgs.patchelf stage4.pkgs.paxctl ]; 252 253 shell = stage4.pkgs.bash + "/bin/bash"; 254 ··· 272 inherit (stage4.pkgs) 273 gzip bzip2 xz bash binutils coreutils diffutils findutils gawk 274 glibc gnumake gnused gnutar gnugrep gnupatch patchelf 275 + attr acl paxctl; 276 }; 277 }; 278
+3 -3
pkgs/stdenv/nix/default.nix
··· 1 - { stdenv, pkgs, config }: 2 3 import ../generic rec { 4 inherit config; ··· 7 '' 8 export NIX_ENFORCE_PURITY=1 9 export NIX_IGNORE_LD_THROUGH_GCC=1 10 - '' + (if stdenv.isDarwin then '' 11 export NIX_ENFORCE_PURITY= 12 export NIX_DONT_SET_RPATH=1 13 export NIX_NO_SELF_RPATH=1 ··· 18 export SDKROOT=$(/usr/bin/xcrun --show-sdk-path 2> /dev/null || true) 19 export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT/usr/include -F$SDKROOT/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations" 20 export NIX_LDFLAGS_AFTER+=" -L$SDKROOT/usr/lib" 21 - '' else ""); 22 23 initialPath = (import ../common-path.nix) {pkgs = pkgs;}; 24
··· 1 + { stdenv, pkgs, config, lib }: 2 3 import ../generic rec { 4 inherit config; ··· 7 '' 8 export NIX_ENFORCE_PURITY=1 9 export NIX_IGNORE_LD_THROUGH_GCC=1 10 + '' + lib.optionalString stdenv.isDarwin '' 11 export NIX_ENFORCE_PURITY= 12 export NIX_DONT_SET_RPATH=1 13 export NIX_NO_SELF_RPATH=1 ··· 18 export SDKROOT=$(/usr/bin/xcrun --show-sdk-path 2> /dev/null || true) 19 export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT/usr/include -F$SDKROOT/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations" 20 export NIX_LDFLAGS_AFTER+=" -L$SDKROOT/usr/lib" 21 + ''; 22 23 initialPath = (import ../common-path.nix) {pkgs = pkgs;}; 24
+12 -12
pkgs/tools/archivers/unzip/default.nix
··· 1 { stdenv, fetchurl, bzip2 2 , enableNLS ? false, libnatspec }: 3 4 - stdenv.mkDerivation ({ 5 name = "unzip-6.0"; 6 - 7 src = fetchurl { 8 url = mirror://sourceforge/infozip/unzip60.tar.gz; 9 sha256 = "0dxx11knh3nk95p2gg2ak777dd11pr7jx5das2g49l262scrcv83"; 10 }; 11 12 nativeBuildInputs = [ bzip2 ]; 13 buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec; ··· 24 25 installFlags = "prefix=$(out)"; 26 27 meta = { 28 homepage = http://www.info-zip.org; 29 description = "An extraction utility for archives compressed in .zip format"; 30 license = "free"; # http://www.info-zip.org/license.html 31 platforms = stdenv.lib.platforms.all; 32 }; 33 - } // (if enableNLS then { 34 - patches = 35 - [ ( fetchurl { 36 - url = 37 - "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1"; 38 - name = "unzip-6.0-natspec.patch"; 39 - sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1"; 40 - }) 41 - ]; 42 - } else {}))
··· 1 { stdenv, fetchurl, bzip2 2 , enableNLS ? false, libnatspec }: 3 4 + stdenv.mkDerivation { 5 name = "unzip-6.0"; 6 + 7 src = fetchurl { 8 url = mirror://sourceforge/infozip/unzip60.tar.gz; 9 sha256 = "0dxx11knh3nk95p2gg2ak777dd11pr7jx5das2g49l262scrcv83"; 10 }; 11 + 12 + patches = stdenv.lib.optional enableNLS 13 + (fetchurl { 14 + url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1"; 15 + name = "unzip-6.0-natspec.patch"; 16 + sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1"; 17 + }); 18 19 nativeBuildInputs = [ bzip2 ]; 20 buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec; ··· 31 32 installFlags = "prefix=$(out)"; 33 34 + setupHook = ./setup-hook.sh; 35 + 36 meta = { 37 homepage = http://www.info-zip.org; 38 description = "An extraction utility for archives compressed in .zip format"; 39 license = "free"; # http://www.info-zip.org/license.html 40 platforms = stdenv.lib.platforms.all; 41 }; 42 + }
+5
pkgs/tools/archivers/unzip/setup-hook.sh
···
··· 1 + unpackCmdHooks+=(_tryUnzip) 2 + _tryUnzip() { 3 + if ! [[ "foo.zip" =~ \.zip$ ]]; then return 1; fi 4 + unzip -qq "$curSrc" 5 + }
+1 -1
pkgs/tools/text/sgml/opensp/setup-hook.sh
··· 18 export ftp_proxy=http://nodtd.invalid/ 19 20 export SGML_CATALOG_FILES 21 - envHooks=(${envHooks[@]} addSGMLCatalogs) 22 fi
··· 18 export ftp_proxy=http://nodtd.invalid/ 19 20 export SGML_CATALOG_FILES 21 + envHooks+=(addSGMLCatalogs) 22 fi
+1 -1
pkgs/tools/typesetting/tex/tetex/setup-hook.sh
··· 4 fi 5 } 6 7 - envHooks=(${envHooks[@]} addTeXMFPath)
··· 4 fi 5 } 6 7 + envHooks+=(addTeXMFPath)
+1 -1
pkgs/tools/typesetting/tex/texlive/setup-hook.sh
··· 4 fi 5 } 6 7 - envHooks=(${envHooks[@]} addTeXMFPath)
··· 4 fi 5 } 6 7 + envHooks+=(addTeXMFPath)
+1 -1
pkgs/top-level/all-packages.nix
··· 205 206 207 allStdenvs = import ../stdenv { 208 - inherit system platform config; 209 allPackages = args: import ./all-packages.nix ({ inherit config system; } // args); 210 }; 211
··· 205 206 207 allStdenvs = import ../stdenv { 208 + inherit system platform config lib; 209 allPackages = args: import ./all-packages.nix ({ inherit config system; } // args); 210 }; 211