2024-07-08 12:58:52 +02:00
# User packages
2023-12-30 10:43:35 +01:00
2024-07-10 22:26:12 +02:00
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.
2023-12-30 10:43:35 +01:00
## Setup
2024-04-01 13:54:50 +02:00
To set `nix` up install its package and activate its service:
2023-12-30 10:43:35 +01:00
```
# apk add nix
# rc-update add nix-daemon default
# rc-service nix-daemon start
```
2024-07-10 22:26:12 +02:00
Do not forget to add your user to the nix group:
2023-12-30 10:43:35 +01:00
```
2023-12-30 21:23:24 +01:00
# adduser <username> nix
2023-12-30 10:43:35 +01:00
```
2024-03-25 11:07:52 +01:00
### Channels
2024-07-10 22:26:12 +02:00
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
2024-03-25 11:07:52 +01:00
```
$ nix-channel --update
```
2023-12-30 10:43:35 +01:00
2024-07-10 22:26:12 +02:00
## Home manager
2023-12-30 10:43:35 +01:00
2024-03-25 11:07:52 +01:00
Nix can be used to manage your `$HOME` with `home-manager` . First install `home-manager` through:
2023-12-30 10:43:35 +01:00
```
2024-04-01 13:54:50 +02:00
$ nix-env -iA nixpkgs.home-manager
2023-12-30 10:43:35 +01:00
```
2024-07-10 22:26:12 +02:00
Now that Nix is up and running utilize the `home.nix` that comes with the [config files ](https://docs.bijl.us/alpine-desktop-setup/post-install/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:
2023-12-30 21:23:24 +01:00
```
2024-03-25 11:07:52 +01:00
$ home-manager switch
2023-12-30 21:23:24 +01:00
```
2024-07-10 22:26:12 +02:00
Thanks to `home-manager` we can easily set up and manage an entire graphical environment with all the necessary packages in one go.
2023-12-30 21:23:24 +01:00
You are now also able to install packages as a user without root from `nixpkgs` :
2023-12-30 10:43:35 +01:00
```
$ nix-env -iA nixpkgs.< package >
```
2024-07-10 22:26:12 +02:00
But for reproducibility it is better to use `home-manager` by declaring them in a `.nix` file and importing that within `home.nix` .
2024-04-01 13:54:50 +02:00
2024-07-10 22:26:12 +02:00
You can also test a package before installing it with `nix-shell -p <program>` .
2023-12-30 21:23:24 +01:00
2024-03-25 11:07:52 +01:00
### NixGL
2024-07-10 22:26:12 +02:00
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` .
2024-05-10 21:42:37 +02:00
2024-07-10 22:26:12 +02:00
Some applications might need Vulkan in which case the program has to be prefixed with:
2023-12-30 10:43:35 +01:00
2023-12-30 21:23:24 +01:00
```
2024-05-10 21:42:37 +02:00
$ nixVulkanIntel < program >
2023-12-30 21:23:24 +01:00
```