Skip to content

Commit

Permalink
Stabilize discard-references
Browse files Browse the repository at this point in the history
It has been there for a few releases now (landed in 2.14.0), doesn't
seem to cause any major issue and is wanted in a few places
(NixOS#7087 (comment)).
  • Loading branch information
Théophane Hufschmitt committed May 12, 2023
1 parent f60b215 commit 0e51087
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 25 deletions.
10 changes: 0 additions & 10 deletions doc/manual/src/language/advanced-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,6 @@ Derivations can declare some infrequently used optional attributes.
```

- [`unsafeDiscardReferences`]{#adv-attr-unsafeDiscardReferences}\
> **Warning**
> This attribute is part of an [experimental feature](@docroot@/contributing/experimental-features.md).
>
> To use this attribute, you must enable the
> [`discard-references`](@docroot@/contributing/experimental-features.md#xp-feature-discard-references) experimental feature.
> For example, in [nix.conf](../command-ref/conf-file.md) you could add:
>
> ```
> extra-experimental-features = discard-references
> ```

When using [structured attributes](#adv-attr-structuredAttrs), the
attribute `unsafeDiscardReferences` is an attribute set with a boolean value for each output name.
Expand Down
5 changes: 5 additions & 0 deletions doc/manual/src/release-notes/rl-next.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Release X.Y (202?-??-??)

- The `discard-references` feature has been stabilized.
This means that the
[unsafeDiscardReferences](@docroot@/contributing/experimental-features.md#xp-feature-discard-references)
attribute is no longer guarded by an experimental flag and can be used
freely.
1 change: 0 additions & 1 deletion src/libstore/build/local-derivation-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,6 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
bool discardReferences = false;
if (auto structuredAttrs = parsedDrv->getStructuredAttrs()) {
if (auto udr = get(*structuredAttrs, "unsafeDiscardReferences")) {
experimentalFeatureSettings.require(Xp::DiscardReferences);
if (auto output = get(*udr, outputName)) {
if (!output->is_boolean())
throw Error("attribute 'unsafeDiscardReferences.\"%s\"' of derivation '%s' must be a Boolean", outputName, drvPath.to_string());
Expand Down
13 changes: 2 additions & 11 deletions src/libutil/experimental-features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct ExperimentalFeatureDetails
std::string_view description;
};

constexpr std::array<ExperimentalFeatureDetails, 13> xpFeatureDetails = {{
constexpr std::array<ExperimentalFeatureDetails, 12> xpFeatureDetails = {{
{
.tag = Xp::CaDerivations,
.name = "ca-derivations",
Expand Down Expand Up @@ -180,15 +180,6 @@ constexpr std::array<ExperimentalFeatureDetails, 13> xpFeatureDetails = {{
the [`use-cgroups`](#conf-use-cgroups) setting for details.
)",
},
{
.tag = Xp::DiscardReferences,
.name = "discard-references",
.description = R"(
Allow the use of the [`unsafeDiscardReferences`](@docroot@/language/advanced-attributes.html#adv-attr-unsafeDiscardReferences) attribute in derivations
that use [structured attributes](@docroot@/language/advanced-attributes.html#adv-attr-structuredAttrs). This disables scanning of outputs for
runtime dependencies.
)",
},
{
.tag = Xp::DaemonTrustOverride,
.name = "daemon-trust-override",
Expand Down Expand Up @@ -243,7 +234,7 @@ std::string_view showExperimentalFeature(const ExperimentalFeature tag)
return xpFeatureDetails[(size_t)tag].name;
}

nlohmann::json documentExperimentalFeatures()
nlohmann::json documentExperimentalFeatures()
{
StringMap res;
for (auto & xpFeature : xpFeatureDetails)
Expand Down
1 change: 0 additions & 1 deletion src/libutil/experimental-features.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ enum struct ExperimentalFeature
ReplFlake,
AutoAllocateUids,
Cgroups,
DiscardReferences,
DaemonTrustOverride,
DynamicDerivations,
};
Expand Down
6 changes: 4 additions & 2 deletions tests/check-refs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ nix-build -o $RESULT check-refs.nix -A test7
nix-build -o $RESULT check-refs.nix -A test10

if isDaemonNewer 2.12pre20230103; then
enableFeatures discard-references
restartDaemon
if ! isDaemonNewer 2.16.0; then
enableFeatures discard-references
restartDaemon
fi

# test11 should succeed.
test11=$(nix-build -o $RESULT check-refs.nix -A test11)
Expand Down

0 comments on commit 0e51087

Please sign in to comment.