aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcmd/installables.cc34
-rw-r--r--src/libutil/experimental-features.cc1
-rw-r--r--src/libutil/experimental-features.hh1
-rw-r--r--src/nix/nix.md12
4 files changed, 48 insertions, 0 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index 74c8a6df5..483bc1421 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -431,6 +431,26 @@ struct InstallableStorePath : Installable
}
};
+struct InstallableIndexedStorePath : Installable
+{
+ ref<Store> store;
+ DerivedPath::Built req;
+
+ InstallableIndexedStorePath(ref<Store> store, DerivedPath::Built && req)
+ : store(store), req(std::move(req))
+ { }
+
+ std::string what() const override
+ {
+ return req.to_string(*store);
+ }
+
+ DerivedPaths toDerivedPaths() override
+ {
+ return { req };
+ }
+};
+
DerivedPaths InstallableValue::toDerivedPaths()
{
DerivedPaths res;
@@ -731,6 +751,20 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
for (auto & s : ss) {
std::exception_ptr ex;
+ if (s.rfind('!') != std::string::npos) {
+ try {
+ result.push_back(std::make_shared<InstallableIndexedStorePath>(
+ store,
+ DerivedPath::Built::parse(*store, s)));
+ settings.requireExperimentalFeature(Xp::ComputedDerivations);
+ continue;
+ } catch (BadStorePath &) {
+ } catch (...) {
+ if (!ex)
+ ex = std::current_exception();
+ }
+ }
+
if (s.find('/') != std::string::npos) {
try {
result.push_back(std::make_shared<InstallableStorePath>(store, store->followLinksToStorePath(s)));
diff --git a/src/libutil/experimental-features.cc b/src/libutil/experimental-features.cc
index e033a4116..c1e574c0d 100644
--- a/src/libutil/experimental-features.cc
+++ b/src/libutil/experimental-features.cc
@@ -13,6 +13,7 @@ std::map<ExperimentalFeature, std::string> stringifiedXpFeatures = {
{ Xp::RecursiveNix, "recursive-nix" },
{ Xp::NoUrlLiterals, "no-url-literals" },
{ Xp::FetchClosure, "fetch-closure" },
+ { Xp::ComputedDerivations, "computed-derivations" },
};
const std::optional<ExperimentalFeature> parseExperimentalFeature(const std::string_view & name)
diff --git a/src/libutil/experimental-features.hh b/src/libutil/experimental-features.hh
index 266e41a22..e6213bf86 100644
--- a/src/libutil/experimental-features.hh
+++ b/src/libutil/experimental-features.hh
@@ -22,6 +22,7 @@ enum struct ExperimentalFeature
RecursiveNix,
NoUrlLiterals,
FetchClosure,
+ ComputedDerivations, // RFC 92
};
/**
diff --git a/src/nix/nix.md b/src/nix/nix.md
index 0dacadee6..691aa137b 100644
--- a/src/nix/nix.md
+++ b/src/nix/nix.md
@@ -130,6 +130,18 @@ the Nix store. Here are the recognised types of installables:
If you want to operate on the store derivation itself, pass the
`--derivation` flag.
+* **Indexed store derivations**: `/nix/store/p7gp6lxdg32h4ka1q398wd9r2zkbbz2v-hello-2.10.drv!out`
+
+ *(Experimental, part of by the `computed-derivations` experimental feature.)*
+
+ Store derivations can be indexed with a specific output name. This
+ allows finer control versus just specifying a derivation (without
+ `--derivation`) and getting all the outputs.
+
+ This is especially useful for (currently unstable) floating content
+ addressed derivations, which do not have precomputed output paths that
+ can be used instead.
+
* **Nix attributes**: `--file /path/to/nixpkgs hello`
When the `-f` / `--file` *path* option is given, installables are