NixOS layer
Table of ContentsClose
1. Description
This layer adds tools for better integration of Emacs in NixOS.
1.1. Features:
- Nix-mode using nix-mode
- Automatic formatting via nixfmt
- Auto-completion of NixOS Options using company-nixos-options
- Helm Lookup for NixOS Options helm-nixos-options
- WIP support for LSP backend using
rnix-lsp
2. Install
2.1. Layer
To use this configuration layer, add it to your ~/.spacemacs
. You will need to
add nixos
to the existing dotspacemacs-configuration-layers
list in this
file.
3. Configuration
3.1. Enabling LSP (Experimental)
To use the experimental LSP backend, set variable nix-backend
to lsp
in
your ~./spacemacs
. (You would also need to enable LSP layer).
(setq-default dotspacemacs-configuration-layers (nixos :variables nix-backend 'lsp))
To install rnix-lsp from nix
, run the following command in shell:
nix-env -i -f https://github.com/nix-community/rnix-lsp/archive/master.tar.gz
3.2. Format on save
To enable automatic formatting on save, set the layer variable
nixos-format-on-save
to t
:
(setq-default dotspacemacs-configuration-layers (nixos :variables nixos-format-on-save t))
3.3. Opt-out from auto-complete
On some systems, company-nixos-options
may be very slow. If this is the case,
see the section on disabling the disabling auto-complete for the nixos
layer.
4. Key bindings
4.1. NixOS Options
Key binding | Description |
---|---|
SPC h > |
Call helm-nixos-options |
SPC m = = |
Format buffer using nixfmt |
SPC m f |
Call nix-flake transient |