@kachick/dprint-plugin-nix
v0.1.1
Published
dprint plugin for Nix formatting using nixfmt
Maintainers
Readme
dprint-plugin-nix
dprint WASM plugin for Nix using nixfmt-rs.
Installation
dprint add kachick/nixConfiguration
Empty works as default
{
"nix": {
}
}Customize if necessary
{
"nix": {
"lineWidth": 100,
"indentWidth": 2
}
}Tips
To format Nix code block in markdown, use tags option in official plugin.
dprint add markdown{
"markdown": {
"tags": {
"nix": "nix"
}
}
}Runs on nix fmt, Replace nixfmt-tree with dprint
{
formatter = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.writeShellScriptBin "dprint-fmt" ''
exec "${lib.getExe pkgs.dprint}" fmt "$@"
''
);
}Limitation
Because this plugin is updated after upstream nixfmt and nixfmt_rs, it will lag behind the latest upstream.
Please do not use it for nixpkgs or NixOS/ contributions, and use it only in personal repositories.
Motivation
- I prefer running formatters through dprint WASM plugins
nix fmtdoesn't have check option- nixfmt needs treefmt (nixfmt-tree) to target Nix files in directories
- Format Nix codeblock with the markdown plugin
