2.1 KiB
User packages
The Nix package manager is a package manager which allows for user independent packages and a whole lot more, although it is not necessarily minimal.
Setup
To set nix
up install its package and activate its service:
# apk add nix
# rc-update add nix-daemon default
# rc-service nix-daemon start
Do not forget to add your user to the nix group:
# adduser <username> nix
Channels
For nix
to be able to install packages it is necessary to add a few channels/repositories in ~/.nix-channels
:
https://nixos.org/channels/nixos-<version> nixpkgs
https://nixos.org/channels/nixos-unstable nixpkgs-unstable
https://github.com/nix-community/nixGL/archive/main.tar.gz nixgl
and replace the version
with the latest version of nix
. Then perform
$ nix-channel --update
Home manager
Nix can be used to manage your $HOME
with home-manager
. First install home-manager
through:
$ nix-env -iA nixpkgs.home-manager
Now that Nix is up and running utilize the home.nix
that comes with the config files to set up your home. But before initialising nix
make sure that you set the correct <username>
in home.nix
which is located in ~/.config/home-manager
. Then after changing that simply run this command:
$ home-manager switch
Thanks to home-manager
we can easily set up and manage an entire graphical environment with all the necessary packages in one go.
You are now also able to install packages as a user without root from nixpkgs
:
$ nix-env -iA nixpkgs.<package>
But for reproducibility it is better to use home-manager
by declaring them in a .nix
file and importing that within home.nix
.
You can also test a package before installing it with nix-shell -p <program>
.
NixGL
The nixGL
channel is necessary to be able to run graphical programs and sessions which are installed through nix
. It should have been installed with home-manager
.
Some applications might need Vulkan in which case the program has to be prefixed with:
$ nixVulkanIntel <program>