Skip to main content

From Nix to Guix

·617 words·3 mins
Technology Linux, NixOS, Guix
Xin
Author
Xin
Artist, Programmer, Expirementalist.
Table of Contents
Personal_Configuration - This article is part of a series.
Part : This Article

Intro

The post follows the conversion of my personal system configuration from NixOS to GNU Guix.

Foundational Knowledge: Guile Scheme

Despite having written a tremendous amount of lisp code at this point. I still lack a firm understanding of the principles that underpin Lisp code. Previous code has largely all been very basic configuration scripting. Or copied, and occasionally modified templates. Guix, while well documented. Seems to expect a higher level of familiarity with programming. So I decided to take a weekend, and go through a few starter resources. The goal is to be able to read, and comprehend what code does with the help of documentation.

All of the practice code for the following resources can be found HERE.

Resources

  • Spritely Institute: A Scheme Primer I started with this, and it acted as a really good test of my lisp / Guile tooling. I stopped when I got to the section on recursion, as that will be better covered by other resources. Overall a quick, and well written "taste" of Scheme style Lisp. Focused on interacting with the REPL.
  • Scheme Hackers Handbook This guide is much more focused on the practical aspects of using Guile. Focusing on setting up projects, testing, and major language features. Incidentally this is my first real exposure to "Test Driven Design", and at first pass I like it. It very much reminds me of Declarative programming. Which is always a good thing.

Getting Started with Guix

For this portion I am going to try and get a "minimum viable" system configuration set up in a virtual machine. This consists of adding the Non-Guix package channel, to support non-free firmware. Then installing Hyprland with Guix, before finally installing the Nix Package Manager inside of Guix to temporarily manage my most needed programs while I fully migrate my configuration.

;; Lines beginning with '$' are shell commands.

;; Print current channels list
$ guix describe

;; Create channels file
$ mkdir -p ~/.config/guix
$ touch ~/.config/guix/channels.scm

## Add to channels.scm
(cons* (channel
            (name 'nonguix)
              (url "https://gitlab.com/nonguix/nonguix")
              (introduction
               (make-channel-introduction
                "897c1a470da759236cc11798f4e0a5f7d4d59fbc"
                (openpgp-fingerprint
                 "2A39 3FFF 68F4 EF7A 3D29  12AF 6F51 20A0 22FB B2D5"))))
          (channel
            (name 'rosenthal)
              (url "https://codeberg.org/hako/rosenthal.git")
              (branch "trunk")
              (introduction
               (make-channel-introduction
                "7677db76330121a901604dfbad19077893865f35"
                (openpgp-fingerprint
                 "13E7 6CDa6 E649 C28C 3385  4DF5 5E5A A665 6149 17F7"))))
           %default-channels)

;; Update Guix Package List
$ guix pull

;; Confirm Channel Status
$ guix describe

;; Install standard Linux Kernel
$ nano /etc/config.scm

;; Change following lines
(use-modules (gnu))

>  (use-modules (gnu) (nongnu packages linux))

(operating-system
  (locale "en_US.utf8")
   .....)

> (operating-system
     (kernel linux)
     (firmware (list linux-firmware))
      (locale "en_US.utf8")
       .....)

$ guix pull
$ guix upgrade
$ sudo guix system reconfigure /etc/config.scm
$ reboot

;; Switch to Hyprland
$ nano /etc/configuration.scm

(use-modules (gnu))
(use-package-modules wm)

(operating-system
  ;; …
  (packages (append (list hyprland)
                    %base-packages)))

;; Install Single User Nix PKMG
$ guix install curl
$ $ bash <(curl -L https://nixos.org/nix/install) --daemon

Conclusions

So if you have made it this far, then this is probably going to be a bit of a twist. But, I didn't end up switching to Guix…

After getting the basic system installed. I started looking for packages, and the general consensus that I came to. Was that your are kind of expected to build and package anything other than the core utils yourself, and Guix has tooling to make this extremely easy. There is even a fairly large culture of sharing "personal" package repos… But ultimately, as someone who is still "getting started" with programming and has no experience packaging software. This was too big of a jump for me.

My plan now is to try Guix again after going through Linux From Scratch.

Personal_Configuration - This article is part of a series.
Part : This Article