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

Can't pass symlinks as flakerefs #5831

Open
anirudhb opened this issue Dec 25, 2021 · 4 comments
Open

Can't pass symlinks as flakerefs #5831

anirudhb opened this issue Dec 25, 2021 · 4 comments
Labels

Comments

@anirudhb
Copy link

Looks like this was changed in #5771, specifically here:
99d617b#diff-bf478d9714839229d3d706a7dcf96aebe2d6193e67cf06f06f440279a53ea36fL114-L116

Even if this was intended, it would be nice to have symlink flakerefs still working as CLI arguments (my config is a symlinked dir, and I haven't had issues building it until now.)

@anirudhb anirudhb added the bug label Dec 25, 2021
@virchau13
Copy link

I think the reason why this was changed was to forbid symlinks being used in flake inputs. (Does this break hermetic evaluation or something?) It would still be nice to use symlinks when directly invoking the Nix tools, though.

@alex-robbins
Copy link

I don't think changing when symlinks are allowed was an intentional effect of that change. It was to solve #5387 where absolute paths were sometimes not allowed (for reasons explained by this comment).

nixos-rebuild has the following in the man page for --flake, and it still works even when /etc/nixos is a symlink:

It defaults to the directory containing the target of the symlink /etc/nixos/flake.nix, if it exists.

So now, when /etc/nixos is a symlink, nixos-rebuild switch works but nixos-rebuild switch --flake /etc/nixos does not.

@SomeoneSerge
Copy link

Yup, just ran into this with /etc/nixos

@stale stale bot added the stale label Oct 30, 2022
@pinpox
Copy link
Member

pinpox commented Apr 7, 2024

Is there any way to make this work for flakes in other directories? I have my flake in a different directory and was using nixos-rebiuld switch --flake /path/to/mydir#myhost which is not possible if /path/to/mydir is replaced by a symlink.

My workaround is:

                                  --flake "$(readlink -f symlink-to-mydir)#myhost"

Which works, but is a bit hacky

@stale stale bot removed the stale label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants