NixOS configuration editors: Difference between revisions
imported>SuperSandro2000 m improve wording |
imported>Milahu add section: Editing as normal user |
||
Line 1: | Line 1: | ||
Creating graphical editors for NixOS configurations is hard because of the amount and complexity of options and the resulting possibilities. | Creating graphical editors for NixOS configurations is hard because of the amount and complexity of options and the resulting possibilities. | ||
== Text editors == | |||
== | To improve the editing experience of <code>configuration.nix</code>, it is recommend to use a text editor with syntax highlighting and language server (autocompletion, formatting, refactoring). | ||
See also: [[Editor Modes for Nix Files]] | |||
=== Editing as normal user === | |||
The configuration files in <code>/etc/nixos/</code> are owned by root, so for every "save" operation, the editor will ask for the sudo password. To avoid this, we can move the config files to a user's home folder: | |||
<pre> | |||
mkdir ~/etc | |||
sudo mv /etc/nixos ~/etc/ | |||
sudo chown -R $(id -un):users ~/etc/nixos | |||
sudo ln -s ~/etc/nixos /etc/ | |||
</pre> | |||
Now you can run <code>codium /etc/nixos</code> to edit the config with VSCodium, and <code>sudo nixos-rebuild switch</code> to build the config. | |||
It's also a good idea to track the config files with <code>git</code>, and to make backups. | |||
== Graphical editors == | |||
It is also possible to use a graphical config manager, which can't express all features of NixOS, but is simple to use. | |||
=== nix-gui by lapp0 === | === nix-gui by lapp0 === | ||
Line 40: | Line 60: | ||
* https://www.reddit.com/r/NixOS/comments/cu4dle/should_nix_have_a_gui/ | * https://www.reddit.com/r/NixOS/comments/cu4dle/should_nix_have_a_gui/ | ||
* https://www.reddit.com/r/nosyntax - structural editors | * https://www.reddit.com/r/nosyntax - structural editors | ||
* [[ | * [[Nixos-rebuild#Specifying a different configuration location]] | ||
* https://discourse.nixos.org/t/use-vscode-editor-configuration-nix-cant-save/14119 |