You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disclaimer: I'd like to report something that's probably not an important bug and an edge case for most projects, however, this worked pre < v2.0.0 and doesn't anymore hence it might be a good idea to put some note in the docs or a warning directly in the code.
Bug: Using absolute paths in projectRootFile seems to break passing arguments to some formatters, for example nixfmt, nixfmt-rfc-style
To Reproduce
Steps to reproduce the behavior:
Simple flakeModule in the following format
{config,inputs, ... }:
{imports=withinputs;[treefmt-nix.flakeModule];perSystem={pkgs, ... }:
{treefmt={package=pkgs.treefmt;flakeCheck=true;flakeFormatter=true;projectRootFile=config.flake-root+"/flake.nix";programs={deadnix.enable=true;# Find and remove unused code in .nix source filesstatix.enable=true;# Lints and suggestions for the nix programming languagenixfmt.enable=true;# An opinionated formatter for Nix};};};}
where
options.flake-root=lib.mkOption{type=lib.types.path;description='' Provides `config.flake-root` with the path to the flake root. '';default=../.;};
NOTE: The same thing happens even with directly specifying projectRootFile = ../. + "/flake.nix";
And running nix fmt produces errors like these
❯ nix fmt
...
nixfmt error:
nixfmt: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/age/secrets/secrets.nix: openFile: does not exist (No such file or directory)
....
and also tries to format stuff that should be ignored, such as
❯ nix fmt
....
WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.direnv/bin/nix-direnv-reload
WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.direnv/flake-profile-9f4ae1dfa18f64f9620b50ba3609c21d070f3a5f.rc
WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/config
WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/hooks/commit-msg
WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/hooks/pre-commit
WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/index
WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/objects/03/466bd59a39888b932526fb36ae2e42dfed6b2c
WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/objects/0c/fe02053860d76afe18757e9d0804a340d3e4b6
WARN format: no formatter for path: ome/tsandrini/ProjectBundle/tsandrini/tensorfiles/.git/objects/0f/866697204f521a6192754f6a5f11aa80f4508c
...
Expected behavior
Setting projectRootFile = "flake.nix"; fixes this and produces expected behaviour, however, since projectRootFile = config.flake-root + "/flake.nix"; worked in the previous versions, this can be confusing to some folk, especially when the error is part of pre-commit hooks or some CI workflow I initially assumed this was due to the nixfmt-rfc-style -> nixfmt renaming in nixpkgs and didn't suspect treefmt at first.
This is why adding a warning or a note in the documentation might be a good idea.
Describe the bug
Disclaimer: I'd like to report something that's probably not an important bug and an edge case for most projects, however, this worked pre <
v2.0.0
and doesn't anymore hence it might be a good idea to put some note in the docs or awarning
directly in the code.Bug: Using absolute paths in
projectRootFile
seems to break passing arguments to some formatters, for examplenixfmt
,nixfmt-rfc-style
To Reproduce
Steps to reproduce the behavior:
flakeModule
in the following formatprojectRootFile = ../. + "/flake.nix";
nix fmt
produces errors like theseExpected behavior
Setting
projectRootFile = "flake.nix";
fixes this and produces expected behaviour, however, sinceprojectRootFile = config.flake-root + "/flake.nix";
worked in the previous versions, this can be confusing to some folk, especially when the error is part ofpre-commit
hooks or some CI workflow I initially assumed this was due to thenixfmt-rfc-style -> nixfmt
renaming innixpkgs
and didn't suspecttreefmt
at first.This is why adding a
warning
or a note in the documentation might be a good idea.System information
where
$FLAKE
points to my personal configuration in which I discovered this after running an update.Additional context
The text was updated successfully, but these errors were encountered: