Commit 238a6053 authored by Artturin's avatar Artturin
Browse files

stdenv: support opt-in __structuredAttrs



Co-authored-by: default avatarRobin Gloster <mail@glob.in>

stdenv: print message if structuredAttrs is enabled

stdenv: add _append

reduces the chance of a user doing it wrong

fix nix develop issue

output hooks don't work yet in nix develop though

making $outputs be the same on non-structuredAttrs and structuredAttrs
is too much trouble.

lets instead make a function that gets the output names

reading environment file '/nix/store/2x7m69a2sm2kh0r6v0q5s9z1dh41m4xf-xz-5.2.5-env-bin'
nix: src/nix/develop.cc:299: std::string Common::makeRcScript(nix::ref<nix::Store>, const BuildEnvironment&, const Path&): Assertion `outputs != buildEnvironment.vars.end()' failed.

use a function to get all output names instead of using $outputs

copy env functionality from https://github.com/NixOS/nixpkgs/pull/76732/commits
parent 3754f950
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ let
      mv bin/nomad-autoscaler $bin/bin
      ln -s $bin/bin/nomad-autoscaler $out/bin/nomad-autoscaler

      for d in $outputs; do
      for d in $(getAllOutputNames); do
        mkdir -p ''${!d}/share
      done
      rmdir $bin/share
+2 −2
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ let
  # The dynamic linker has different names on different platforms. This is a
  # shell glob that ought to match it.
  dynamicLinker =
    /**/ if sharedLibraryLoader == null then null
    /**/ if sharedLibraryLoader == null then ""
    else if targetPlatform.libc == "musl"             then "${sharedLibraryLoader}/lib/ld-musl-*"
    else if targetPlatform.libc == "uclibc"           then "${sharedLibraryLoader}/lib/ld*-uClibc.so.1"
    else if (targetPlatform.libc == "bionic" && targetPlatform.is32bit) then "/system/bin/linker"
@@ -87,7 +87,7 @@ let
    else if targetPlatform.isDarwin                   then "/usr/lib/dyld"
    else if targetPlatform.isFreeBSD                  then "/libexec/ld-elf.so.1"
    else if lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1"
    else null;
    else "";

  expand-response-params =
    if buildPackages ? stdenv && buildPackages.stdenv.hasCC && buildPackages.stdenv.cc != "/dev/null"
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ stdenv.mkDerivation (
      echo "$system" > $out/nix-support/system

      if [ -z "${toString doingAnalysis}" ]; then
          for i in $outputs; do
          for i in $(getAllOutputNames); do
              if [ "$i" = out ]; then j=none; else j="$i"; fi
              mkdir -p ''${!i}/nix-support
              echo "nix-build $j ''${!i}" >> ''${!i}/nix-support/hydra-build-products
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ autoPatchelf() {
# (Expressions don't expand in single quotes, use double quotes for that.)
postFixupHooks+=('
    if [ -z "${dontAutoPatchelf-}" ]; then
        autoPatchelf -- $(for output in $outputs; do
        autoPatchelf -- $(for output in $(getAllOutputNames); do
            [ -e "${!output}" ] || continue
            echo "${!output}"
        done)
+9 −3
Original line number Diff line number Diff line
@@ -5,10 +5,17 @@
preFixupHooks+=(_moveToShare)

_moveToShare() {
    forceShare=${forceShare:=man doc info}
    if [ -n "$__structuredAttrs" ]; then
        if [ -z "${forceShare-}" ]; then
            forceShare=( man doc info )
        fi
    else
        forceShare=( ${forceShare:-man doc info} )
    fi

    if [[ -z "$out" ]]; then return; fi

    for d in $forceShare; do
    for d in "${forceShare[@]}"; do
        if [ -d "$out/$d" ]; then
            if [ -d "$out/share/$d" ]; then
                echo "both $d/ and share/$d/ exist!"
@@ -20,4 +27,3 @@ _moveToShare() {
        fi
    done
}
Loading