Very First Steps With Nix on Debian

Mixing Debian with Nix, my first steps.

O U T D A T E D

This information about Nix and Debian is out of date. Don't use this.

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.

(19 May 2022: In an earlier version of this blog, I had written" nix-channel update", without the hyphens. Thanks, Greg)

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.

Lastly, check if you're in the group nix-users. If not, as root

adduser $your_user_name_here nix-users

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