languages/nix: change nixpkgs-fmt to nixfmt (rfc-style)

This commit is contained in:
Anthony Rodriguez 2024-09-26 16:56:27 +02:00
parent e80520ddf3
commit 68377e8db1
No known key found for this signature in database
GPG key ID: EE3BE97C040A86CE
2 changed files with 31 additions and 5 deletions

View file

@ -72,6 +72,15 @@ one type, you can simply change
- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*`
- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable`
### `nixpkgs-fmt` removed in favor of `nixfmt` {#sec-nixpkgs-fmt-deprecation}
`nixpkgs-fmt` has been archived for a while, and it's finally being removed in
favor of nixfmt (more information can be found
[here](https://github.com/nix-community/nixpkgs-fmt?tab=readme-ov-file#nixpkgs-fmt---nix-code-formatter-for-nixpkgs).
To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
`nixfmt`.
## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae):
@ -289,3 +298,4 @@ one type, you can simply change
[nezia1](https://github.com/nezia1):
- Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and Svelte. Enable them via [](#opt-vim.languages.ts.format.type), [](#opt-vim.languages.css.format.type) and [](#opt-vim.languages.svelte.format.type) respectively.
- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with [nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style).

View file

@ -5,6 +5,7 @@
...
}: let
inherit (builtins) attrNames;
inherit (lib) concatStringsSep;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
@ -62,10 +63,10 @@
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
},
''}
${optionalString (cfg.format.type == "nixpkgs-fmt")
${optionalString (cfg.format.type == "nixfmt")
''
formatting = {
command = {"${cfg.format.package}/bin/nixpkgs-fmt"},
command = {"${cfg.format.package}/bin/nixfmt"},
},
''}
},
@ -90,10 +91,19 @@
'';
};
nixpkgs-fmt = {
package = pkgs.nixpkgs-fmt;
# Never need to use null-ls for nixpkgs-fmt
nixfmt = {
package = pkgs.nixfmt-rfc-style;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.nixfmt.with({
command = "${cfg.format.package}/bin/nixfmt"
})
)
'';
};
nixpkgs-fmt = null; # removed
};
defaultDiagnosticsProvider = ["statix" "deadnix"];
@ -175,6 +185,12 @@ in {
config = mkIf cfg.enable (mkMerge [
{
assertions = [
{
assertion = cfg.format.type != "nixpkgs-fmt";
message = "nixpkgs-fmt has been archived upstream. Please use one of the following instead: ${concatStringsSep ", " (attrNames formats)}";
}
];
vim.pluginRC.nix = ''
vim.api.nvim_create_autocmd("FileType", {
pattern = "nix",