New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lock file #2864
Fix lock file #2864
Conversation
lockfile updating
If DontUpdate but the lockfile isn't correct
src/libexpr/primops/flake.cc
Outdated
// Hack: Make sure that flake.lock is visible to Git, so it ends up in the Nix store. | ||
runProgram("git", true, { "-C", refData->path, "add", | ||
(topRef.subdir == "" ? "" : topRef.subdir + "/") + "flake.lock" }); | ||
else std::cout << "Cannot write lockfile because the FlakeRef isn't of the form IsPath." << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't compile:
src/libexpr/primops/flake.cc: In function ‘nix::ResolvedFlake nix::resolveFlake(nix::EvalState&, const nix::FlakeRef&, nix::HandleLockFile)’:
src/libexpr/primops/flake.cc:470:9: error: expected ‘}’ before ‘else’
else std::cout << "Cannot write lockfile because the FlakeRef isn't of the form IsPath." << std::endl;
^~~~
src/libexpr/primops/flake.cc
Outdated
else if (handle == UseUpdatedLockFile) return false; | ||
else if (handle == RecreateLockFile) return true; | ||
else if (handle == UseNewLockFile) return false; | ||
else throw Error("There is a new HandleLockFile element!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to do assert(false)
here since this is an unreachable condition. (Maybe even static_assert(false)
but I'm not sure the compiler is smart enough to see it's unreachable.)
src/libexpr/primops/flake.hh
Outdated
}; | ||
|
||
typedef std::vector<std::shared_ptr<FlakeRegistry>> Registries; | ||
|
||
Path getUserRegistryPath(); | ||
|
||
enum RegistryAccess { DisallowRegistry, AllowRegistry, AllowRegistryAtTop }; | ||
enum HandleLockFile { AllPure, UpdateLockFile, UseUpdatedLockFile, RecreateLockFile, UseNewLockFile}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some comments explaining the semantics of each mode? It's not really clear from the name what the difference between UpdateLockFile
and UseUpdateLockFile
is, or between RecreateLockFile
and UseNewLockFile
.
Some confusing behaviour:
This gives the impression that it's an error, but the command actually succeeded. Something like It's also not clear why it would want to write a lockfile, given that |
The lockfile handling in flakes is now fixed:
nix build
without updating lockfile #2818