aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-01-29 14:57:57 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-01-29 18:41:25 +0100
commitf68bed7f67d9acc13ebe38e6f5aa8a641f6e557d (patch)
tree1370862f1228da0d524c64eca129956691232762 /src/nix
parente53c89a64388ba2dc39f956c8f63620d28cc32af (diff)
Add flag --override-input to override specific lock file entries
E.g. $ nix flake update ~/Misc/eelco-configurations/hagbard \ --override-input 'dwarffs/nixpkgs' ../my-nixpkgs overrides the 'nixpkgs' input of the 'dwarffs' input of the top-level flake. Fixes #2837.
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/command.hh5
-rw-r--r--src/nix/flake.cc2
-rw-r--r--src/nix/installables.cc15
3 files changed, 17 insertions, 5 deletions
diff --git a/src/nix/command.hh b/src/nix/command.hh
index 08fa0c5fa..eb44caf05 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -4,6 +4,7 @@
#include "args.hh"
#include "common-eval-args.hh"
#include "path.hh"
+#include "flake/lockfile.hh"
#include <optional>
@@ -42,11 +43,11 @@ struct EvalCommand : virtual StoreCommand, MixEvalArgs
struct MixFlakeOptions : virtual Args
{
bool recreateLockFile = false;
-
bool saveLockFile = true;
-
bool useRegistries = true;
+ flake::LockFlags lockFlags;
+
MixFlakeOptions();
flake::LockFileMode getLockFileMode();
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index f7e329b49..2852a627d 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -43,7 +43,7 @@ public:
LockedFlake lockFlake()
{
- return flake::lockFlake(*getEvalState(), getFlakeRef(), getLockFileMode());
+ return flake::lockFlake(*getEvalState(), getFlakeRef(), getLockFileMode(), lockFlags);
}
};
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
index 8e4b53308..7d59a25ee 100644
--- a/src/nix/installables.cc
+++ b/src/nix/installables.cc
@@ -33,6 +33,17 @@ MixFlakeOptions::MixFlakeOptions()
.longName("no-registries")
.description("don't use flake registries")
.set(&useRegistries, false);
+
+ mkFlag()
+ .longName("override-input")
+ .description("override a specific flake input (e.g. 'dwarffs/nixpkgs')")
+ .arity(2)
+ .labels({"input-path", "flake-url"})
+ .handler([&](std::vector<std::string> ss) {
+ lockFlags.inputOverrides.insert_or_assign(
+ flake::parseInputPath(ss[0]),
+ parseFlakeRef(ss[1], absPath(".")));
+ });
}
flake::LockFileMode MixFlakeOptions::getLockFileMode()
@@ -321,7 +332,7 @@ std::tuple<std::string, FlakeRef, flake::EvalCache::Derivation> InstallableFlake
{
auto state = cmd.getEvalState();
- auto lockedFlake = lockFlake(*state, flakeRef, cmd.getLockFileMode());
+ auto lockedFlake = lockFlake(*state, flakeRef, cmd.getLockFileMode(), cmd.lockFlags);
Value * vOutputs = nullptr;
@@ -375,7 +386,7 @@ std::vector<flake::EvalCache::Derivation> InstallableFlake::toDerivations()
Value * InstallableFlake::toValue(EvalState & state)
{
- auto lockedFlake = lockFlake(state, flakeRef, cmd.getLockFileMode());
+ auto lockedFlake = lockFlake(state, flakeRef, cmd.getLockFileMode(), cmd.lockFlags);
auto vOutputs = getFlakeOutputs(state, lockedFlake);