Skip to content
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

Merged
merged 3 commits into from May 21, 2019
Merged

Fix lock file #2864

merged 3 commits into from May 21, 2019

Conversation

CSVdB
Copy link
Contributor

@CSVdB CSVdB commented May 16, 2019

lockfile updating
If DontUpdate but the lockfile isn't correct
// 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;
Copy link
Member

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;
         ^~~~

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!");
Copy link
Member

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.)

};

typedef std::vector<std::shared_ptr<FlakeRegistry>> Registries;

Path getUserRegistryPath();

enum RegistryAccess { DisallowRegistry, AllowRegistry, AllowRegistryAtTop };
enum HandleLockFile { AllPure, UpdateLockFile, UseUpdatedLockFile, RecreateLockFile, UseNewLockFile};
Copy link
Member

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.

@edolstra
Copy link
Member

edolstra commented May 21, 2019

Some confusing behaviour:

$ nix build dwarffs:dwarffs
Cannot write lockfile because the FlakeRef isn't of the form IsPath.

This gives the impression that it's an error, but the command actually succeeded. Something like warning: cannot update lockfile of remote flake 'dwarffs:dwarffs' would be better. (It shouldn't refer to IsPath since that's an internal.)

It's also not clear why it would want to write a lockfile, given that dwarffs already contains a lockfile.

@edolstra edolstra merged commit ef6ae61 into NixOS:flakes May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants