Very first steps with Nix on Debian

27 Jun 2021 One-minute read

Mixing Debian with Nix, my first steps.

Why Nix?

Because Debian is currently frozen. Or, because $some_package is not (yet) available in Debian.

Installation.

To install, as root, do:

apt install nix nix-setup-systemd

then, as user:

nix-channel --add https://nixos.org/channels/nixpkgs-unstable
nix-channel update

followed by a package you wish to run from Nix. For example, Nyxt.

nix-env --install nyxt

To find this Nyxt and other applications you install via Nix, you should add the path to your shell. For example:

export PATH=$PATH:$HOME/.nix-profile/bin

If this works for you, add it to your .bashrc.

Errors

If you get

error: opening lock file ‘/nix/var/nix/profiles/per-user/root/profile.lock’: Permission denied

then rm ~/.nix-profile and try again. This is probably because you tried to use nix-env or nix-channel or something while root (source).

Maintenance

Three basic commands to keep your Nix packages up to date:

nix-channel --update nixpkgs
nix-env -u '*'
nix-collect-garbage -d