// plugins

Nix Plugin

Adapter plugin that formats Nix code via nixfmt-rs, a Rust port of nixfmt.

Formats .nix files.

This plugin is updated after upstream nixfmt and nixfmt-rs, so its output can lag behind the latest nixfmt. The plugin author recommends against using it for nixpkgs or other NixOS organization contributions.

Install and Setup

In your project's directory with a dprint.json file, run:

dprint add kachick/nix
# or install from npm
dprint add npm:@kachick/dprint-plugin-nix

This will update your config file to have an entry for the plugin. Then optionally specify a "nix" property to add configuration:

{
  "nix": {
    // nix config goes here
  },
  "plugins": [
    "https://plugins.dprint.dev/kachick/nix-x.x.x.wasm"
  ]
}

Configuration

See Configuration.

Formatting Nix Code Blocks in Markdown

Use the tags option of the Markdown plugin to format nix code blocks with this plugin:

{
  "markdown": {
    "tags": {
      "nix": "nix"
    }
  }
}