mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
Provide default values for outputHashAlgo and outputHashMode
This commit is contained in:
parent
a99af85a77
commit
7537097284
@ -991,8 +991,8 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
|
|||||||
bool contentAddressed = false;
|
bool contentAddressed = false;
|
||||||
bool isImpure = false;
|
bool isImpure = false;
|
||||||
std::optional<std::string> outputHash;
|
std::optional<std::string> outputHash;
|
||||||
std::string outputHashAlgo;
|
std::optional<std::string> outputHashAlgo;
|
||||||
auto ingestionMethod = FileIngestionMethod::Flat;
|
std::optional<FileIngestionMethod> ingestionMethod;
|
||||||
|
|
||||||
StringSet outputs;
|
StringSet outputs;
|
||||||
outputs.insert("out");
|
outputs.insert("out");
|
||||||
@ -1190,15 +1190,16 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
|
|||||||
.errPos = posDrvName
|
.errPos = posDrvName
|
||||||
});
|
});
|
||||||
|
|
||||||
std::optional<HashType> ht = parseHashTypeOpt(outputHashAlgo);
|
std::optional<HashType> ht = parseHashTypeOpt(outputHashAlgo.value_or("sha256"));
|
||||||
Hash h = newHashAllowEmpty(*outputHash, ht);
|
Hash h = newHashAllowEmpty(*outputHash, ht);
|
||||||
|
|
||||||
auto outPath = state.store->makeFixedOutputPath(ingestionMethod, h, drvName);
|
auto method = ingestionMethod.value_or(FileIngestionMethod::Flat);
|
||||||
|
auto outPath = state.store->makeFixedOutputPath(method, h, drvName);
|
||||||
drv.env["out"] = state.store->printStorePath(outPath);
|
drv.env["out"] = state.store->printStorePath(outPath);
|
||||||
drv.outputs.insert_or_assign("out",
|
drv.outputs.insert_or_assign("out",
|
||||||
DerivationOutput::CAFixed {
|
DerivationOutput::CAFixed {
|
||||||
.hash = FixedOutputHash {
|
.hash = FixedOutputHash {
|
||||||
.method = ingestionMethod,
|
.method = method,
|
||||||
.hash = std::move(h),
|
.hash = std::move(h),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -1211,19 +1212,21 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
|
|||||||
.errPos = posDrvName
|
.errPos = posDrvName
|
||||||
});
|
});
|
||||||
|
|
||||||
HashType ht = parseHashType(outputHashAlgo);
|
auto ht = parseHashType(outputHashAlgo.value_or("sha256"));
|
||||||
|
auto method = ingestionMethod.value_or(FileIngestionMethod::Recursive);
|
||||||
|
|
||||||
for (auto & i : outputs) {
|
for (auto & i : outputs) {
|
||||||
drv.env[i] = hashPlaceholder(i);
|
drv.env[i] = hashPlaceholder(i);
|
||||||
if (isImpure)
|
if (isImpure)
|
||||||
drv.outputs.insert_or_assign(i,
|
drv.outputs.insert_or_assign(i,
|
||||||
DerivationOutput::Impure {
|
DerivationOutput::Impure {
|
||||||
.method = ingestionMethod,
|
.method = method,
|
||||||
.hashType = ht,
|
.hashType = ht,
|
||||||
});
|
});
|
||||||
else
|
else
|
||||||
drv.outputs.insert_or_assign(i,
|
drv.outputs.insert_or_assign(i,
|
||||||
DerivationOutput::CAFloating {
|
DerivationOutput::CAFloating {
|
||||||
.method = ingestionMethod,
|
.method = method,
|
||||||
.hashType = ht,
|
.hashType = ht,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@ rec {
|
|||||||
printf $((x + 1)) > $TEST_ROOT/counter
|
printf $((x + 1)) > $TEST_ROOT/counter
|
||||||
'';
|
'';
|
||||||
__impure = true;
|
__impure = true;
|
||||||
outputHashAlgo = "sha256";
|
|
||||||
outputHashMode = "recursive";
|
|
||||||
impureEnvVars = [ "TEST_ROOT" ];
|
impureEnvVars = [ "TEST_ROOT" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -32,8 +30,6 @@ rec {
|
|||||||
ln -s $out $out/self
|
ln -s $out $out/self
|
||||||
'';
|
'';
|
||||||
__impure = true;
|
__impure = true;
|
||||||
outputHashAlgo = "sha256";
|
|
||||||
outputHashMode = "recursive";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# This is not allowed.
|
# This is not allowed.
|
||||||
@ -53,7 +49,6 @@ rec {
|
|||||||
x=$(< ${impureOnImpure}/n)
|
x=$(< ${impureOnImpure}/n)
|
||||||
printf ''${x:0:1} > $out
|
printf ''${x:0:1} > $out
|
||||||
'';
|
'';
|
||||||
outputHashAlgo = "sha256";
|
|
||||||
outputHashMode = "recursive";
|
outputHashMode = "recursive";
|
||||||
outputHash = "sha256-eBYxcgkuWuiqs4cKNgKwkb3vY/HR0vVsJnqe8itJGcQ=";
|
outputHash = "sha256-eBYxcgkuWuiqs4cKNgKwkb3vY/HR0vVsJnqe8itJGcQ=";
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user