Skip to content

wimpysworld/nix-config

Repository files navigation

Wimpy's NixOS & Home Manager Configurations

This repository contains a Nix Flake for configuring my computers and/or home environment. It is not intended to be a drop in configuration for your computer, but you are welcome to use it as a reference or starting point for your own configuration. If you are looking for a more generic NixOS configuration, I recommend nix-starter-configs. 👍️ These computers are managed by this Nix flake ❄️

Hostname Board CPU RAM Primary GPU Secondary GPU Role OS State
vader MEG-X570-UNIFY AMD Ryzen 9 5950X 128GB Fighter RX 6700 XT NVIDIA T1000 🖥️ ❄️
phasma MEG-X570-ACE AMD Ryzen 9 5900X 128GB Fighter RX 6700 XT NVIDIA T600 🖥️ ❄️
palpatine ThinkPad P1 Gen 1 Intel Xeon E-2176M 64GB NVIDIA Quadro P2000 Max-Q Intel UHD Graphics P630 💻️🎭️ 🪟
sidious ThinkPad P1 Gen 1 Intel Xeon E-2176M 64GB NVIDIA Quadro P2000 Max-Q Intel UHD Graphics P630 💻️🎭️ ❄️
tanis ThinkPad Z13 Gen 1 AMD Ryzen 5 PRO 6650U 32GB AMD Radeon 660M 💻️ ❄️
dooku Macbook Air M2 15" Apple M2 8-core CPU 24GB Apple M2 10-core GPU 💻️🎭️ 🍏 🚧
tyranus Macbook Air M2 15" Apple M2 8-core CPU 24GB Apple M2 10-core GPU 💻️🎭️ ❄️ 🚧
steamdeck Steam Deck 64GB LCD Zen 2 4c/8t 16GB 8 RDNA 2 CUs 🎮️ 🐧
minimech QEMU - - VirGL 🐄 ❄️
scrubber QEMU - - VirGL 🐄 ❄️
skull NUC6i7KYK Intel Core i7-6770HQ 64GB Intel Iris Pro Graphics 580 ☁️ ❄️ 🚧
designare Z390-DESIGNARE Intel Core i9-9900K 64GB Intel Arc A770 16GB Intel UHD Graphics 630 ☁️ ❄️ 🚧
brix GB-BXCEH-2955 Intel Celeron 2955U 16GB Intel HD Graphics ☁️ ❄️ 🧟
nuc NUC5i7RYH Intel Core i7-5557U 32GB Intel Iris Graphics 6100 ☁️ ❄️ 🧟
ripper TRX40-DESIGNARE AMD Ryzen Threadripper 3970X 256GB GeForce RTX 3090 GAMING OC 🖥️ ❄️ ⚰️
trooper ROG Crosshair VIII Impact AMD Ryzen 9 5950X 64GB Fighter RX 6800 🖥️ ❄️ ⚰️

Key

  • 🎭️ : Dual boot
  • 🖥️ : Desktop
  • 💻️ : Laptop
  • 🎮️ : Games Machine
  • 🐄 : Virtual Machine
  • ☁️ : Server

As featured on Linux Matters podcast! 🎙️ I am a presenter on Linux Matters and this configuration was featured in Episode 7 - Immutable Desktop Linux for Anyone.

Linux Matters Podcast
Linux Matters Podcast

Structure

The nixos/_mixins and home-manager/_mixins are a collection of composited configurations based on the arguments defined in flake.nix.

Installing 💾

  • Boot off a .iso image created by this flake using build-iso console or build-iso <desktop> (see below)
  • Put the .iso image on a USB drive
  • Boot the target computer from the USB drive
  • Two installation options are available: 1 Use the graphical Calamares installer to install an ad-hoc system 2 Run install-system <hostname> <username> from a terminal
    • The install script uses Disko or disks.sh to automatically partition and format the disks, then uses my flake via nixos-install to complete a full-system installation
    • This flake is copied to the target user's home directory as ~/Zero/nix-config
    • The nixos-enter command is used to automatically chroot into the new system and apply the Home Manager configuration.
  • Make a cuppa 🫖
  • Reboot 🥾

