Skip to main content

Nix

Installation​

See instructions here.

Toolchain​

Formatting​

Use either one of these two formatters:

Linting​

Language Server Setup​

It is very wise to use nixd as the language server for Nix files together

Settings for nixd​

The following LSP settings will make autocomplete nixpkgs:

{
nixpkgs = {
expr = "import <nixpkgs> { }",
},
formatting = { command = "nixfmt" },
options = {
}
}

If you want to autocomplete also on your NixOS system add the following:

  options = {
nixos = {
expr = string.format(
'(builtins.getFlake "<path-to-your-flake>").nixosConfiguration.<your-system-name>',
p
),
},
}
info

These settings are LSP configuration settings which can be applied in any editor setup which supports LSPs (e.g. nvim, code).

Building​

Packaging​