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

builtins.getFlake fails with "cannot write modified lock file" #6541

Closed
ncfavier opened this issue May 17, 2022 · 2 comments · Fixed by #6544
Closed

builtins.getFlake fails with "cannot write modified lock file" #6541

ncfavier opened this issue May 17, 2022 · 2 comments · Fixed by #6544
Labels

Comments

@ncfavier
Copy link
Member

Describe the bug

builtins.getFlake fails with "cannot write modified lock file" when using it on a repository without a lock file, e.g. home-manager, even when passing --no-write-lock-file.

Steps To Reproduce

$ echo 'builtins.getFlake "github:nix-community/home-manager"' > f.nix
$ nix eval --no-write-lock-file -f f.nix
error: cannot write modified lock file of flake 'github:nix-community/home-manager' (use '--no-write-lock-file' to ignore)
(use '--show-trace' to show detailed location information)

Expected behavior

No such error, i.e. don't attempt to write a lock file in builtins.getFlake.

nix-env --version output

nix (Nix) 2.9.0pre20220505_f4102de

Additional context

callFlake(state,
lockFlake(state, flakeRef,
LockFlags {
.updateLockFile = false,
.useRegistries = !evalSettings.pureEval && fetchSettings.useRegistries,
.allowMutable = !evalSettings.pureEval,
}),
v);

We should probably add .writeLockFile = false here? I'll PR that in a while if there's no response here.

@edolstra
Copy link
Member

We do have to make sure that pure evaluation continues to fail, e.g.

nix eval --json --expr 'builtins.getFlake "github:nix-community/home-manager/32a7da69dc53c9eb5ad0675eb7fdc58f7fe35272"'  

has to fail if there are unlocked inputs. I think this will fail before it even gets to writing the lock file though (e.g. error: cannot update flake input 'nixpkgs' in pure mode).

@ncfavier
Copy link
Member Author

Yes, the suggested fix doesn't change that

ncfavier added a commit to ncfavier/nix that referenced this issue May 18, 2022
ncfavier added a commit to ncfavier/nix that referenced this issue May 18, 2022
ncfavier added a commit to ncfavier/home-manager that referenced this issue May 21, 2022
Add a lockfile to work around NixOS/nix#6541
(and because it's a good idea anyway).

Also use flake-utils, and restrict ourselves to the five platforms
supported by nixpkgs. Otherwise, the IFD for nmd fails on weird
platforms. This fixes `nix flake check`.

Remove the redundant `apps` output, see nix-community#2442 (comment)
ncfavier added a commit to ncfavier/home-manager that referenced this issue Jun 5, 2022
Add a lockfile to work around NixOS/nix#6541
(and because it's a good idea anyway).

Also use flake-utils, and restrict ourselves to the five platforms
supported by nixpkgs. Otherwise, the IFD for nmd fails on weird
platforms. This fixes `nix flake check`.

Remove the redundant `apps` output, see nix-community#2442 (comment)
ncfavier added a commit to ncfavier/home-manager that referenced this issue Jun 7, 2022
Add a lockfile to work around NixOS/nix#6541
(and because it's a good idea anyway).

Also use flake-utils, and restrict ourselves to the five platforms
supported by nixpkgs. Otherwise, the IFD for nmd fails on weird
platforms. This fixes `nix flake check`.

Remove the redundant `apps` output, see nix-community#2442 (comment)
teto pushed a commit to nix-community/home-manager that referenced this issue Jun 7, 2022
* Add flake.lock and clean up flake.nix

Add a lockfile to work around NixOS/nix#6541
(and because it's a good idea anyway).

Also use flake-utils, and restrict ourselves to the five platforms
supported by nixpkgs. Otherwise, the IFD for nmd fails on weird
platforms. This fixes `nix flake check`.

Remove the redundant `apps` output, see #2442 (comment)

* nixos,nix-darwin: factor out into a common module

* nixos,nix-darwin: make `home-managers.users` shallowly visible

Make sure the option is included in the NixOS/nix-darwin manual (but the
HM submodule options aren't).

Also add a static description to the HM submodule type so that we don't need to
evaluate the submodules just to build the option manual. This makes
nixos-search able to index the home-manager flake.

Also clean up some TODOs.

* flake: add nmd and nmt

This avoids having to use `pkgs.fetchFromGitLab` in an IFD, which causes
issues when indexing packages with nixos-search because `pkgs` is
instantiated with every platform.
jevy pushed a commit to jevy/home-manager that referenced this issue Jul 1, 2022
* Add flake.lock and clean up flake.nix

Add a lockfile to work around NixOS/nix#6541
(and because it's a good idea anyway).

Also use flake-utils, and restrict ourselves to the five platforms
supported by nixpkgs. Otherwise, the IFD for nmd fails on weird
platforms. This fixes `nix flake check`.

Remove the redundant `apps` output, see nix-community#2442 (comment)

* nixos,nix-darwin: factor out into a common module

* nixos,nix-darwin: make `home-managers.users` shallowly visible

Make sure the option is included in the NixOS/nix-darwin manual (but the
HM submodule options aren't).

Also add a static description to the HM submodule type so that we don't need to
evaluate the submodules just to build the option manual. This makes
nixos-search able to index the home-manager flake.

Also clean up some TODOs.

* flake: add nmd and nmt

This avoids having to use `pkgs.fetchFromGitLab` in an IFD, which causes
issues when indexing packages with nixos-search because `pkgs` is
instantiated with every platform.
spacekookie pushed a commit to spacekookie/home-manager that referenced this issue Feb 10, 2023
* Add flake.lock and clean up flake.nix

Add a lockfile to work around NixOS/nix#6541
(and because it's a good idea anyway).

Also use flake-utils, and restrict ourselves to the five platforms
supported by nixpkgs. Otherwise, the IFD for nmd fails on weird
platforms. This fixes `nix flake check`.

Remove the redundant `apps` output, see nix-community#2442 (comment)

* nixos,nix-darwin: factor out into a common module

* nixos,nix-darwin: make `home-managers.users` shallowly visible

Make sure the option is included in the NixOS/nix-darwin manual (but the
HM submodule options aren't).

Also add a static description to the HM submodule type so that we don't need to
evaluate the submodules just to build the option manual. This makes
nixos-search able to index the home-manager flake.

Also clean up some TODOs.

* flake: add nmd and nmt

This avoids having to use `pkgs.fetchFromGitLab` in an IFD, which causes
issues when indexing packages with nixos-search because `pkgs` is
instantiated with every platform.
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 a pull request may close this issue.

2 participants