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

nix build handles flake references differently depending on if they explicitly say "path:" #5510

Open
colemickens opened this issue Nov 6, 2021 · 1 comment

Comments

@colemickens
Copy link
Member

Describe the bug

see: NixOS/nixpkgs#144811

It seems that nix build FOO does different things when FOO is ~/some/path vs path:~/some/path.

This might also explain another issue I found long ago, with nixos-rebuild: NixOS/nixpkgs#101648

This bug strikes me as odd, why is the path parsing code not being handled the same at this point when it's been guessed or specified as a path?

@thufschmitt
Copy link
Member

I don’t know whether that’s the cause of your issues, but nix build /some/path will indeed resolve to git+file:///some/path if /some/path is a git repository, or path:/some/path otherwise. Which I think makes perfect sense, because people (well, me at least) will expect nix build . to work regardless of whether I’m in a git repo or not, and to play with git if I’m in a git repo.
And having a way to explicitly specify path:FOO is also very handy for the 1% cases where I need to force the use of a plain path even if the path is a git repository.

github-actions bot pushed a commit to NixOS/nixpkgs that referenced this issue Jan 8, 2022
The removed lines converted the flake path passed by the command line
from `/some/path` to `git+file:///some/path`.

This technically shouldn't cause any issues, however running
`nixos-rebuild switch` inside a directory `/nix/store` will cause the
switch to fail and leave a partially construct generation (see issue #144811
for details).

By itself this shouldn't be too much of an issue, however thanks to
another issue in `systemd-boot-builder.py` this can leave the system
in a broken state for those using `boot.loader.systemd-boot` (AFAIK the
default), where future `nixos-rebuild switch` will fail
(see issue #93694 for details).

The issue can be fixed by running
`nix-env -p /nix/var/nix/profiles/system --delete-generations old`,
however this makes newbies very confused and it is showing in our
support threads in Matrix and Discourse (see
https://discourse.nixos.org/t/need-help-on-failure-of-building-my-configuration/16842).

Keep in mind this is a workaround. The actual issue seems to be in nix
itself (see: NixOS/nix#5510).

See also #150065 for an alternative fix that caused other issues.

Kudos for @figsoda for figuring out this fix.

(cherry picked from commit c274d04)
@stale stale bot added the stale label Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants