NixOS
NixOS is a Linux distribution that has the main focus on reproducibility. The entire system configuration is done with two main files:
/etc/nixos/configuration.nix
/etc/nixos/hardware-configuration.nix
Searching for options in the configuration file
First open the manual with man
command:
man configuration.nix
Then type a forward slash /
and a search term to search for options containing
that term:
/bluetooth
The example above shows all configuration settings containing the word “bluetooth”.
Installing packages
Packages can be searched at search.nixos.org.
List all the packages in the configuration.nix
file the following subsection:
environment.systemPackages = with pkgs; [
helix
firefox
spotify
]
Never use nix-env
; this destroys the entire philosophy of NixOS.
Rebuilding the system
After all configuration changes are made the system can implement these changes by executing the following command:
sudo nixos-rebuild switch
After running this command the system is updated and the new configuration settings are set (this includes installing new packages).
Cleaning up older versions
Every time the system gets rebuilt, a new version gets added to the bootloader. This storage can accumulate over time. To remove old versions run the command:
sudo nix-collect-garbage --delete-older-than <time>
<time>
must be replaced with an actual time like15d
.