diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-05-21 13:46:19 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-05-21 13:46:19 +0200 |
commit | 818c8da5b88c5486026dd377b384e9121bb68de5 (patch) | |
tree | edf2dfcbf924ebddc1e06302c6c20f310d313b58 /src/nix | |
parent | b53169533161fc6e9a6b24acab18cb3e56d387f2 (diff) | |
parent | ef6ae61503bed7afa73a45ca6a4fb3597a9e514d (diff) |
Merge branch 'fixLockFile' of https://github.com/CSVdB/nix into flakes
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/command.hh | 8 | ||||
-rw-r--r-- | src/nix/flake.cc | 12 | ||||
-rw-r--r-- | src/nix/installables.cc | 28 |
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; |