diff options
author | EuAndreh <eu@euandre.org> | 2025-03-27 16:18:42 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-03-28 17:12:33 -0300 |
commit | 30d408c44ab0d7fb5901a27486354e833aa1ac64 (patch) | |
tree | bf26b1b01cbc549946e106f4596de6f58a254369 | |
parent | src/content/style.css: Update selectors for what mkwb(1) emits (diff) | |
download | euandre.org-30d408c44ab0d7fb5901a27486354e833aa1ac64.tar.gz euandre.org-30d408c44ab0d7fb5901a27486354e833aa1ac64.tar.xz |
src/content/blog/2018/07/17/guix-nixos.adoc: Update to asciidoc
-rw-r--r-- | src/content/blog/2018/07/17/guix-nixos.adoc | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/src/content/blog/2018/07/17/guix-nixos.adoc b/src/content/blog/2018/07/17/guix-nixos.adoc index 6005f9f..aa42e4b 100644 --- a/src/content/blog/2018/07/17/guix-nixos.adoc +++ b/src/content/blog/2018/07/17/guix-nixos.adoc @@ -1,30 +1,26 @@ ---- -title: Running Guix on NixOS -date: 2018-07-17 -layout: post -lang: en -ref: running-guix-on-nixos ---- -I wanted to run -Guix on a NixOS machine. Even though the Guix manual explains how to do it -[step by step][0], I needed a few extra ones to make it work properly. += Running Guix on NixOS -[0]: https://www.gnu.org/software/guix/manual/en/html_node/Binary-Installation.html#Binary-Installation +:install-step: https://www.gnu.org/software/guix/manual/en/html_node/Binary-Installation.html#Binary-Installation -I couldn't just install GuixSD because my wireless network card -doesn't have any free drivers (yet). +I wanted to run Guix on a NixOS machine. Even though the Guix manual explains +how to do it {install-step}[step by step], I needed a few extra ones to make it +work properly. -## Creating `guixbuilder` users +I couldn't just install GuixSD because my wireless network card doesn't have any +free drivers (yet). -Guix requires you to create non-root users that will be used to perform -the builds in the isolated environments. +== Creating `guixbuilder` users -The [manual][1] already provides you with a ready to run (as root) command for -creating the build users: +:manual: https://www.gnu.org/software/guix/manual/en/html_node/Build-Environment-Setup.html#Build-Environment-Setup -[1]: https://www.gnu.org/software/guix/manual/en/html_node/Build-Environment-Setup.html#Build-Environment-Setup +Guix requires you to create non-root users that will be used to perform the +builds in the isolated environments. -```bash +The {manual}[manual] already provides you with a ready to run (as root) command +for creating the build users: + +[source,bash] +---- groupadd --system guixbuild for i in `seq -w 1 10`; do @@ -33,15 +29,16 @@ do -c "Guix build user $i" --system \ guixbuilder$i; done -``` +---- -However, In my personal NixOS I have disabled [`users.mutableUsers`][2], which -means that even if I run the above command it means that they'll be removed once -I rebuild my OS: +:mutable-users: https://nixos.org/nixos/manual/index.html#sec-user-management -[2]: https://nixos.org/nixos/manual/index.html#sec-user-management +However, In my personal NixOS I have disabled +{mutable-users}[`users.mutableUsers`], which means that even if I run the above +command it means that they'll be removed once I rebuild my OS: -```shell +[source,shell] +---- $ sudo nixos-rebuild switch (...) removing user ‘guixbuilder7’ @@ -55,12 +52,13 @@ removing user ‘guixbuilder2’ removing user ‘guixbuilder8’ removing user ‘guixbuilder5’ (...) -``` +---- -Instead of enabling `users.mutableUsers` I could add the Guix users by -adding them to my system configuration: +Instead of enabling `users.mutableUsers` I could add the Guix users by adding +them to my system configuration: -```nix +[source,nix] +---- { config, pkgs, ...}: { @@ -101,26 +99,27 @@ adding them to my system configuration: }; }; } -``` +---- + +Here I used `fold` and the `//` operator to merge all of the configuration sets +into a single `extraUsers` value. -Here I used `fold` and the `//` operator to merge all of the -configuration sets into a single `extraUsers` value. +== Creating the `systemd` service -## Creating the `systemd` service +:service-file: https://git.savannah.gnu.org/cgit/guix.git/tree/etc/guix-daemon.service.in?id=00c86a888488b16ce30634d3a3a9d871ed6734a2 One other thing missing was the `systemd` service. -First I couldn't just copy the `.service` file to `/etc` since in NixOS -that folder isn't writable. But also I wanted the service to be better -integrated with the OS. +First I couldn't just copy the `.service` file to `/etc` since in NixOS that +folder isn't writable. But also I wanted the service to be better integrated +with the OS. That was a little easier than creating the users, all I had to do was translate -the provided [`guix-daemon.service.in`][3] configuration to an equivalent Nix -expression - -[3]: https://git.savannah.gnu.org/cgit/guix.git/tree/etc/guix-daemon.service.in?id=00c86a888488b16ce30634d3a3a9d871ed6734a2 +the provided {service-file}[`guix-daemon.service.in`] configuration to an +equivalent Nix expression: -```ini +[source,ini] +---- # This is a "service unit file" for the systemd init system to launch # 'guix-daemon'. Drop it in /etc/systemd/system or similar to have # 'guix-daemon' automatically started. @@ -142,11 +141,12 @@ TasksMax=8192 [Install] WantedBy=multi-user.target -``` +---- This sample `systemd` configuration file became: -```nix +[source,nix] +---- guix-daemon = { enable = true; description = "Build daemon for GNU Guix"; @@ -160,12 +160,13 @@ guix-daemon = { }; wantedBy = [ "multi-user.target" ]; }; -``` +---- -There you go! After running `sudo nixos-rebuild switch` I could get Guix -up and running: +There you go! After running `sudo nixos-rebuild switch` I could get Guix up and +running: -```bash +[source,bash] +---- $ guix package -i hello The following package will be installed: hello 2.10 /gnu/store/bihfrh609gkxb9dp7n96wlpigiv3krfy-hello-2.10 @@ -182,15 +183,15 @@ Creating manual page database... 2 packages in profile $ hello Hello, world! -``` +---- + +:nixos-modules: https://nixos.org/nixos/manual/index.html#sec-writing-modules +:req: https://www.gnu.org/software/guix/manual/en/html_node/Requirements.html#Requirements Some improvements to this approach are: -1. looking into [NixOS modules][4] and trying to bundle everything together - into a single logical unit; -2. [build Guix from source][5] and share the Nix store and daemon with Guix. +. looking into {nixos-modules}[NixOS modules] and trying to bundle everything + together into a single logical unit; +. {req}[build Guix from source] and share the Nix store and daemon with Guix. Happy Guix/Nix hacking! - -[4]: https://nixos.org/nixos/manual/index.html#sec-writing-modules -[5]: https://www.gnu.org/software/guix/manual/en/html_node/Requirements.html#Requirements |