NixOS Commands

November 7, 2020 Linux 0 minutes, 42 seconds


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


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 nixos
# for example unstable channel
nix-channel --add nixos
nix-channel --update

Remove channel

nix-channel --remove CHANNEL_ALIAS


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 -iA pkgs.NAME

Clean system

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

Optimize store

nix-store --optimise