mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Make outputHashAlgo
accept "nar"
, stay in sync
Now that we have a few things identifying content address methods by name, we should be consistent about it. Move up the `parseHashAlgoOpt` for tidiness too. Discussed this change for consistency's sake as part of #8876 Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
parent
c313394ae9
commit
93d68e18e5
4 changed files with 24 additions and 11 deletions
|
@ -207,12 +207,17 @@ Derivations can declare some infrequently used optional attributes.
|
||||||
|
|
||||||
This is the default.
|
This is the default.
|
||||||
|
|
||||||
- `"recursive"`\
|
- `"recursive"` or `"nar"`\
|
||||||
The hash is computed over the NAR archive dump of the output
|
The hash is computed over the [NAR archive](@docroot@/glossary.md#gloss-nar) dump of the output
|
||||||
(i.e., the result of [`nix-store --dump`](@docroot@/command-ref/nix-store/dump.md)). In
|
(i.e., the result of [`nix-store --dump`](@docroot@/command-ref/nix-store/dump.md)). In
|
||||||
this case, the output can be anything, including a directory
|
this case, the output can be anything, including a directory
|
||||||
tree.
|
tree.
|
||||||
|
|
||||||
|
`"recursive"` is the traditional way of indicating this,
|
||||||
|
and is supported since 2005 (virtually the entire history of Nix).
|
||||||
|
`"nar"` is more clear, and consistent with other parts of Nix (such as the CLI),
|
||||||
|
however support for it is only added in Nix version 2.21.
|
||||||
|
|
||||||
- [`__contentAddressed`]{#adv-attr-__contentAddressed}
|
- [`__contentAddressed`]{#adv-attr-__contentAddressed}
|
||||||
> **Warning**
|
> **Warning**
|
||||||
> This attribute is part of an [experimental feature](@docroot@/contributing/experimental-features.md).
|
> This attribute is part of an [experimental feature](@docroot@/contributing/experimental-features.md).
|
||||||
|
|
|
@ -1139,18 +1139,20 @@ drvName, Bindings * attrs, Value & v)
|
||||||
vomit("processing attribute '%1%'", key);
|
vomit("processing attribute '%1%'", key);
|
||||||
|
|
||||||
auto handleHashMode = [&](const std::string_view s) {
|
auto handleHashMode = [&](const std::string_view s) {
|
||||||
if (s == "recursive") ingestionMethod = FileIngestionMethod::Recursive;
|
if (s == "recursive") {
|
||||||
else if (s == "flat") ingestionMethod = FileIngestionMethod::Flat;
|
// back compat, new name is "nar"
|
||||||
else if (s == "git") {
|
ingestionMethod = FileIngestionMethod::Recursive;
|
||||||
experimentalFeatureSettings.require(Xp::GitHashing);
|
} else try {
|
||||||
ingestionMethod = FileIngestionMethod::Git;
|
ingestionMethod = ContentAddressMethod::parse(s);
|
||||||
} else if (s == "text") {
|
} catch (UsageError &) {
|
||||||
experimentalFeatureSettings.require(Xp::DynamicDerivations);
|
|
||||||
ingestionMethod = TextIngestionMethod {};
|
|
||||||
} else
|
|
||||||
state.error<EvalError>(
|
state.error<EvalError>(
|
||||||
"invalid value '%s' for 'outputHashMode' attribute", s
|
"invalid value '%s' for 'outputHashMode' attribute", s
|
||||||
).atPos(v).debugThrow();
|
).atPos(v).debugThrow();
|
||||||
|
}
|
||||||
|
if (ingestionMethod == TextIngestionMethod {})
|
||||||
|
experimentalFeatureSettings.require(Xp::DynamicDerivations);
|
||||||
|
if (ingestionMethod == FileIngestionMethod::Git)
|
||||||
|
experimentalFeatureSettings.require(Xp::GitHashing);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto handleOutputs = [&](const Strings & ss) {
|
auto handleOutputs = [&](const Strings & ss) {
|
||||||
|
|
|
@ -64,4 +64,6 @@ rec {
|
||||||
(f2 "bar" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
(f2 "bar" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Can use "nar" instead of "recursive" now.
|
||||||
|
nar-not-recursive = f2 "foo" ./fixed.builder2.sh "nar" "md5" "3670af73070fa14077ad74e0f5ea4e42";
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,3 +61,7 @@ out3=$(nix-store --add-fixed --recursive sha256 $TEST_ROOT/fixed)
|
||||||
|
|
||||||
out4=$(nix-store --print-fixed-path --recursive sha256 "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik" fixed)
|
out4=$(nix-store --print-fixed-path --recursive sha256 "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik" fixed)
|
||||||
[ "$out" = "$out4" ]
|
[ "$out" = "$out4" ]
|
||||||
|
|
||||||
|
# Can use `outputHashMode = "nar";` instead of `"recursive"` now.
|
||||||
|
clearStore
|
||||||
|
nix-build fixed.nix -A nar-not-recursive --no-out-link
|
||||||
|
|
Loading…
Reference in a new issue