nixfmt
nixfmt copied to clipboard
Nixfmt does overwrite symlinks with reformatted contents
When I have a symlink and pass it to nixfmt
(eg because of using globbing from the shell as in nixfmt **/*.nix
) it gets overwritten by a regular file containing the formatted target.
nixfmt
should either ignore symlinks or write to the symlinks target, rather than overwriting the symlink.
$ readlink -f default.nix
/home/nmelzer/.config/nixpkgs/hosts/vbox-arch.nix
$ nixfmt default.nix
$ readlink -f default.nix
/home/nmelzer/.config/nixpkgs/hosts/default.nix
$ nixfmt --version
Format Nix source code
Sadly it seems as if in my version of nixfmt
#50 isn't fixed yet.
Thanks for reporting! I made a PR with a fix that should be merged soon. Unfortunately, our releases go through hackage and that can be kind of slow. If you don't want to wait for those, the README contains instruction for installing nixfmt from master.
As far as I see, the version fix should already be available in latest release, at least according to the GitHub interface, though it doesn't seem to be in nixpkgs
yet.
Though I might consider an installation from source, as in general the process behind updating something in nixpkgs seems to be quite slow.
Is there still someone working on this?