Closed aidalgol closed 4 hours ago
Try moving the imports
one level up. The issue is that the module is designed to be imported on the top-level instead of per system.
diff --git a/repro/flake.nix b/repro/flake.nix
index 3cc165a..114aceb 100644
--- a/repro/flake.nix
+++ b/repro/flake.nix
@@ -12,6 +12,11 @@
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" ];
+
+ imports = [
+ inputs.treefmt-nix.flakeModule
+ ];
+
perSystem =
{
config,
@@ -22,10 +27,6 @@
...
}:
{
- imports = [
- inputs.treefmt-nix.flakeModule
- ];
-
treefmt = {
projectRootFile = "flake.nix";
programs.nixfmt-rfc-style.enable = true;
Yep, that was the problem. Thanks!
Describe the bug
Trying to use
treefmt
viaflake-parts
produces an eval error.To Reproduce
Steps to reproduce the behavior:
Write the following
flake.nix
file.nix flake lock
nix fmt
(The full trace does not include any lines in
flake.nix
, so I have omitted it.)Expected behavior
nix fmt
to runtreefmt
.System information
"x86_64-linux"
Linux 6.6.63, NixOS, 25.05 (Warbler), 25.05.20241128.970e93b
yes
yes
nix-env (Lix, like Nix) 2.91.1 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/aidan/.config/nix/nix.conf:/home/aidan/.config/kdedefaults/nix/nix.conf:/nix/store/w4r255xy5az98q5im6m7yzx5536qa8dy-plasma-workspace-6.2.4/etc/xdg/nix/nix.conf:/nix/store/b06v1z7pgfdcv6iix1mja9ych2yp6zw3-kglobalacceld-6.2.4/etc/xdg/nix/nix.conf:/nix/store/pdgsrs8i0crldkl8n2cp9jx3h06rcnzc-baloo-6.8.0/etc/xdg/nix/nix.conf:/nix/store/w4r255xy5az98q5im6m7yzx5536qa8dy-plasma-workspace-6.2.4/etc/xdg/nix/nix.conf:/nix/store/b06v1z7pgfdcv6iix1mja9ych2yp6zw3-kglobalacceld-6.2.4/etc/xdg/nix/nix.conf:/nix/store/pdgsrs8i0crldkl8n2cp9jx3h06rcnzc-baloo-6.8.0/etc/xdg/nix/nix.conf:/home/aidan/.config/kdedefaults/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/aidan/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/aidan/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/aidan/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/icglv8lfkxzd7qkpxh3kawhnxbixg3mi-lix-2.91.1/share
/home/aidan/.nix-defexpr/channels/nixpkgs
Additional context
There is also a documentation bug here, #270, so I had to try working out how to use this from just the minimal example in the README.