Applying Changes ✨

I clone this repo to ~/Zero/nix-config. NixOS and Home Manager changes are applied separately because I have some non-NixOS hosts.

gh repo clone wimpysworld/nix-config ~/Zero/nix-config
  • ❄️ NixOS: A build-host and switch-host aliases are provided that build the NixOS configuration and switch to it respectively.
  • 🏠️ Home Manager: A build-home and switch-home aliases are provided that build the Home Manager configuration and switch to it respectively.
  • 🌍️ All: There are also build-all and switch-all aliases that build and switch to both the NixOS and Home Manager configurations.

ISO 📀

The build-iso script is included that creates .iso images from this flake. The following modes are available:

  • build-iso console (terminal environment): Includes install-system for automated installation.
  • build-iso gnome (GNOME Desktop environment): Includes install-system and Calamares installation.
  • build-iso mate (MATE Desktop environment): Includes install-system and Calamares installation.
  • build-iso pantheon (Pantheon Desktop environment): Includes install-system and Calamares installation.

Live images will be left in ~/$HOME/Zero/nix-config/result/iso/ and are also injected into ~/Quickemu/nixos-console and ~/Quickemu/nixos-<desktop> respectively. The console .iso image is also periodically built and published via [GitHub Actions and is available in this project's Releases](https://github.com/wimpysworld/nix-config/releases).

What's in the box? 🎁

Nix is configured with flake support and the unified CLI enabled.

Structure

Here's the directory structure I'm using:

.
├── home-manager
│   ├── _mixins
│   │   ├── configs
│   │   ├── desktop
│   │   │   ├── aqua
│   │   │   ├── gnome
│   │   │   ├── mate
│   │   │   └── pantheon
│   │   ├── hosts
│   │   │   ├── phasma
│   │   │   └── vader
│   │   ├── services
│   │   └── users
│   │       └── martin
│   └── default.nix
├── nixos
│   ├── _mixins
│   │   ├── configs
│   │   ├── desktop
│   │   │   ├── gnome
│   │   │   ├── mate
│   │   │   └── pantheon
│   │   ├── services
│   │   └── users
│   │       ├── martin
│   │       ├── nixos
│   │       └── root
│   ├── phasma
│   ├── vader
│   └── default.nix
├── overlays
├── pkgs
├── secrets
└── flake.nix

The NixOS and Home Manager configurations are in the nixos and home-manager directories respectively, they are structured in the same way with _mixins directories that contain the mixin configurations that are used to compose the final configuration. The pkgs directory contains my custom local packages with package overlays in the overlays directory. The secrets directory contains secrets managed by sops-nix. The default.nix files in the root of each directory are the entry points.

The Shell 🐚

[Fish shell] with powerline-go and a collection of tools that deliver a "Modern Unix" experience. The base system has a firewall enabled and also includes [OpenSSH], sops-nix for secret management, [ZeroTier], [Podman & Distrobox] and, of course, a delightfully configured micro. (Fight me! 🥊) My common scripts are (slowly) being migrated to declarative Nix-managed scripts.

fastfetch on Ripper

The Desktop 🖥️

GNOME 👣 MATE 🧉 and Pantheon 🏛️ desktop options are available. The font configuration is common for all desktops using Work Sans and Fira Code. The usual creature comforts you'd expect to find in a Linux Desktop are integrated such as Pipewire, Bluetooth, Avahi, CUPS, SANE and NetworkManager.

Desktop System Configuration Theme
GNOME GNOME Install GNOME Configuration Adwaita (Dark)
MATE MATE Install MATE Configuration Yaru Magenta (Dark)
Pantheon Pantheon Install Pantheon Configuration elementary Bubble Gum (Dark)

Eye Candy 👀🍬

Pantheon on Designare

Alt

Post-install Checklist

Things I currently need to do manually after installation.

Secrets

  • Provision ~/.config/sops/age/keys.txt. Optionally handled by install-system.
  • Add ssh-to-age -i /etc/ssh/ssh_host_ed25519_key.pub to .sops.yaml.
  • Run sops updatekeys secrets/secrets.yaml
  • Run gpg-restore
  • 1Password - authenticate
  • LastPass - authenticate

Services

  • Atuin - atuin login -u <user>
  • Brave - enroll sync
  • Chatterino - authenticate
  • Discord - authenticate
  • GitKraken - authenticate with GitHub
  • Grammarly - authenticate
  • IRCCloud - authenticate
  • Maelstral - maestral_qt
  • Matrix - authenticate
  • Syncthing - Connect API and introduce host
  • Tailscale - sudo tailscale up
  • Telegram - authenticate
  • Keybase - keybase login
  • VSCode - authenticate with GitHub enable sync
  • Wavebox - authenticate Google and restore profile
  • ZeroTier - enable host sudo zerotier-cli info
  • Run fonts.sh to install commercial fonts

Windows Boot Manager on multi-disk systems

One of my laptops (sidious) is a multi-disk system with Windows 11 Pro 🪟 installed on a separate disk from NixOS. The Windows EFI partition is not automatically detected by systemd-boot, because it is on a different disk. The following steps are required to copy the Windows Boot Manager to the NixOS EFI partition so dual-booting is possible.

Find Windows EFI Partition

lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT

Mount Windows EFI Partition

sudo mkdir /mnt/win-efi
sudo mount /dev/nvme1n1p1 /mnt/win-efi

Copy Contents of Windows EFI to NixOS EFI

sudo rsync -av /mnt/win-efi/EFI/Microsoft/ /boot/EFI/Microsoft/

Clean up

sudo umount /mnt/win-efi
sudo rm -rf /mnt/win-efi

Reboot and systemd-boot should now offer the option to boot NixOS and Windows.

TODO 🗒️

Things I should do or improve:

System

macOS

  • Install Rosetta and disable Xcode Command Line tools on macOS
    • softwareupdate --install-rosetta --agree-to-license

Linux Desktop

Game Development

  • Package for Defold
  • Local package for PICO-8
  • Add Godot. Maybe...

Shell

  • zellij, tmate or tmux
  • git-graph and/or git-igitt integration

Servers

  • Migrate Borg Backups to borgmatic via NixOS modules and Home Manager
  • Forgejo or Gitea
  • microbin

Inspirations 🧑‍🏫

Before preparing my NixOS and Home Manager configurations I took a look at what other Nix users are doing. My colleagues shared their configs and tips which included nome from Luc Perkins, nixos-config from Cole Helbling, flake from Ana Hoverbear and her Declarative GNOME configuration with NixOS blog post. A couple of friends also shared their configurations and here's Jon Seager's nixos-config and Aaron Honeycutt's nix-configs.

While learning Nix I watched some talks/interviews with Matthew Croughan and Will Taylor's Nix tutorials on Youtube. Will Taylor's dotfiles are worth a look, as are his videos, and Matthew Croughan's nixcfg is also a useful reference. After I created my initial flake I found nix-starter-configs by Gabriel Fontes which is an excellent starting point. I'll be incorporating many of the techniques it demonstrates in my nix-config.

I like the directory hierarchy in Jon Seager's nixos-config and the mixin pattern used in Matthew Croughan's nixcfg, so my initial Nix configuration is heavily influenced by both of those. Ana's excellent Declarative GNOME configuration with NixOS blog post was essential to get a personalised desktop. That said, there's plenty to learn from browsing other people's Nix configurations, not least for discovering cool software. I recommend a search of GitHub nixos configuration from time to time to see what interesting techniques you pick up and new tools you might discover.

The Disko implementation and automated installation are chasing the ideas outlined in these blog posts: