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
This is kinda a specific issue that I'm having but I was hoping to use the nix fmt command to format my flake. The only problem is that my flake.nix file is not in the root directory of my project; instead it's nested in a nix/ directory, since I also want to include some non-nix stuff in this specific repository.
The language server is working fine, but when I save a Nix file, I get an error in the output:
[Error - 11:56:44 PM] Request textDocument/formatting failed.
Message: Failed to run formatter: Process exited with exit status: 1.
path '/home/matt/projects/devmattrick/infrastructure' does not contain a 'flake.nix', searching up
error: path '/home/matt/projects/devmattrick/infrastructure' is not part of a flake (neither it nor its parent directories contain a 'flake.nix' file)
The issue is that my flake.nix (and all other .nix files) are in the nix/ directory of this project. I don't know if this is possible but I think the desired behavior of this would be to run the formatter command relative to the .nix file I'm saving instead of the VSCode project root.
Thanks for the help!
EDIT: It seems like nix fmt also doesn't accept input from stdin. nix fmt might need to be special cased since it will format the entire flake on save, which would probably be undesirable. It doesn't look like there's an easy way to tell nix fmt to "only format this one file" from what I can tell from the documentation.
The text was updated successfully, but these errors were encountered:
I think, as you are using nil for your formatting, the issue is more appropriate for the nil repo. oxalica/nil#70 already exists there to track this issue. You can use "command": ["nix", "fmt", "--", "-"], if the formatter of the flake your editing supports stdin→stdout formatting when given - as its first positional argument (which is what the above "command" value is accomplishing). NixOS/nix#8063 defines this API so in the future all nix formatters for use with flakes should hopefully comply with it (if they don't already).
This is kinda a specific issue that I'm having but I was hoping to use the
nix fmt
command to format my flake. The only problem is that my flake.nix file is not in the root directory of my project; instead it's nested in anix/
directory, since I also want to include some non-nix stuff in this specific repository.I have my Nix IDE plugin set up like so:
The language server is working fine, but when I save a Nix file, I get an error in the output:
The issue is that my
flake.nix
(and all other.nix
files) are in thenix/
directory of this project. I don't know if this is possible but I think the desired behavior of this would be to run the formatter command relative to the.nix
file I'm saving instead of the VSCode project root.Thanks for the help!
EDIT: It seems like
nix fmt
also doesn't accept input from stdin.nix fmt
might need to be special cased since it will format the entire flake on save, which would probably be undesirable. It doesn't look like there's an easy way to tellnix fmt
to "only format this one file" from what I can tell from the documentation.The text was updated successfully, but these errors were encountered: