guix-config/README.org
2025-07-30 22:22:25 +00:00

3.6 KiB

Enable remote installation

After booting the Gnu Guix System ISO image, elect to drop into a shell after selecting your language and location.

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.

During new installations with QEMU, I typically forward port 22 to a fixed port number (e.g., 62000).

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 then Quit the cgdisk interface.

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 guixvm

Prepare installation

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

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

  mount -t btrfs /dev/mapper/guixvm /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/guix /mnt
  mkdir -p /mnt/home /mnt/gnu /mnt/data /mnt/var/log /mnt/boot /mnt/swap
  mount -o subvol=home /dev/mapper/guix /mnt/home
  mount -o subvol=gnu  /dev/mapper/guix /mnt/gnu
  mount -o subvol=data /dev/mapper/guix /mnt/data
  mount -o subvol=log  /dev/mapper/guix /mnt/var/log
  mount -o subvol=boot /dev/mapper/guix /mnt/boot
  mount -o subvol=swap /dev/mapper/guix /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

  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 --timeout=800 --max-silent-time=800
  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

  sudo guix system -L ~/src/guix-config reconfigure ~/src/guix-config/hosts/$(hostname).scm
  sudo guix home -L ~/src/guix-config reconfigure ~/src/guix-config/home/$(hostname).scm