aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nix/build.cc15
-rw-r--r--src/nix/command.hh6
-rw-r--r--src/nix/installables.cc8
3 files changed, 22 insertions, 7 deletions
diff --git a/src/nix/build.cc b/src/nix/build.cc
index 5a3d9d31a..ef6b48969 100644
--- a/src/nix/build.cc
+++ b/src/nix/build.cc
@@ -10,7 +10,7 @@ struct CmdBuild : MixDryRun, InstallablesCommand
{
Path outLink = "result";
- bool updateLock = true;
+ bool update = true;
CmdBuild()
{
@@ -29,7 +29,7 @@ struct CmdBuild : MixDryRun, InstallablesCommand
mkFlag()
.longName("no-update")
.description("don't update the lock file")
- .set(&updateLock, false);
+ .set(&update, false);
}
std::string name() override
@@ -77,11 +77,12 @@ struct CmdBuild : MixDryRun, InstallablesCommand
}
}
- // FlakeUri flakeUri = "";
- // if(updateLock)
- // for (uint i = 0; i < installables.size(); i++)
- // // if (auto flakeUri = installableToFlakeUri)
- // updateLockFile(*evalState, flakeUri);
+ if (update)
+ for (auto installable : installables) {
+ auto flakeUri = installable->installableToFlakeUri();
+ if (flakeUri)
+ updateLockFile(*evalState, *flakeUri);
+ }
}
};
diff --git a/src/nix/command.hh b/src/nix/command.hh
index 56e1e6f34..a5ae56fb9 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -3,6 +3,7 @@
#include "args.hh"
#include "primops/flake.hh"
#include "common-eval-args.hh"
+#include <optional>
namespace nix {
@@ -66,6 +67,11 @@ struct Installable
Buildable toBuildable();
+ virtual std::optional<std::string> installableToFlakeUri()
+ {
+ return std::nullopt;
+ }
+
virtual Value * toValue(EvalState & state)
{
throw Error("argument '%s' cannot be evaluated", what());
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
index 13a68a797..fc2c34861 100644
--- a/src/nix/installables.cc
+++ b/src/nix/installables.cc
@@ -175,6 +175,14 @@ struct InstallableFlake : InstallableValue
state.forceValue(*v);
return v;
}
+
+ std::optional<std::string> installableToFlakeUri() override
+ {
+ if (std::get_if<FlakeRef::IsPath>(&flakeRef.data))
+ return flakeRef.to_string();
+ else
+ return std::nullopt;
+ }
};
// FIXME: extend