nix
Public mirror
synced 2026-11-02 10:57:17 +01:00
Watch 1
Fork 0
You've already forked nix

Latest commit

Tobias
42de8b6 2026-10-30 19:20:12 +01:00 79 commits
2026-07-22 17:01:01 +02:00
2026-10-30 19:20:12 +01:00
2026-10-28 21:42:59 +01:00
2026-10-07 23:56:47 +02:00
2026-09-16 20:25:35 +02:00
2026-09-16 02:57:47 +02:00
2026-09-16 20:25:35 +02:00
2026-10-28 21:42:59 +01:00

nix

Flake configuration for NixOS hosts (pxl, rxl) and a nix-darwin host (txl). Linux stack: niri WM · DankMaterialShell (DMS) + native dms-greeter · alacritty + fish. macOS stack: aerospace WM · alacritty + fish · nix packages for everything CLI, homebrew for GUI casks only.

preview preview-darwin

Structure

nix/
├── flake.nix          # Flake inputs & host definitions (pxl, rxl, txl)
├── install.sh         # Guided installer for fresh NixOS setups
├── deploy.sh          # Switch & rebuild helper script
├── hosts/             # System configurations
│   ├── common/        # Shared NixOS base (audio, fonts, DMS, greeter)
│   ├── pxl/           # Desktop: Secure Boot & Windows dual-boot
│   ├── rxl/           # Laptop: Disko LUKS+LVM & TPM2 auto-unlock
│   └── txl/           # MacBook: nix-darwin & Homebrew GUI casks
└── home/              # User environments (Home Manager)
    ├── common/        # Shared shell, tools, editors, terminal & font settings
    ├── linux/         # Linux desktop environment (niri WM, DMS, Wayland)
    └── darwin/        # macOS desktop environment (aerospace WM)

NixOS systems combine hosts/common + hosts/<host> with home/common + home/linux. macOS (txl) combines hosts/txl with home/common + home/darwin.

Hosts

Host Device OS Bootloader Storage / Partitions Features
pxl Desktop NixOS lanzaboote (Secure Boot) Manual Ext4 Windows dual-boot, sbctl
rxl Framework 13 NixOS systemd-boot Disko (LUKS + LVM) TPM2 auto-unlock, fingerprint
txl MacBook macOS Apple Bootloader APFS nix-darwin, Homebrew casks

Installation

1. Fresh NixOS Install (rxl)

Automated installation using disko with LVM inside LUKS encryption: an Ext4 root volume and 40 GiB swap for hibernation. The EFI partition is unencrypted.

  1. Boot the NixOS live ISO and connect to the internet.
  2. Clone this repository:
    git clone https://github.com/tobikli/nix.git ~/nix && cd ~/nix
    
  3. Locate your target disk ID:
    lsblk -o NAME,ID-LINK,SIZE,MODEL
    
  4. Set the device path in hosts/rxl/disko.nix (replace CHANGEME).
  5. Run the installer:
    sudo ./install.sh rxl
    
  6. Set the user password before rebooting:
    sudo nixos-enter --root /mnt -c 'passwd tobias'
    sudo reboot
    
  7. (Optional) After the first boot, enroll TPM2 auto-unlock for the LUKS container:
    sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/disk/by-partlabel/disk-main-luks
    

2. Dual-Boot NixOS Install (pxl)

Manual installation for systems sharing a disk or secondary drive with Windows and using Secure Boot.

  1. Boot the NixOS live ISO and connect to the internet.
  2. Clone this repository:
    git clone https://github.com/tobikli/nix.git ~/nix && cd ~/nix
    
  3. Partition and format your Linux partitions manually, then mount them to /mnt (e.g. root to /mnt, EFI to /mnt/boot).
  4. Verify the Windows EFI partition path in hosts/pxl/default.nix (defaults to /dev/nvme1n1p1). On each rebuild, NixOS automatically copies the Microsoft boot files to /boot/EFI/Microsoft so systemd-boot auto-discovers Windows.
  5. Prepare the lanzaboote signing keys under /mnt/var/lib/sbctl before installing. The configured pkiBundle is /var/lib/sbctl in the installed system; install.sh does not create these keys. For a new key set, use sbctl from the live environment with the target paths, or first install with Secure Boot/lanzaboote disabled and enable it after creating keys on the installed system.
  6. Run the installer:
    sudo ./install.sh pxl
    
  7. Set the user password before rebooting:
    sudo nixos-enter --root /mnt -c 'passwd tobias'
    sudo reboot
    
  8. To enable Secure Boot, enter UEFI Setup Mode and enroll the existing signing keys with sbctl from the installed system:
    sudo sbctl enroll-keys --microsoft
    

3. macOS Setup (txl)

  1. Prerequisite: Create a macOS account named tobias (matching users.users.tobias in hosts/txl/default.nix) via the standard macOS Setup Assistant.
  2. Install Nix using the Determinate Systems installer:
    curl -fsSL https://install.determinate.systems/nix | sh -s -- install
    
  3. Install Homebrew if it is not already available. This configuration manages its packages but does not install Homebrew itself.
  4. Clone this repository:
    git clone https://github.com/tobikli/nix.git ~/nix && cd ~/nix
    
  5. Bootstrap nix-darwin and switch:
    sudo nix run nix-darwin -- switch --flake .#txl
    
    Note: Homebrew is managed declaratively by nix-darwin for GUI casks (hosts/txl/default.nix). Undeclared casks are cleaned up on activation.

Deploy & Daily Usage

Rebuild and switch configurations directly from this repository:

sudo ./deploy.sh         # Auto-detects host via hostname
sudo ./deploy.sh <host>  # Rebuild a specific host (pxl, rxl, txl)

Inside fish, these functions use the repository at ~/nix and select the host via hostname -s:

  • nrs: Rebuild and switch (nixos-rebuild switch or darwin-rebuild switch)
  • nrb: On NixOS, build and set the configuration for the next boot without changing the running system (nixos-rebuild boot). On macOS, build without activating (darwin-rebuild build).

Fonts & Editors

home/common/font.nix defines the shared font families:

  • systemFont: Inter, used by Linux GTK/GNOME, DMS, media overlays, and the default sans-serif font.
  • monospaceFont: JetBrainsMono Nerd Font Mono, used by Emacs, Alacritty, VS Code (including its terminal), and Linux's default monospace font.

The editor/terminal base size is sizePt = 15. linuxScale = 0.8 produces 12pt on Linux while macOS keeps 15pt. VS Code's CSS pixel sizes are derived automatically (16px and 20px respectively). System UI and overlay sizes remain defined in their respective modules; serif and emoji defaults remain separate.

Change font families and editor sizes in this one file, then rebuild. If selecting a different font, also ensure its package is installed via hosts/common/default.nix (Linux) or hosts/txl/default.nix (macOS).

Emacs uses the native Wayland emacs-pgtk build on Linux and the native macOS build on Darwin. Its configuration and theme live in home/common/emacs/; Home Manager generates ~/.emacs.d/init.el with the shared font setting.

In Niri, Super + mouse wheel up/down focuses columns left/right (wheel up moves left, wheel down moves right). Desktop bindings live in home/linux/niri.nix.

Adding a Host

  1. Create hosts/<name>/default.nix (and disko.nix or hardware-configuration.nix).
  2. Add a nixosConfigurations.<name> or darwinConfigurations.<name> entry in flake.nix.
  3. Deploy with sudo ./deploy.sh <name>.