2021-02-10

GNU Guix System Installation with Static Networking

linux   guix   index

Guix logo

During Guix system installation, the manual option, I had to connect to my home network, where I use static IP addresses. I stumbled a bit to get it working, but in the end it was simple enough.

Here are some notes on the process. Assuming the interface name is eth0 and the static IP address is 192.168.1.12.

First, we need to stop the networking service, as it is interfering by assigning addresses and routes.

herd stop networking

Then, we can assign an IP address on our device, bring it up, and add a route for our default gateway.

ip addr add 192.168.1.12/24 dev eth0
ip link set dev eth0 up
ip route add default via 192.168.1.1

That’s it. One last thing would be to add the appropriate name servers in the installer’s /etc/resolv.conf.

nameserver 192.168.1.1

Static address for the installed system

The above was during installation, but how do we set up networking with a persistent static address in our config?

The “GNU Guix Reference Manual” defines this, and can be done as follows.

(static-networking-service
          "eth0" "192.168.1.12"
          #:netmask "255.255.255.0"
          #:gateway "192.168.1.1"
          #:name-servers '("192.168.1.1"))

Removing default services

In the manual they are adding the static networking service on %base-services which does not itself include networking.

On the other hand, if our services are based on %desktop-services, then it includes NetworkManager, so we need to remove that, otherwise guix system will complain about the existence of two networking tools.

(remove (lambda (service)
          (eq? (service-kind service) network-manager-service-type)
          %desktop-services))

The above removes only one service, NetworkManager. But, I had to remove multiple ones, and that can be achieved with the or procedure.

Static networking can most likely be setup in the config with NetworkManager as well, but I found this simpler for my first install.

Putting everything together, a services section, that includes just networking, looks something like this.

(services
 (cons*
  (static-networking-service "eth0" "192.168.1.12"
                             #:netmask "255.255.255.0"
                             #:gateway "192.168.1.1"
                             #:name-servers '("192.168.1.1"))
  (remove (lambda (service)
            (or 
             (eq? (service-kind service) network-manager-service-type)
             (eq? (service-kind service) avahi-service-type)))
          %desktop-services)))