formatting nixpkgs-fmt command exited with 65280,
When I try to format with Nix IDE, I get this message:
formatting nixpkgs-fmt command exited with 65280, error: 3
[Error - 11:56:39 AM] Request textDocument/formatting failed.
Message: formatting nixpkgs-fmt command exited with 65280
Code: -32001
I've tried other commands such as nixfmt and nixfmt-classic
My settings.json
"nix.enableLanguageServer": true,
"nix.serverPath": "nixd",
"nix.serverSettings": {
"nixd": {
"formatting": {
"command": [ "nixpkgs-fmt" ]
},
},
},
"nix.formatterPath": "nixpkgs-fmt",
and the packages in my /etc/nixosconfiguration.nix file
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
vscode
telegram-desktop
git
nixd
];
I had tried as well with nixfmt in my system packages and this did not work :( pls halp! NixOS newbie, so may be missing the obvious
A quick fix would be to add nixpkgs-fmt to the environment to use the older formatter.
In my case, I encountered the same error because nixd releases <= v2.3.1, which was in the unstable channel, effectively forces usage of nixpkgs-fmt if you have flakes in the nixd configuration. nixpkgs-fmt was recently archived so there are also some migration pains to nixfmt at the moment.
Until a new release is merged, those that want to use another formatter can either use nixd from source/flake with the nix fmt flake option:
outputs = inputs: {
formatter.x86_64-linux = inputs.nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
...
};
or the vscode-nix-ide configuration without flakes defined:
"nix.serverSettings": {
"nixd": {
"formatting": {
"command": ["nixfmt"]
}
}
},
Both options still require the formatter package in the environment, from my testing.
Thanks for the suggestions.
For me, putting pkgs.nixfmt-rfc-style instead of pkgs.nixpkgs-fmt in my packages, and having in my VSCode config:
"nixd": {
"formatting": {
"command": "nixfmt"
}
}
has the formatter working again.
Kindly check the same from terminal. If the issue persists, kindly reopen with the version number of nixpkgs-fmt to get more help.