| config | ||
| home | ||
| hosts/xps15 | ||
| scripts | ||
| .gitignore | ||
| flake.lock | ||
| flake.nix | ||
| MIGRATION-GUIDE.md | ||
| README.md | ||
nix-config
NixOS and home-manager configuration for a Dell XPS 15 9500.
Disaster recovery
If you lose your laptop, you need exactly two things from memory:
- AWS root credentials (email + password) — gets you into the console, which gets you to Lightsail, which means Vaultwarden at git.barrettruth.com is reachable
- Vaultwarden master password — unlocks everything else (GitHub, email, etc.)
If you have 2FA on either of these via an authenticator app, you also need recovery codes. Print them. Store them somewhere physical that isn't your laptop.
All SSH keys, GPG keys, and .pem files are stored as attachments in Vaultwarden. Restoring them is step 10 below.
Before you migrate: upload keys to Vaultwarden
Do this now, while you still have a working machine. Create a vault entry (e.g. "keys") and attach:
~/.ssh/id_ed25519~/.ssh/id_ed25519.pub~/.ssh/git-keypair.pem~/.ssh/git-keypair-old.pem~/.ssh/uva_key(if still needed)- GPG private key (export first):
gpg --export-secret-keys --armor A6C96C9349D2FC81 > /tmp/gpg-private.asc
Attach /tmp/gpg-private.asc, then delete the temp file.
By storing the same keys, the key IDs in git.nix stay valid, GitHub
doesn't need updating, and git signing works immediately after restore.
Manual steps (fresh install from zero)
1. Flash the installer
Download the NixOS minimal ISO from https://nixos.org/download (x86_64).
dd bs=4M if=nixos-minimal-*.iso of=/dev/sdX status=progress oflag=sync
2. Boot and connect to WiFi
Boot from USB (F12 for boot menu on XPS 15).
iwctl
[iwd]# station wlan0 scan
[iwd]# station wlan0 get-networks
[iwd]# station wlan0 connect <SSID>
Verify: ping nixos.org
3. Partition
lsblk -f
Option A: fresh partition table
fdisk /dev/nvme0n1
# 1. EFI System partition — 512M
# 2. Linux swap — match your RAM
# 3. Linux filesystem — rest of disk
mkfs.fat -F 32 /dev/nvme0n1p1
mkswap /dev/nvme0n1p2
mkfs.ext4 -L nixos /dev/nvme0n1p3
mount /dev/nvme0n1p3 /mnt
mkdir -p /mnt/boot/efi
mount /dev/nvme0n1p1 /mnt/boot/efi
swapon /dev/nvme0n1p2
Option B: reuse existing partitions
mkfs.ext4 -L nixos /dev/nvme0n1pX # formats root, wipes the old OS
mount /dev/nvme0n1pX /mnt
mkdir -p /mnt/boot/efi
mount /dev/nvme0n1pY /mnt/boot/efi
swapon /dev/nvme0n1pZ
4. Generate hardware config
nixos-generate-config --root /mnt
This produces /mnt/etc/nixos/hardware-configuration.nix. You need this
file — it describes your specific disk UUIDs, kernel modules, and
firmware. The generated configuration.nix next to it is not used.
5. Clone the repo
nix-shell -p git
git clone https://github.com/barrettruth/nix-config /mnt/home/barrett/nix-config
Copy the hardware config into place:
cp /mnt/etc/nixos/hardware-configuration.nix /mnt/home/barrett/nix-config/hosts/xps15/
6. Copy fonts (optional, can be done later)
Fonts are proprietary and not in the repo. The build will succeed
without them — home-manager prints a warning and fonts fall back to
system defaults. When you're ready, populate ~/nix-config/fonts/:
- Copy from a USB drive
- Copy from a backup
- Download from wherever you originally purchased them
- Pull from another machine via scp
cp -r /path/to/your/fonts /mnt/home/barrett/nix-config/fonts/
The fonts/ directory is gitignored and symlinked to
~/.local/share/fonts at activation time.
7. Install
nixos-install --flake /mnt/home/barrett/nix-config#xps15
This builds the entire system (kernel, drivers, services, user environment, home-manager) in one shot. It will ask you to set the root password at the end.
8. Reboot and set user password
reboot
Remove the USB. Log in as root, then:
passwd barrett
logout
Log in as barrett.
9. Fix ownership
The install created ~/nix-config as root. Fix it:
sudo chown -R barrett:users ~/nix-config
10. Restore keys from Vaultwarden
Open Zen browser and go to git.barrettruth.com. Log in with your master password. Open the vault entry containing your keys and download all attachments.
SSH keys
mkdir -p ~/.ssh
cp ~/Downloads/id_ed25519 ~/.ssh/
cp ~/Downloads/id_ed25519.pub ~/.ssh/
cp ~/Downloads/git-keypair.pem ~/.ssh/
cp ~/Downloads/git-keypair-old.pem ~/.ssh/
Permissions are fixed automatically by the activation script in
git.nix on the next rebuild. If you want them right now:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519 ~/.ssh/git-keypair.pem ~/.ssh/git-keypair-old.pem
chmod 644 ~/.ssh/id_ed25519.pub
Set the repo remote to SSH for push access:
cd ~/nix-config
git remote set-url origin git@github.com:barrettruth/nix-config.git
GPG key
gpg --import ~/Downloads/gpg-private.asc
gpg --edit-key A6C96C9349D2FC81 trust
Select trust level 5 (ultimate), then quit. The key ID matches what's
in git.nix, so git signing works immediately.
Clean up
Delete the downloaded key files from ~/Downloads/.
11. Rebuild
After all manual steps are done:
sudo nixos-rebuild switch --flake ~/nix-config#xps15
12. Verify
- Terminal opens (ghostty)
- Neovim works and plugins install on first launch
- Browser opens (zen)
- Waybar shows at top
- Audio works (XF86 keys)
- Git push works (SSH)
- Git commits are signed (GPG)
What's automated vs. what's manual
Automated (handled by the flake)
- All packages and their exact versions
- Zsh, tmux, fzf, direnv, lf configuration
- Ghostty terminal configuration
- Hyprland, waybar, rofi, dunst, hypridle, hyprlock, hyprpaper
- Git config, aliases, ignore patterns
- SSH config (host definitions, not keys)
- GPG agent config (not the keys themselves)
- Keyd keyboard remapping
- NVIDIA drivers and prime offload
- Pipewire audio stack
- Docker and libvirt
- Systemd services and timers
- XDG directories and MIME associations
- Scripts symlinked to ~/.local/bin/scripts
- Directory creation (~/dev, ~/dl, ~/img, ~/wp)
- Cloning this repo to ~/nix-config on first activation
- Wallpaper symlinks from the repo to ~/img/screen
- Daily flake input updates
Manual (you must do these yourself)
- Flash and boot the installer
- Partition and mount disks
- Generate hardware-configuration.nix
- Set root and user passwords
- Restore SSH keys, GPG key, and .pem files from Vaultwarden
- Copy fonts into nix-config/fonts/ (optional, can be done later)
- Restore browser profile (~/.zen) if you want tabs/extensions back
Day-to-day
# edit config, rebuild
sudo nixos-rebuild switch --flake ~/nix-config#xps15
# update all inputs (nixpkgs, home-manager, etc.)
nix flake update --flake ~/nix-config
sudo nixos-rebuild switch --flake ~/nix-config#xps15
# rollback
sudo nixos-rebuild switch --flake ~/nix-config#xps15 --rollback
# or pick a previous generation from GRUB at boot
# garbage collect old generations
sudo nix-collect-garbage -d
# home-manager is integrated into nixos-rebuild, no separate command needed
Architecture
flake.nix
inputs: nixpkgs, home-manager, nixos-hardware, neovim-nightly,
zen-browser, claude-code
nixosConfigurations.xps15 # sudo nixos-rebuild switch --flake .#xps15
hosts/xps15/configuration.nix # boot, hardware, networking, services, users
hosts/xps15/hardware-configuration.nix # machine-specific (not committed)
home-manager (embedded) # user env built as part of system
home/home.nix # imports all modules below
modules/bootstrap.nix # mkdir, clone repo, link wallpapers
modules/theme.nix # midnight/daylight color palettes, fonts, cursor
modules/shell.nix # zsh, tmux, lf, fzf, direnv, ripgrep, fd, eza
modules/terminal.nix # ghostty
modules/git.nix # git, gh, ssh hosts, gpg agent
modules/editor.nix # neovim (config is out-of-store symlink)
modules/ui.nix # hyprland, waybar, rofi, dunst, hyprlock
modules/packages.nix # apps (zen, signal, slack, etc.)
homeConfigurations.barrett # home-manager switch --flake .#barrett
(same home/home.nix, for non-NixOS systems)