Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatting nixpkgs-fmt command exited with 65280, #412

Open
maribrowne opened this issue Aug 10, 2024 · 3 comments
Open

formatting nixpkgs-fmt command exited with 65280, #412

maribrowne opened this issue Aug 10, 2024 · 3 comments

Comments

@maribrowne
Copy link

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

Screenshot_20240810_111217
Screenshot_20240810_111242
Screenshot_20240810_120445

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
  ];

@maribrowne
Copy link
Author

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

@myned
Copy link

myned commented Aug 18, 2024

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.

@Ten0
Copy link

Ten0 commented Sep 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants