Running Guix on NixOS

Posted on July 17, 2018

I wanted to run Guix on a NixOS machine. Even though the Guix manual explains how to do it step by step, I needed a few extra ones to make it work properly.

I couldn’t just install GuixSD because my wireless network card doesn’t have any free/libre drivers (yet).

Creating guixbuilder users

Guix requires you to create non-root users that will be used to perform the builds in the isolated environments.

The manual already provides you with a ready to run (as root) command for creating the build users:

However, In my personal NixOS I have disabled users.mutableUsers, which means that even if I run the above command it means that they’ll be removed once I rebuild my OS:

$ sudo nixos-rebuild switch
(...)
removing user ‘guixbuilder7’
removing user ‘guixbuilder3’
removing user ‘guixbuilder10’
removing user ‘guixbuilder1’
removing user ‘guixbuilder6’
removing user ‘guixbuilder9’
removing user ‘guixbuilder4’
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:

Here I used fold and the // operator to merge all of the configuration sets into a single extraUsers value.

Creating the systemd service

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.

That was a little easier than creating the users, all I had to do was translate the provided guix-daemon.service.in configuration to an equivalent Nix expression

This sample systemd configuration file became:

There you go! After running sudo nixos-rebuild switch I could get Guix up and running:

Some improvements to this approach are:

  1. looking into NixOS modules and trying to bundle everything together into a single logical unit;
  2. build Guix from source and share the Nix store and daemon with Guix.

Happy Guix/Nix hacking!