diff options
| author | Robert Hensing <robert@roberthensing.nl> | 2024-07-05 11:58:55 +0200 |
|---|---|---|
| committer | Robert Hensing <robert@roberthensing.nl> | 2024-07-28 23:17:18 +0200 |
| commit | 43df2b50f94cd7528fd1d20c552140aeeb3cbf21 (patch) | |
| tree | 0915978eda4da3bd0cf4d165956a0a560c2c0ac5 /pkgs/build-support/dev-shell-tools | |
| parent | Merge pull request #329250 from crimeminister/update-iroh-v0.21.0 (diff) | |
| download | nixpkgs-43df2b50f94cd7528fd1d20c552140aeeb3cbf21.tar.gz | |
devShellTools.{unstructuredDerivationInputEnv,derivationOutputEnv}: extract
Diffstat (limited to 'pkgs/build-support/dev-shell-tools')
| -rw-r--r-- | pkgs/build-support/dev-shell-tools/default.nix | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/pkgs/build-support/dev-shell-tools/default.nix b/pkgs/build-support/dev-shell-tools/default.nix index cd5fa5f5937e..87432b42f360 100644 --- a/pkgs/build-support/dev-shell-tools/default.nix +++ b/pkgs/build-support/dev-shell-tools/default.nix @@ -1,4 +1,7 @@ -{ lib }: +{ + lib, + writeText, +}: let inherit (builtins) typeOf; in @@ -13,4 +16,24 @@ rec { if typeOf value == "path" then "${value}" else if typeOf value == "list" then toString (map valueToString value) else toString value; + + + # https://github.com/NixOS/nix/blob/2.8.0/src/libstore/build/local-derivation-goal.cc#L992-L1004 + unstructuredDerivationInputEnv = { drvAttrs }: + # FIXME: this should be `normalAttrs // passAsFileAttrs` + lib.mapAttrs' + (name: value: + let str = valueToString value; + in if lib.elem name (drvAttrs.passAsFile or []) + then lib.nameValuePair "${name}Path" (writeText "pass-as-text-${name}" str) + else lib.nameValuePair name str + ) + drvAttrs; + + derivationOutputEnv = { outputList, outputMap }: + # A mapping from output name to the nix store path where they should end up + # https://github.com/NixOS/nix/blob/2.8.0/src/libexpr/primops.cc#L1253 + lib.genAttrs outputList (output: builtins.unsafeDiscardStringContext outputMap.${output}.outPath); + + } |
