devShellTools.unstructuredDerivationInputEnv: Match passAsFile basename
This commit is contained in:
parent
7237aa700f
commit
1cf3103bca
@ -1,6 +1,6 @@
|
||||
{
|
||||
lib,
|
||||
writeText,
|
||||
writeTextFile,
|
||||
}:
|
||||
let
|
||||
inherit (builtins) typeOf;
|
||||
@ -29,7 +29,21 @@ rec {
|
||||
(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}"
|
||||
then
|
||||
let
|
||||
nameHash = builtins.convertHash {
|
||||
hash = "sha256:" + builtins.hashString "sha256" name;
|
||||
toHashFormat = "nix32";
|
||||
};
|
||||
basename = ".attr-${nameHash}";
|
||||
in
|
||||
lib.nameValuePair "${name}Path" "${
|
||||
writeTextFile {
|
||||
name = "shell-passAsFile-${name}";
|
||||
text = str;
|
||||
destination = "/${basename}";
|
||||
}
|
||||
}/${basename}"
|
||||
else lib.nameValuePair name str
|
||||
)
|
||||
(removeAttrs drvAttrs [
|
||||
|
@ -143,9 +143,7 @@ in
|
||||
|
||||
diff $exampleBarPathString $barPath
|
||||
|
||||
# TODO nice to have, as `cp $barPath foo/` preserves the basename:
|
||||
# this is usually a mistake, so not that big a deal perhaps
|
||||
# [[ "$(basename $exampleBarPathString)" = "$(basename $barPath)" ]]
|
||||
[[ "$(basename $exampleBarPathString)" = "$(basename $barPath)" ]]
|
||||
)
|
||||
|
||||
''${args:+fail "args should not be set by Nix. We don't expect it to and unstructuredDerivationInputEnv removes it."}
|
||||
|
Loading…
Reference in New Issue
Block a user