NixOS
Useful links
Useful information
Configuration
There are 3 main types of packages that you can add to your configuration.nix file. When unsure which of the following three you should be using, check the Wiki to see if an article exists for the software you’re wanting to install. If not, check the Option search
- A package that you add to either your
environment.systemPackagesor to your user’s packages - A
program, which is a package that also has extra configurations set. E.g.,programs.githas different options that you can set to add extra functionality, such as PS1 and LFS - A
servicecreates a systemd service that will run in the background. You can usually set extra options, such as configuration changes, non-standard ports, enabling or disabling the service, etc1.
Commands
To make your configuration.nix changes take effect, you will use the nixos-rebuild command. There are several subcommands that you can make use of to change the effect of the command. Be sure to be in the /etc/nixos directory when running these commands
nixos-rebuild boot: Build a new configuration and make it the boot default, but don’t change your running system. This is great for large configuration changes or updates that could restart graphical programs or cause programs to crashnixos-rebuild test: Build a new configuration and activate it immediately, so your running system is using it, HOWEVER it will not add it to your boot menu. If anything breaks, simply reboot and you will go back to your previously working generationnixos-rebuild switch: Build a new configuration and activate it immediately. This also adds the new generation to your boot menunixos-rebuild dry-build: Show what would be built if you were to build this configurationnixos-rebuild build: Build the configuration (including downloading all packages), but don’t switch to it or add it to the boot menu
-
Always disable a service with the configuration (
services.<name>.enable = false), not withsystemctl disable) ↩