mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
<nix/fetchurl.nix>: Restore support for "impure = true"
This commit is contained in:
parent
e37d502895
commit
bb63bd50e6
3 changed files with 9 additions and 5 deletions
|
@ -20,9 +20,8 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
|
||||||
if (!out)
|
if (!out)
|
||||||
throw Error("'builtin:fetchurl' requires an 'out' output");
|
throw Error("'builtin:fetchurl' requires an 'out' output");
|
||||||
|
|
||||||
auto dof = std::get_if<DerivationOutput::CAFixed>(&out->raw);
|
if (!(drv.type().isFixed() || drv.type().isImpure()))
|
||||||
if (!dof)
|
throw Error("'builtin:fetchurl' must be a fixed-output or impure derivation");
|
||||||
throw Error("'builtin:fetchurl' must be a fixed-output derivation");
|
|
||||||
|
|
||||||
auto getAttr = [&](const std::string & name) {
|
auto getAttr = [&](const std::string & name) {
|
||||||
auto i = drv.env.find(name);
|
auto i = drv.env.find(name);
|
||||||
|
@ -67,7 +66,8 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Try the hashed mirrors first. */
|
/* Try the hashed mirrors first. */
|
||||||
if (dof->ca.method.getFileIngestionMethod() == FileIngestionMethod::Flat)
|
auto dof = std::get_if<DerivationOutput::CAFixed>(&out->raw);
|
||||||
|
if (dof && dof->ca.method.getFileIngestionMethod() == FileIngestionMethod::Flat)
|
||||||
for (auto hashedMirror : settings.hashedMirrors.get())
|
for (auto hashedMirror : settings.hashedMirrors.get())
|
||||||
try {
|
try {
|
||||||
if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/';
|
if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/';
|
||||||
|
|
|
@ -83,4 +83,4 @@ test -L $outPath/symlink
|
||||||
requireDaemonNewerThan "2.20"
|
requireDaemonNewerThan "2.20"
|
||||||
expected=100
|
expected=100
|
||||||
if [[ -v NIX_DAEMON_PACKAGE ]]; then expected=1; fi # work around the daemon not returning a 100 status correctly
|
if [[ -v NIX_DAEMON_PACKAGE ]]; then expected=1; fi # work around the daemon not returning a 100 status correctly
|
||||||
expectStderr $expected nix-build --expr '{ url }: builtins.derivation { name = "nix-cache-info"; system = "x86_64-linux"; builder = "builtin:fetchurl"; inherit url; outputHashMode = "flat"; }' --argstr url file://$narxz 2>&1 | grep 'must be a fixed-output derivation'
|
expectStderr $expected nix-build --expr '{ url }: builtins.derivation { name = "nix-cache-info"; system = "x86_64-linux"; builder = "builtin:fetchurl"; inherit url; outputHashMode = "flat"; }' --argstr url file://$narxz 2>&1 | grep 'must be a fixed-output or impure derivation'
|
||||||
|
|
|
@ -63,3 +63,7 @@ path5=$(nix build -L --no-link --json --file ./impure-derivations.nix contentAdd
|
||||||
path6=$(nix build -L --no-link --json --file ./impure-derivations.nix inputAddressedAfterCA | jq -r .[].outputs.out)
|
path6=$(nix build -L --no-link --json --file ./impure-derivations.nix inputAddressedAfterCA | jq -r .[].outputs.out)
|
||||||
[[ $(< $path6) = X ]]
|
[[ $(< $path6) = X ]]
|
||||||
[[ $(< $TEST_ROOT/counter) = 5 ]]
|
[[ $(< $TEST_ROOT/counter) = 5 ]]
|
||||||
|
|
||||||
|
# Test nix/fetchurl.nix.
|
||||||
|
path7=$(nix build -L --no-link --print-out-paths --expr "import <nix/fetchurl.nix> { impure = true; url = file://$PWD/impure-derivations.sh; }")
|
||||||
|
cmp $path7 $PWD/impure-derivations.sh
|
||||||
|
|
Loading…
Reference in a new issue