Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

NixOS

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

  1. A package that you add to either your environment.systemPackages or to your user’s packages
  2. A program, which is a package that also has extra configurations set. E.g., programs.git has different options that you can set to add extra functionality, such as PS1 and LFS
  3. A service creates 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 crash
  • nixos-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 generation
  • nixos-rebuild switch: Build a new configuration and activate it immediately. This also adds the new generation to your boot menu
  • nixos-rebuild dry-build: Show what would be built if you were to build this configuration
  • nixos-rebuild build: Build the configuration (including downloading all packages), but don’t switch to it or add it to the boot menu

  1. Always disable a service with the configuration (services.<name>.enable = false), not with systemctl disable) ↩