NixOS configuration editors: Difference between revisions

From NixOS Wiki
imported>Milahu
add section: Editing as normal user
imported>Milahu
add section: nixui by matejc
Line 39: Line 39:
* haskell + gtk desktop program
* haskell + gtk desktop program
* 150+ GitHub stars
* 150+ GitHub stars
* last commit: 2020


=== nixos-conf-editor by vlinkz ===
=== nixos-conf-editor by vlinkz ===
Line 48: Line 49:
* 50+ GitHub stars
* 50+ GitHub stars
* backend tool: https://github.com/vlinkz/nix-editor
* backend tool: https://github.com/vlinkz/nix-editor
=== nixui by matejc ===
* https://github.com/matejc/nixui
* https://blog.matejc.com/blogs/myblog/graphical-ui-for-nix
* 40+ GitHub stars
* last commit: 2015


=== Nixos-Gui by Celestialme ===
=== Nixos-Gui by Celestialme ===
Line 59: Line 67:


* 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://discourse.nixos.org/t/how-would-your-nixos-configuration-tool-look/1380
* https://www.reddit.com/r/nosyntax - structural editors
* https://www.reddit.com/r/nosyntax - structural editors
* [[Nixos-rebuild#Specifying a different configuration location]]
* [[Nixos-rebuild#Specifying a different configuration location]]
* https://discourse.nixos.org/t/use-vscode-editor-configuration-nix-cant-save/14119
* https://discourse.nixos.org/t/use-vscode-editor-configuration-nix-cant-save/14119

Revision as of 11:54, 31 August 2022

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 configuration.nix, 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 /etc/nixos/ 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:

mkdir ~/etc
sudo mv /etc/nixos ~/etc/
sudo chown -R $(id -un):users ~/etc/nixos
sudo ln -s ~/etc/nixos /etc/

Now you can run codium /etc/nixos to edit the config with VSCodium, and sudo nixos-rebuild switch to build the config.

It's also a good idea to track the config files with git, 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

nixos-manager by pmiddend

nixos-conf-editor by vlinkz

nixui by matejc

Nixos-Gui by Celestialme

See also