The path to GNUrvana

System Configuration with Guix

Table of Contents


Guix supports the concept of channels which basically amount to Git repositories which contain Guix package definitions that can be installed on your machine. Aside from the %default-channels list, I also use the Nonguix channel to install packages that aren't included with Guix by default like the non-free Linux kernel.


  ;; NOTE: This file is generated from ~/.dotfiles/System.org.  Please see commentary there.

(list (channel
        (name 'channel-x)
        (url "file:///home/daviwil/Projects/Code/channel-x"))
        (name 'flat)
        (url "https://github.com/flatwhatson/guix-channel.git")
              "736A C00E 1254 378B A982  7AF6 9DBE 8265 81B6 4490"))))
      ;; (channel
      ;;   (name 'nonguix)
      ;;   (branch "add-sof-firmware")
      ;;   (url "file:///home/daviwil/Projects/Code/nonguix"))
        (name 'nonguix)
        (url "https://gitlab.com/nonguix/nonguix"))
        (name 'guix)
        (url "https://git.savannah.gnu.org/git/guix.git")
        ;; (commit
        ;;   "b1cabedd28b92324259875fc52ca5d52d411a026")
              "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))

  ;; (cons* (channel
  ;;         (name 'channel-x)
  ;;         ;; (url "https://github.com/daviwil/channel-x"))
  ;;         (url "file:///home/daviwil/Projects/Code/channel-x"))
  ;;        (channel
  ;;         (name 'flat)
  ;;         (url "https://github.com/flatwhatson/guix-channel.git")
  ;;         (commit
  ;;          "302f8a4f7e56cb3b484de9fe86617a3aaf20098c")
  ;;         (introduction
  ;;          (make-channel-introduction
  ;;           "33f86a4b48205c0dc19d7c036c85393f0766f806"
  ;;           (openpgp-fingerprint
  ;;            "736A C00E 1254 378B A982  7AF6 9DBE 8265 81B6 4490"))))
  ;;        (channel
  ;;         (name 'nonguix)
  ;;         (url "https://gitlab.com/nonguix/nonguix"))
  ;;        %default-channels)

  ;;(list (channel
  ;;        (name 'nonguix)
  ;;        (commit "c34fa8bfacdce5fa45b2a684c2b27309c09a9056")
  ;;        (url "https://gitlab.com/nonguix/nonguix"))
  ;;      (channel
  ;;        (name 'guix)
  ;;        (commit "190187326ad7516dd6728eed7bb6ef2d4f92897a")
  ;;        (url "https://git.savannah.gnu.org/git/guix.git")
  ;;        (introduction
  ;;          (make-channel-introduction
  ;;            "9edb3f66fd807b096b48283debdcddccfea34bad"
  ;;          (openpgp-fingerprint
  ;;            "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))

The following channel list can be used when testing patches to packages and services from a local clone of the Guix repo. You'll have to create a branch and commit changes to it before guix pull can pick them up, though. You can change the target branch using the branch field of the channel.

;; (list (channel
;;         (name 'nonguix)
;;         (url "https://gitlab.com/nonguix/nonguix"))
;;       (channel
;;         (name 'guix)
;;         (branch "fix-glu-pkg-config")
;;         (url "file:///home/daviwil/Projects/Code/guix")
;;         (introduction
;;           (make-channel-introduction
;;             "d06d5db885e4b8399e878708862fbe3a67f0592c"
;;             (openpgp-fingerprint
;;               "53C4 1E6E 41AA FE55 335A  CA5E 446A 2ED4 D940 BF14")))))


Base Configuration

This base configuration is shared between all of the machines I manage with Guix. Since all of my machines are Lenovo ThinkPad laptops, the same basic configuration applies pretty cleanly across all of them. This may change in the future.

Any configuration that derives from base-operating-system must invoke guix system in a specific way to ensure it gets loaded correctly:

sudo -E guix system -L ~/.dotfiles/.config/guix/systems reconfigure ~/.dotfiles/.config/guix/systems/davinci.scm


;; NOTE: This file is generated from ~/.dotfiles/System.org.  Please see commentary there.

(define-module (base-system)
  #:use-module (gnu)
  #:use-module (srfi srfi-1)
  #:use-module (gnu system nss)
  #:use-module (gnu services pm)
  #:use-module (gnu services cups)
  #:use-module (gnu services desktop)
  #:use-module (gnu services docker)
  #:use-module (gnu services networking)
  #:use-module (gnu services virtualization)
  #:use-module (gnu packages wm)
  #:use-module (gnu packages cups)
  #:use-module (gnu packages vim)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages xorg)
  #:use-module (gnu packages emacs)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages mtools)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages gnuzilla)
  #:use-module (gnu packages pulseaudio)
  #:use-module (gnu packages web-browsers)
  #:use-module (gnu packages version-control)
  #:use-module (gnu packages package-management)
  #:use-module (nongnu packages linux)
  #:use-module (nongnu system linux-initrd))

(use-service-modules nix)
(use-service-modules desktop xorg)
(use-package-modules certs)
(use-package-modules shells)

Add a udev rule to enable members of the video group to control screen brightness.

;; Allow members of the "video" group to change the screen brightness.
(define %backlight-udev-rule
   (string-append "ACTION==\"add\", SUBSYSTEM==\"backlight\", "
                  "RUN+=\"/run/current-system/profile/bin/chgrp video /sys/class/backlight/%k/brightness\""
                  "ACTION==\"add\", SUBSYSTEM==\"backlight\", "
                  "RUN+=\"/run/current-system/profile/bin/chmod g+w /sys/class/backlight/%k/brightness\"")))

Override the default %desktop-services to add the udev backlight configuration and include OpenVPN in the list of NetworkManager plugins.

(define %my-desktop-services
  (modify-services %desktop-services
                   (elogind-service-type config =>
                                         (elogind-configuration (inherit config)
                                                                (handle-lid-switch-external-power 'suspend)))
                   (udev-service-type config =>
                                      (udev-configuration (inherit config)
                                                          (rules (cons %backlight-udev-rule
                                                                       (udev-configuration-rules config)))))
                   (network-manager-service-type config =>
                                                 (network-manager-configuration (inherit config)
                                                                                (vpn-plugins (list network-manager-openvpn))))))

Use the libinput driver for all input devices since it's a bit more modern than the default.

(define %xorg-libinput-config
  "Section \"InputClass\"
  Identifier \"Touchpads\"
  Driver \"libinput\"
  MatchDevicePath \"/dev/input/event*\"
  MatchIsTouchpad \"on\"

  Option \"Tapping\" \"on\"
  Option \"TappingDrag\" \"on\"
  Option \"DisableWhileTyping\" \"on\"
  Option \"MiddleEmulation\" \"on\"
  Option \"ScrollMethod\" \"twofinger\"
Section \"InputClass\"
  Identifier \"Keyboards\"
  Driver \"libinput\"
  MatchDevicePath \"/dev/input/event*\"
  MatchIsKeyboard \"on\"

Define the base-operating-system which will be inherited by all machine configurations.

(define-public base-operating-system
    (host-name "hackstock")
    (timezone "America/Los_Angeles")
    (locale "en_US.utf8")

    ;; Use non-free Linux and firmware
    (kernel linux)
    (firmware (list linux-firmware))
    (initrd microcode-initrd)

    ;; Choose US English keyboard layout.  The "altgr-intl"
    ;; variant provides dead keys for accented characters.
    (keyboard-layout (keyboard-layout "us" "altgr-intl" #:model "thinkpad"))

    ;; Use the UEFI variant of GRUB with the EFI System
    ;; Partition mounted on /boot/efi.
    (bootloader (bootloader-configuration
                 (bootloader grub-efi-bootloader)
                 (target "/boot/efi")
                 (keyboard-layout keyboard-layout)))

    ;; Guix doesn't like it when there isn't a file-systems
    ;; entry, so add one that is meant to be overridden
    (file-systems (cons*
                     (mount-point "/tmp")
                     (device "none")
                     (type "tmpfs")
                     (check? #f))

    (users (cons (user-account
                  (name "daviwil")
                  (comment "David Wilson")
                  (group "users")
                  (home-directory "/home/daviwil")
                  (supplementary-groups '(
                                          "wheel"     ;; sudo
                                          "netdev"    ;; network devices
                                          "realtime"  ;; Enable realtime scheduling
                                          "lp"        ;; control bluetooth devices
                                          "audio"     ;; control audio devices
                                          "video")))  ;; control video devices


    ;; Add the 'realtime' group
    (groups (cons (user-group (system? #t) (name "realtime"))

    ;; Install bare-minimum system packages
    (packages (append (list
                        nss-certs     ;; for HTTPS access
                        gvfs)         ;; for user mounts

    ;; Use the "desktop" services, which include the X11 log-in service,
    ;; networking with NetworkManager, and more
    (services (cons* (service slim-service-type
                                    (keyboard-layout keyboard-layout)
                                    (extra-config (list %xorg-libinput-config))))))
                    (service tlp-service-type
                                (cpu-boost-on-ac? #t)
                                (wifi-pwr-on-bat? #t)))
                    (pam-limits-service ;; This enables JACK to enter realtime mode
                      (pam-limits-entry "@realtime" 'both 'rtprio 99)
                      (pam-limits-entry "@realtime" 'both 'memlock 'unlimited)))
                    (extra-special-file "/usr/bin/env"
                      (file-append coreutils "/bin/env"))
                    (service thermald-service-type)
                    (service docker-service-type)
                    (service libvirt-service-type
                              (unix-sock-group "libvirt")
                              (tls-port "16555")))
                    (service cups-service-type
                               (web-interface? #t)
                                 (list cups-filters))))
                    (service nix-service-type)
                    (bluetooth-service #:auto-enable? #t)
                    (remove (lambda (service)
                                (eq? (service-kind service) gdm-service-type))

    ;; Allow resolution of '.local' host names with mDNS
    (name-service-switch %mdns-host-lookup-nss)))


Because I'm lame, all of my machines are named from characters, things, and places from the movie Hackers.

Per-System Settings

Some settings need to be customized on a per-system basis without tweaking individual configuration files. Thanks to org-mode's noweb functionality, I can define a set of variables that can be tweaked for each system and applied across these configuration files when they get generated.

I also define a function called dw/system-settings-get which can retrieve these settings appropriately.

(require 'map) ;; Needed for map-merge

(setq dw/system-settings
    '((desktop/dpi . 180)
      (desktop/background . "samuel-ferrara-uOi3lg8fGl4-unsplash.jpg")
      (emacs/default-face-size . 220)
      (emacs/variable-face-size . 245)
      (emacs/fixed-face-size . 200)
      (polybar/height . 35)
      (polybar/font-0-size . 18)
      (polybar/font-1-size . 14)
      (polybar/font-2-size . 20)
      (polybar/font-3-size . 13)
      (dunst/font-size . 20)
      (dunst/max-icon-size . 88)
      (vimb/default-zoom . 180)
      (qutebrowser/default-zoom . 200))


zerocool is a 5th Generation ThinkPad X1 Carbon that I use for most of my writing and hacking at home.


;; NOTE: This file is generated from ~/.dotfiles/System.org.  Please see commentary there.

(define-module (zerocool)
  #:use-module (base-system)
  #:use-module (gnu))

 (inherit base-operating-system)
 (host-name "zerocool")

  (list (mapped-device
         (source (uuid "039d3ff8-0f90-40bf-89d2-4b2454ada6df"))
         (target "system-root")
         (type luks-device-mapping))))

 (file-systems (cons*
                 (device (file-system-label "zerocool"))
                 (mount-point "/")
                 (type "ext4")
                 (dependencies mapped-devices))
                 (device "/dev/nvme0n1p1")
                 (mount-point "/boot/efi")
                 (type "vfat"))


acidburn is a 1st Generation ThinkPad X1 Nano that I use for most of my writing and hacking at home.


;; NOTE: This file is generated from ~/.dotfiles/System.org.  Please see commentary there.

(define-module (acidburn)
  #:use-module (base-system)
  #:use-module (gnu)
  #:use-module (nongnu packages linux))

 (inherit base-operating-system)
 (host-name "acidburn")

 (firmware (list linux-firmware sof-firmware))

 ;; Don't load modules that can conflict with drivers needed for
 ;; sound on this system.  See also:
 ;; https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_7)#Audio
 (kernel-arguments '("modprobe.blacklist=snd_hda_intel,snd_soc_skl"))

  (list (mapped-device
         (source (uuid "15ece913-c423-49aa-ac42-3bad39fdd966"))
         (target "system-root")
         (type luks-device-mapping))))

 (file-systems (cons*
                 (device (file-system-label "system-root"))
                 (mount-point "/")
                 (type "ext4")
                 (dependencies mapped-devices))
                 (device "/dev/nvme0n1p1")
                 (mount-point "/boot/efi")
                 (type "vfat"))

System Settings

(when (equal system-name "acidburn")
  '((desktop/dpi . 180)
    (emacs/default-face-size . 190)
    (emacs/variable-face-size . 200)
    (emacs/fixed-face-size . 190)
    (polybar/height . 30)
    (polybar/font-0-size . 16)
    (polybar/font-1-size . 12)
    (polybar/font-2-size . 18)
    (polybar/font-3-size . 11)
    (dunst/font-size . 20)
    (dunst/max-icon-size . 88)
    (vimb/default-zoom . 160)
    (qutebrowser/default-zoom . 180)))


davinci is a ThinkPad T480s that I use at my day job.


;; NOTE: This file is generated from ~/.dotfiles/System.org.  Please see commentary there.

(define-module (davinci)
  #:use-module (base-system)
  #:use-module (gnu))

 (inherit base-operating-system)
 (host-name "davinci")

  (list (mapped-device
         (source (uuid "eaba53d9-d7e5-4129-82c8-df28bfe6527e"))
         (target "system-root")
         (type luks-device-mapping))))

 (file-systems (cons*
                 (device (file-system-label "system-root"))
                 (mount-point "/")
                 (type "ext4")
                 (dependencies mapped-devices))
                 (device "/dev/nvme0n1p2")
                 (mount-point "/boot/efi")
                 (type "vfat"))

System Settings

(when (equal system-name "davinci")
  '((desktop/dpi . 130)
    (emacs/default-face-size . 165)
    (emacs/fixed-face-size . 165)
    (emacs/variable-face-size . 190)
    (polybar/height . 25)
    (polybar/font-0-size . 12)
    (polybar/font-1-size . 8)
    (polybar/font-2-size . 14)
    (polybar/font-3-size . 9)
    (dunst/font-size . 14)
    (dunst/max-icon-size . 64)
    (vimb/default-zoom . 150)
    (qutebrowser/default-zoom . 150)))

;; When booted into Windows
(when (equal system-name "daviwil-t480")
  '((emacs/default-face-size . 110)
    (emacs/fixed-face-size . 110)
    (emacs/variable-face-size . 134)))


phantom is a ThinkPad X1 Extreme that I use for music production and video editing. For whatever reason, loading the nouveau driver crashes the machine upon booting so I've blacklisted it for now until I figure out how to get it working correctly.


;; NOTE: This file is generated from ~/.dotfiles/System.org.  Please see commentary there.

(define-module (phantom)
  #:use-module (base-system)
  #:use-module (gnu))

 (inherit base-operating-system)
 (host-name "phantom")

  (list (mapped-device
         (source (uuid "091b8ad5-efb3-4c5b-8370-7db99c404a30"))
         (target "system-root")
         (type luks-device-mapping))))

 (file-systems (cons*
                 (device (file-system-label "system-root"))
                 (mount-point "/")
                 (type "ext4")
                 (dependencies mapped-devices))
                 (device "/dev/nvme0n1p1")
                 (mount-point "/boot/efi")
                 (type "vfat"))

System Settings

(when (equal system-name "phantom")
  '((desktop/dpi . 240)
    (polybar/height . 40)
    (vimb/default-zoom . 200)))

USB Installation Image

To install Guix on another machine, you first to build need a USB image. Since I use modern laptops that require non-free components, I have to build a custom installation image with the full Linux kernel. I also include a few other programs that are useful for the installation process. I adapted this image from one found on the Nonguix repository, hence the copyright header.


;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
;;; Copyright © 2019 David Wilson <david@daviwil.com>
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; GNU General Public License for more details.
;;; You should have received a copy of the GNU General Public License
;;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;; Generate a bootable image (e.g. for USB sticks, etc.) with:
;; $ guix system disk-image nongnu/system/install.scm

(define-module (nongnu system install)
  #:use-module (gnu system)
  #:use-module (gnu system install)
  #:use-module (gnu packages version-control)
  #:use-module (gnu packages vim)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages emacs)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages mtools)
  #:use-module (gnu packages package-management)
  #:use-module (nongnu packages linux)
  #:export (installation-os-nonfree))

(define installation-os-nonfree
    (inherit installation-os)
    (kernel linux)
    (firmware (list linux-firmware))

    ;; Add the 'net.ifnames' argument to prevent network interfaces
    ;; from having really long names.  This can cause an issue with
    ;; wpa_supplicant when you try to connect to a wifi network.
    (kernel-arguments '("quiet" "modprobe.blacklist=radeon" "net.ifnames=0"))

    ;; Add some extra packages useful for the installation process
     (append (list exfat-utils fuse-exfat git curl stow vim emacs-no-x-toolkit)
             (operating-system-packages installation-os)))))


Profile Management

I like to separate my packages into separate manifests that get installed as profiles which can be updated independently. These profiles get installed under the ~/.guix-extra-profiles path and sourced by my ~/.profile when I log in.

To make the management of multiple profiles easier, I've created a couple of shell scripts:

Activating Profiles

This script accepts a space-separated list of manifest file names (without extension) under the ~/.config/guix/manifests folder and then installs those profiles for the first time. For example:

activate-profiles desktop emacs music


# NOTE: This file is generated from ~/.dotfiles/System.org.  Please see commentary there.


if [[ $# -eq 0 ]]; then

for profile in $profiles; do
  # Remove the path and file extension, if any
  profileName=$(basename $profile)

  if [ -f $manifestPath ]; then
    echo -e "${GREEN}Activating profile:" $manifestPath "${NC}"

    mkdir -p $profilePath
    guix package --manifest=$manifestPath --profile="$profilePath/$profileName"

    # Source the new profile
    if [ -f $GUIX_PROFILE/etc/profile ]; then
        . "$GUIX_PROFILE"/etc/profile
        echo -e "${RED}Couldn't find profile:" $GUIX_PROFILE/etc/profile "${NC}"
    echo "No profile found at path" $profilePath

Updating Profiles

This script accepts a space-separated list of manifest file names (without extension) under the ~/.config/guix/manifests folder and then installs any updates to the packages contained within them. If no profile names are provided, it walks the list of profile directories under ~/.guix-extra-profiles and updates each one of them.

update-profiles emacs


# NOTE: This file is generated from ~/.dotfiles/System.org.  Please see commentary there.


if [[ $# -eq 0 ]]; then

for profile in $profiles; do
  profileName=$(basename $profile)

  echo -e "${GREEN}Updating profile:" $profilePath "${NC}"

  guix package --profile="$profilePath/$profileName" --manifest="$HOME/.config/guix/manifests/$profileName.scm"

Dotfiles Management

Since I keep all of my important configuration files in Org Mode code blocks, I have to ensure that the real configuration files are kept up to date when I sync the latest changes to my dotfiles repo. I've written a couple of scripts to simplify that process:


When I want to sync my dotfiles repo into my local clone which likely has uncommitted changes, I run sync-dotfiles. This script first makes sure that all Org files are saved in a running Emacs instance and then stashes everything before pulling the latest changes from origin. After pulling, the stash is popped and then the script verifies there are no merge conflicts from the stash before proceeding. If there are no conflicts, update-dotfiles is run, otherwise I'll fix the merge conflicts manually and run update-dotfiles myself.


# Sync dotfiles repo and ensure that dotfiles are tangled correctly afterward


# Navigate to the directory of this script (generally ~/.dotfiles/.bin)
cd $(dirname $(readlink -f $0))
cd ..

echo -e "${BLUE}Saving Org buffers if Emacs is running...${NC}"
emacsclient -u -e "(org-save-all-org-buffers)" -a "echo 'Emacs is not currently running'"

echo -e "${BLUE}Stashing existing changes...${NC}"
stash_result=$(git stash push -m "sync-dotfiles: Before syncing dotfiles")
if [ "$stash_result" = "No local changes to save" ]; then

echo -e "${BLUE}Pulling updates from dotfiles repo...${NC}"
git pull origin master

if [[ $needs_pop -eq 1 ]]; then
    echo -e "${BLUE}Popping stashed changes...${NC}"
    git stash pop

unmerged_files=$(git diff --name-only --diff-filter=U)
if [[ ! -z $unmerged_files ]]; then
   echo -e "${RED}The following files have merge conflicts after popping the stash:${NC}"
   printf %"s\n" $unmerged_files  # Ensure newlines are printed


Updating my dotfiles requires running a script in Emacs to loop over all of my literate configuration .org files and run org-babel-tangle-file to make sure all of my configuration files are up to date.


# Navigate to the directory of this script (generally ~/.dotfiles/.bin)
cd $(dirname $(readlink -f $0))
cd ..

# The heavy lifting is done by an Emacs script
emacs -Q --script ./.emacs.d/tangle-dotfiles.el

# Make sure any running Emacs instance gets updated settings
emacsclient -e '(load-file "~/.emacs.d/per-system-settings.el")' -a "echo 'Emacs is not currently running'"

# Update configuration symlinks
stow .


(require 'org)
(load-file "~/.dotfiles/.emacs.d/lisp/dw-settings.el")

;; Don't ask when evaluating code blocks
(setq org-confirm-babel-evaluate nil)

(let* ((dotfiles-path (expand-file-name "~/.dotfiles"))
       (org-files (directory-files dotfiles-path nil "\\.org$")))

  (defun dw/tangle-org-file (org-file)
    (message "\n\033[1;32mUpdating %s\033[0m\n" org-file)
    (org-babel-tangle-file (expand-file-name org-file dotfiles-path)))

  ;; Tangle Systems.org first
  (dw/tangle-org-file "Systems.org")

  (dolist (org-file org-files)
    (unless (member org-file '("README.org" "Systems.org"))
      (dw/tangle-org-file org-file))))

Nix Package Manager

In an ironic twist of fate, I've found that certain tools I need to use are more easily available in the Nix package repository, so I use it to install them.

https://nixos.org/channels/nixpkgs-unstable nixpkgs

The channel needs to be updated before any packages can be installed:

nix-channel --update

Installing packages:

nix-env -i nodejs dotnet-sdk gh hledger
# nix-env -iA nixpkgs.nodejs-12_x # For a specific version

System Installation

Here's a guide for how I install my GNU Guix systems from scratch. This process is simplified because I've already prepared a reusable system configuration so you might need to do extra work if you end up following this for your own system install.

Building the Installation Image

Since I use modern Thinkpads, I have to use the non-free kernel and firmware blobs from the nonguix channel. After cloning the repo, the installation image can be built with this command:

# Create a slightly larger install image to have some headroom
# for temporary file creation and avoid "no space free" errors
guix system image ./install.scm --image-size=5G

NOTE: It can take an hour or more for this to complete, so be patient...

Once the build is complete, Guix will print out the path to the disk image file that was created. You can now write the installation image to a USB stick using dd:

sudo dd if=/gnu/store/nyg6jv3a4l0pbcvb0x7jfsb60k9qalga-disk-image of=/dev/sdX status=progress

Installing Guix

With the newly "burned" installation image, boot from the USB drive and choose "Install using the shell based process."

Setting up WiFi

Use an editor (or echo) to create a new file called wifi.conf to store the wifi configuration. Make sure to set ssid to the name of your wifi access point and psk to the passphrase for your wifi. You may also need to change the key_mgmt parameter depending on the type of authentication your wifi router supports (some examples on Arch Wiki).

  psk="unencrypted passphrase"

First, run the following commands to unblock the wifi card, determine its device name, and connect using the device name you received from ifconfig -a. In my case it's wlp4s0 so I run the command like so:

rfkill unblock all
ifconfig -a
wpa_supplicant -c wifi.conf -i wlp4s0 -B

The last step to set up networking is to run dhclient to turn on DNS for your wifi connection:

dhclient -v wlp4s0

Setting Up Partitions

Since we're installing on a ThinkPad with UEFI, follow the instructions in the Guix manual for disk partitioning. The short of it is that you need to use cfdisk to create a partition in your free space:

cfdisk /dev/nvme0n1

Once you have your Linux root partition set up, you can enable LUKS to encrypt that partition by running the following commands (where /dev/nvme0n1p5 is your root partition and system-root is an arbitrary label you'd like to use for it):

cryptsetup luksFormat /dev/nvme0n1p5
cryptsetup open --type luks /dev/nvme0n1p5 system-root
mkfs.ext4 -L system-root /dev/mapper/system-root
mount LABEL=system-root /mnt

Finally, make sure to mount your EFI partition to /mnt/boot so that the installer can install the bootloader. The Guix installation instructions obscure this step slightly so it's easy to miss:

mkdir -p /mnt/boot/efi
mount /dev/<EFI partition> /mnt/boot/efi

Now your EFI and encrypted root filesystems are mounted so you can proceed with system installation. You must now set up the installation enviornment using herd:

herd start cow-store /mnt

Initial System Installation

If you've got a system configuration prepared already, you can use git to pull it down into the current directory (the one you're already in, not /mnt):

git clone https://github.com/daviwil/dotfiles

One important step before you attempt system installation is to set up the nonguix channel so that the system can be installed from it. Once you've cloned your dotfiles repo, you can place your channels.scm file into the root user's .config/guix path and then run guix pull to activate it:

mkdir -p ~/.config/guix
cp dotfiles/guix/channels.scm ~/.config/guix
guix pull
hash guix  # This is necessary to ensure the updated profile path is active!

The pull operation may take a while depending on how recently you generated your installation USB image (if packages in the main Guix repository have been updated since then).

Once your channels are set up, you will need to tweak your configuration to reflect the partition UUIDs and labels for the system that you are installing. To figure out the UUID of your encrypted root partition, you can use the following command:

cryptsetup luksUUID /dev/<root partition>

Now you can initialize your system using the following command:

guix system -L ~/.dotfiles/.config/guix/systems init path/to/config.scm /mnt

This could take a while, so make sure your laptop is plugged in and let it run. If you see any errors during installation, don't fret, you can usually resume from where you left off because your Guix store will have any packages that were already installed.

Initial System Setup

Congrats! You now have a new Guix system installed, reboot now to complete the initial setup of your user account.

The first thing you'll want to do when you land at the login prompt is login as root and immediately change the root and user passwords using passwd (there isn't a root password by default!):

passwd             # Set passwd for 'root'
passwd <username>  # Set password for your user account (no angle brackets)

Now log into your user account and clone your dotfiles repository.

Since we used the nonguix channel to install the non-free Linux kernel, we'll need to make sure that channel is configured in our user account so that we have access to those packages the next time we guix pull. At the moment I just symlink the Guix config folder from my .dotfiles to ~/.config/guix:

ln -sf ~/.dotfiles/guix ~/.config/guix

Verify that your channels.scm file is in the target path (~/.config/guix/channels.scm) and then run guix pull to sync in the new channel.

Now you can install the packages that you want to use for day-to-day activities. I separate different types of packages into individual manifest files and manage them with my activate-profiles script:

activate-profiles desktop emacs

Now the packages for these manifests will be installed and usable. They can be updated in the future by using the update-profiles script.