diff --git a/content/rambles/nix-on-other-distros.md b/content/rambles/nix-on-other-distros.md new file mode 100644 index 0000000..8c290e9 --- /dev/null +++ b/content/rambles/nix-on-other-distros.md @@ -0,0 +1,86 @@ +--- +title: "Nix on Other Distros" +date: "2022-09-12T11:37:11+02:00" +author: "$HUMANOID" +tags: ["technology", "linux"] +description: "A guide on installing the Nix packagemanger on Alpine and Debian" +draft: false +--- + +# A Few Problems + +The Nix package manager is an amazing tool that allows you to manage your packages through a purely functional environment. +I'm not going to get into why it's amazing or how it really works in this article. +This is purely a guide to installing it in Alpine and Debian Linux. + +**"Why not use the official instructions?"** + +The official instructions require me to `curl` a script directly into `sh`. +From there it requires sudo privileges to install the package manager itself. +This sets of a load of alarm bells in terms of security and what it's going to do from there. +As the Nix package manager is packaged for both Debian and Alpine, my two favourite distros next to NixOS, there is no real reason _not_ to use their respective package managers. + +When you try to install Nix on Alpine you also get the warning that it only supports systemd and that you're on your own when it comes to getting it to work on any other init systems. +This problem is fixed in the Alpine pacakge. + +Then there is also the benefit of of being able to remove it with either `apt autoremove --purge nix-setup-systemd` or `apk del nix` instead of having to run said same script a second time. + +Yes, I'm aware that you don't _have_ to curl the script directly into `sh` and that you can download it to your local system to see what it's actually doing. +But that doesn't take away from the fact that the official instructions tell you to perform an inherently insecure set of actions by trusting what is effectively a random script on the internet. + +## Basics + +### Package Installation + +The first step is to install the package itself. +On Debian this is done with: + +```sh +sudo apt install nix +``` + +On Alpine, you first have to add the "testing" repo. +This is part of the `edge` branch. +As far as I know, you _could in theory_ get away with just adding the "testing" repo and not moving the rest of your system over to `edge`, but I highly doubt that will do any good for the stability of your system. + +Moving your system over to the `edge` branch is done by opening `/etc/apk/repositories`, uncommenting the mirrors referring `edge` in the and commting out the lines referring to (at time of writing) `3.16`. + +From there, run... +```sh +doas apk -U upgrade +``` +...to move your system over to `edge`. + +Now installing Nix can be done as usual with: +```sh +doas apk add nix +``` + +This will install the required binaries and the Nix daemon. + +### Starting the Daemon + +On Debian the Nix daemon is enabled by default. +To make sure it's running and enabled, run: +```sh +sudo systemctl status nix-daemon.service +``` + +If for whatever reason it's not started and/or enabled, run: +```sh +sudo systemctl enable --now nix-daemon.service +``` + +On Alpine, the daemon isn't added to any run level by default. +This is done using: +```sh +doas rc-update add nix-daemon +``` +Starting it is then done using: +```sh +doas rc-service nix-daemon start +``` + +### Groups + +Next step is to add your account to the correct group.