mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
fetchPypiLegacy: pass NETRC via impureEnvVars if inPureEval
Co-authored-by: Matthew Croughan <matt@croughan.sh>
This commit is contained in:
parent
2a9ab9c1e0
commit
482a26382f
@ -4,6 +4,20 @@
|
|||||||
lib,
|
lib,
|
||||||
python3,
|
python3,
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
optionalAttrs
|
||||||
|
fetchers
|
||||||
|
optional
|
||||||
|
inPureEvalMode
|
||||||
|
filter
|
||||||
|
head
|
||||||
|
concatStringsSep
|
||||||
|
escapeShellArg
|
||||||
|
;
|
||||||
|
|
||||||
|
impureEnvVars = fetchers.proxyImpureEnvVars ++ optional inPureEvalMode "NETRC";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
# package name
|
# package name
|
||||||
pname,
|
pname,
|
||||||
@ -19,10 +33,10 @@
|
|||||||
name ? null,
|
name ? null,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
urls' = urls ++ lib.optional (url != null) url;
|
urls' = urls ++ optional (url != null) url;
|
||||||
|
|
||||||
pathParts = lib.filter ({ prefix, path }: "NETRC" == prefix) builtins.nixPath;
|
pathParts = filter ({ prefix, path }: "NETRC" == prefix) builtins.nixPath;
|
||||||
netrc_file = if (pathParts != [ ]) then (lib.head pathParts).path else "";
|
netrc_file = if (pathParts != [ ]) then (head pathParts).path else "";
|
||||||
|
|
||||||
in
|
in
|
||||||
# Assert that we have at least one URL
|
# Assert that we have at least one URL
|
||||||
@ -31,18 +45,18 @@ runCommand file
|
|||||||
(
|
(
|
||||||
{
|
{
|
||||||
nativeBuildInputs = [ python3 ];
|
nativeBuildInputs = [ python3 ];
|
||||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
inherit impureEnvVars;
|
||||||
outputHashMode = "flat";
|
outputHashMode = "flat";
|
||||||
# if hash is empty select a default algo to let nix propose the actual hash.
|
# if hash is empty select a default algo to let nix propose the actual hash.
|
||||||
outputHashAlgo = if hash == "" then "sha256" else null;
|
outputHashAlgo = if hash == "" then "sha256" else null;
|
||||||
outputHash = hash;
|
outputHash = hash;
|
||||||
NETRC = netrc_file;
|
|
||||||
}
|
}
|
||||||
// (lib.optionalAttrs (name != null) { inherit name; })
|
// optionalAttrs (name != null) { inherit name; }
|
||||||
|
// optionalAttrs (!inPureEvalMode) { env.NETRC = netrc_file; }
|
||||||
)
|
)
|
||||||
''
|
''
|
||||||
python ${./fetch-legacy.py} ${
|
python ${./fetch-legacy.py} ${
|
||||||
lib.concatStringsSep " " (map (url: "--url ${lib.escapeShellArg url}") urls')
|
concatStringsSep " " (map (url: "--url ${escapeShellArg url}") urls')
|
||||||
} --pname ${pname} --filename ${file}
|
} --pname ${pname} --filename ${file}
|
||||||
mv ${file} $out
|
mv ${file} $out
|
||||||
''
|
''
|
||||||
|
Loading…
Reference in New Issue
Block a user