Nixos useful stuff

Managing system configurations

Managing nix channels

Nix channels are where packages are published, they are equivalent of the "releases" in other distributions.

The current stable channel can generally be found by going on nixos.org and looking for the "announcements" page, or by going on the channels directory and looking for the highest version number.

It is generally safe to switch between channels, with the exception that after switching to a newer channel which changes the database schema, it might then be impossible to roll back to a previous channel (which should not be needed anyway).

Freeing up disk space

Nixos does not delete old versions of packages that are used by previous system configurations: they are kept so that a rollback is always possible. This can make the disk usage go up quickly, so commands exist to delete old configurations and optimise disk usage if needed.

Update packages without using too much disk space

Putting all the above together, updating packages keeping only the current configuration as backup:

Testing packages

Any user can create a temporary shell with some additional packages installed by running nix-shell -p {packages}. The packages do not persist after the shell has been closed.

User management

See the Nixos manual.

In order to manage users in a declarative-only way:

users.users.alice = {
    isNormalUser = true;
    description = "Alice Foobar";
    extraGroups = [
        "wheel"
        "networkmanager"
    ];
    openssh.authorizedKeys.keys = [
        "ssh-dss AAAAB3Nza... alice@foobar"
    ];
    hashedPassword = "$6$DICyZPtOZcWUIULB$hOaPtCKeTJUxHeFDyBUI9nGeX5LCLAqvZOEtAZQTFbLuum5upMt10.9LtGmY01Fc7w.Wi2OFwA5YHyJJC18MM/";
};