Skip to content

yveszoundi/guix-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

This document describes my Gnu Guix System setup for a virtual machine installation (QEMU for me).

  • This is for a UEFI installation that can be performed remotely via SSH (easy copy/paste of notes, etc.)
  • The installation uses BTRFS instead of LVM, with full disk encryption (LUKS)
  • The core installation itself is minimal and the user specific software packages feature DWL (dwm for Wayland)

My initial goal is to contribute to Open Source projects from a Guix environment.

  • My main machine runs few dedicated virtual machines (VM) a la Qubes OS (vault-vm, personal-vm, dev-vm, etc.)
  • Gnu Guix System would be dedicated to open source contributions

Enable remote installation

After booting the Gnu Guix System ISO image, please start SSH and setup a non-blank root password.

herd start ssh-daemon
passwd

Prepare the installation

You can “ssh into” the Gnu Guix System installation: ssh root@ip_here -p port_here.

For new installations with QEMU, I typically forward port 22 to a fixed port number.

For my personal setup, I’m using ssh root@localhost -p 62000.

Create partitions

Identify your disk partitions (fdisk -l can help).

Create 2 partitions by running cgdisk /dev/sda (in my case)

  • Setup the EFI partition (code ef00) of 300 MB (/dev/sda1 in my case)
  • Setup the Linux partition (default code) with the remaining disk space (/dev/sda2 in my case)

Write changes to disk and quit cgdisk.

Create an encrypted device

Encrypt the main partition.

cryptsetup luksFormat --type luks1 /dev/sda2

Open LUKS device

Open the encrypted device.

cryptsetup luksOpen /dev/sda2 guixsdvm

Prepare installation

Run all the commands below to configure partitions and setup filesystems.

mkfs.btrfs -L guixroot /dev/mapper/guixsdvm

mount -t btrfs /dev/mapper/guixsdvm /mnt

btrfs subvolume create /mnt/root
btrfs subvolume create /mnt/boot
btrfs subvolume create /mnt/home
btrfs subvolume create /mnt/gnu
btrfs subvolume create /mnt/data
btrfs subvolume create /mnt/log
btrfs subvolume create /mnt/swap

btrfs filesystem mkswapfile --size 4g /mnt/swap/swapfile
btrfs subvolume snapshot -r /mnt/root /mnt/root-blank

umount /mnt

mount -o subvol=root /dev/mapper/guixsdvm /mnt
mkdir -p /mnt/home /mnt/gnu /mnt/data /mnt/var/log /mnt/boot /mnt/swap
mount -o subvol=home /dev/mapper/guixsdvm /mnt/home
mount -o subvol=gnu  /dev/mapper/guixsdvm /mnt/gnu
mount -o subvol=data /dev/mapper/guixsdvm /mnt/data
mount -o subvol=log  /dev/mapper/guixsdvm /mnt/var/log
mount -o subvol=boot /dev/mapper/guixsdvm /mnt/boot
mount -o subvol=swap /dev/mapper/guixsdvm /mnt/swap

mkfs.vfat /dev/sda1
mkdir -p /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi

herd start cow-store /mnt

Install the system

Edit the etc/config.scm file as needed (i.e. efi and root partition names, timezone, keyboard layout).

You need to create the config.scm file inside your installation

  • You can add/edit the file on your Guix installation locally or via SSH (with nano, mg or vi)
  • Alternatively, you could also download the raw file from GitHub via wget or curl
mkdir -p /mnt/etc
cp config.scm /mnt/etc/config.scm
guix system init /mnt/etc/config.scm /mnt

You can now reboot into your new system (shutdown/start or reboot depending on your setup).

reboot

Setup the new system

Update passwords

Both passwords for the root and user users are initially empty.

Let’s login as root and change that.

passwd
passwd user

Update the system

You can now continue the configuration process remotely (ssh user@localhost -p 62000 in my case).

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

Fix the clock

Connect to the machine remotely (ssh user@localhost -p 62000 in my case).

guix package -i ntp
GUIX_PROFILE="$HOME/.guix-profile"
. "$GUIX_PROFILE/etc/profile"
sudo ntpdate -s time.nist.gov && sudo hwclock --systohc
guix package -r ntp

User environment setup

This will setup a minimal Wayland graphical environment with dwl-guile (via Guix home configuration management).

  • It is assumed have you’ve pulled the contents of this git repository on your new Guix installation
  • We’ll then be able to quickly have a system up and running

As a regular user (user in my case), deploy home/user/src/guix-config/home-configuration.scm.

mkdir -p ~/Downloads ~/.config/guix
cd ~/Downloads
git clone https://github.com/yveszoundi/guix-config
cp -rf home/user/src ~/
cp home/user/.config/guix/channels.scm ~/.config/guix/
guix pull
guix home reconfigure ~/src/guix-config/home-configuration.scm
cd -

Upon first login in the tty, the dwl window manager will be started.

Additional notes

Dev environment setup

I only conceptually understand how to setup a custom environment (guix shell):

  • How easy is it to setup one-off environments for non-trivial projects (rust, java, nodejs, c/c++, etc.)?
  • How should I manage GC and snapshots in the future?

QEMU parameters

If the UI doesn’t start, the QEMU parameter -vga qxl seems to avoid issues with Wayland drivers/renderers.

References