fix: Resolve symlink before FlakeRefFromEnv#107
fix: Resolve symlink before FlakeRefFromEnv#107water-sucks merged 1 commit intonix-community:mainfrom
Conversation
There was a problem hiding this comment.
Thanks for the PR! I was not aware of this issue.
This PR currently only does this for the generic FindConfiguration() function, which only resolves the issue for implicit configuration discovery.
However, many commands accept explicit command-line flake ref parameters, so this change may need to be applied to all those places, or the same problem may arise.
In our case, since this is flake-specific behavior, I think it would make sense to move this to internal/configuration/configuration.go, and only evaluate symlinks if the provided path exists on disk (i.e. verified with os.Stat()). I'm willing to hear alternative ways of implementing this though :}
f7a2a54 to
e65fb60
Compare
I believe you meant I’ve gone ahead and moved the symlink resolution logic to I’ve also tested cases like |
Currently, nixos-cli subcommands that execute the nix command under the hood
fail to find flake.nix inside symlinked directories (ex: ln -s ~/.config/nixos /etc; nixos apply -dv).
However, nixos-rebuild{,-ng} work fine in the same setup.
This change ensures that the path is resolved to the real directory
before being passed to FlakeRefFromEnv using filepath.EvalSymlinks,
allowing symlinked configuration directories to work transparently.
Signed-off-by: Maxim Mikhailov <darkness9724@gmail.com>
e65fb60 to
5ce7a86
Compare
water-sucks
left a comment
There was a problem hiding this comment.
Thanks for the contribution! Works during my own (rudimentary) testing as well.
Appreciate you for taking the time to address the requested changes too :}
At some point I want to take a crack at resolving symlinks in upstream Nix as well, since that can be useful for behavior for other systems, i.e. nix-darwin, but this will do for now.
Greetings!
Currently,
nixos-clisubcommands that execute thenixcommand under the hood fail to find flake.nix inside symlinked directories (for example,ln -s ~/.config/nixos /etc; nixos apply -dv). However,nixos-rebuild{,-ng}work fine in the same setup.This change ensures that the path is resolved to the real directory before being passed to
FlakeRefFromEnvusingfilepath.EvalSymlinks, allowing symlinked configuration directories to work transparently.