aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-05-21 13:46:19 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-05-21 13:46:19 +0200
commit818c8da5b88c5486026dd377b384e9121bb68de5 (patch)
treeedf2dfcbf924ebddc1e06302c6c20f310d313b58 /src/nix
parentb53169533161fc6e9a6b24acab18cb3e56d387f2 (diff)
parentef6ae61503bed7afa73a45ca6a4fb3597a9e514d (diff)
Merge branch 'fixLockFile' of https://github.com/CSVdB/nix into flakes
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/command.hh8
-rw-r--r--src/nix/flake.cc12
-rw-r--r--src/nix/installables.cc28
3 files changed, 31 insertions, 17 deletions
diff --git a/src/nix/command.hh b/src/nix/command.hh
index 640c6cd16..30d869b19 100644
--- a/src/nix/command.hh
+++ b/src/nix/command.hh
@@ -76,10 +76,14 @@ struct SourceExprCommand : virtual Args, StoreCommand, MixEvalArgs
{
std::optional<Path> file;
- bool updateLockFile = true;
-
SourceExprCommand();
+ bool recreateLockFile = false;
+
+ bool saveLockFile = true;
+
+ bool noRegistries = false;
+
ref<EvalState> getEvalState();
std::vector<std::shared_ptr<Installable>> parseInstallables(
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 0af368570..bfb3178ad 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -114,7 +114,7 @@ struct CmdFlakeDeps : FlakeCommand, MixJSON, StoreCommand, MixEvalArgs
FlakeRef flakeRef(flakeUri);
- ResolvedFlake resFlake = resolveFlake(*evalState, flakeRef, AllowRegistryAtTop);
+ ResolvedFlake resFlake = resolveFlake(*evalState, flakeRef, UpdateLockFile);
std::queue<ResolvedFlake> todo;
todo.push(resFlake);
@@ -126,13 +126,13 @@ struct CmdFlakeDeps : FlakeCommand, MixJSON, StoreCommand, MixEvalArgs
for (NonFlake & nonFlake : resFlake.nonFlakeDeps)
printNonFlakeInfo(nonFlake, json);
- for (ResolvedFlake & newResFlake : resFlake.flakeDeps)
- todo.push(newResFlake);
+ for (auto info : resFlake.flakeDeps)
+ todo.push(info.second);
}
}
};
-struct CmdFlakeUpdate : StoreCommand, GitRepoCommand, MixEvalArgs
+struct CmdFlakeUpdate : StoreCommand, FlakeCommand, MixEvalArgs
{
std::string name() override
{
@@ -148,8 +148,8 @@ struct CmdFlakeUpdate : StoreCommand, GitRepoCommand, MixEvalArgs
{
auto evalState = std::make_shared<EvalState>(searchPath, store);
- if (gitPath == "") gitPath = absPath(".");
- updateLockFile(*evalState, gitPath);
+ bool recreateLockFile = true;
+ updateLockFile(*evalState, flakeUri, recreateLockFile);
}
};
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
index db67952e1..a2a55d949 100644
--- a/src/nix/installables.cc
+++ b/src/nix/installables.cc
@@ -23,9 +23,19 @@ SourceExprCommand::SourceExprCommand()
.dest(&file);
mkFlag()
- .longName("no-update")
- .description("don't create/update flake lock files")
- .set(&updateLockFile, false);
+ .longName("recreate-lock-file")
+ .description("recreate lock file from scratch")
+ .set(&recreateLockFile, true);
+
+ mkFlag()
+ .longName("dont-save-lock-file")
+ .description("save the newly generated lock file")
+ .set(&saveLockFile, false);
+
+ mkFlag()
+ .longName("no-registries")
+ .description("don't use flake registries")
+ .set(&noRegistries, true);
}
ref<EvalState> SourceExprCommand::getEvalState()
@@ -157,13 +167,13 @@ struct InstallableFlake : InstallableValue
Value * toValue(EvalState & state) override
{
- auto path = std::get_if<FlakeRef::IsPath>(&flakeRef.data);
- if (cmd.updateLockFile && path) {
- updateLockFile(state, path->path);
- }
-
auto vFlake = state.allocValue();
- makeFlakeValue(state, flakeRef, AllowRegistryAtTop, *vFlake);
+
+ HandleLockFile handle = cmd.noRegistries ? AllPure :
+ cmd.recreateLockFile ?
+ (cmd.saveLockFile ? RecreateLockFile : UseNewLockFile)
+ : (cmd.saveLockFile ? UpdateLockFile : UseUpdatedLockFile);
+ makeFlakeValue(state, flakeRef, handle, *vFlake);
auto vProvides = (*vFlake->attrs->get(state.symbols.create("provides")))->value;