NixOS Commands

July 31, 2019 Linux 0 minutes, 42 seconds

Configuration

Activate your configuration but not reboot persistant

nixos-rebuild test

Activate your configuration not before reboot

nixos-rebuild boot

Activate your configuration and make it permanent

nixos-rebuild switch

List automatic tasks

systemctl list-timers

Updates/Upgrades

See subscribed channels

nix-channel --list | grep nixos

Switch channel

Channels are per user so switching a channel as user will not affect the main config!

nix-channel --add https://nixos.org/channels/channel-name nixos
# for example unstable channel
nix-channel --add https://nixos.org/channels/nixos-unstable nixos
nix-channel --update

Remove channel

nix-channel --remove CHANNEL_ALIAS

Upgrade

nixos-rebuild switch --upgrade

Access NixOS config options

nixos-option OPTION-SET
nixos-option services.sshd

Search package

nix-env -qaP '.*PACKAGE.*'

Show package description

nix-env -qa --description '.*PACKAGE.*'

Upgrade package(s)

nix-env -u PACKAGE
nix-env -u

(Un)Install package

nix-env -i PACKAGE
nix-env -e PACKAGE

Install package from source

nix-env -f https://github.com/NixOS/nixpkgs/archive/master.tar.gz -iA pkgs.NAME

Clean system

nix-collect-garbage -d # as root to clear system profile

Optimize store

nix-store --optimise