Keeping laptops, workstations, headless servers, VMs, and single-board computers in sync by hand always ends in configuration drift. To keep every machine reproducible and tracked in Git, I put together nixconf, a modular NixOS and Home Manager flake built with flake-parts and nixos-unstable.
Multi-host targets#
One repository builds seven targets across x86_64-linux and aarch64-linux:
| Host | Arch | Role | Disk / Boot |
|---|---|---|---|
laptop | x86_64-linux | Primary laptop (AMD + Nvidia PRIME, MangoWM, gaming, security) | UEFI systemd-boot, LUKS + Btrfs (_disko.nix) |
desktop | x86_64-linux | Workstation without laptop or Nvidia quirks | UEFI systemd-boot, Btrfs via disko |
vm | x86_64-linux | Graphical QEMU/KVM VM (MangoWM, SPICE, VS Code Server) | GRUB, qemu-guest, _disko.nix available |
vm-minimal | x86_64-linux | Headless CLI-only VM for fast evaluation and testing | GRUB + EFI, disko ext4 |
server | x86_64-linux | Headless homelab server (Docker, Tailscale, hardened SSH) | UEFI systemd-boot, disko Btrfs |
raspberrypi | aarch64-linux | Raspberry Pi 4 headless server (nixos-hardware + SD image) | sd-image-aarch64 (nix build .#raspberrypi-sd) |
iso | x86_64-linux | Custom live/rescue USB with disko, ninit, kssh, disk tools | Bootable ISO (nix build .#iso) |
Layout and auto-imported flake-parts#
Instead of listing every module manually in flake.nix, the root flake uses lib.fileset to auto-import every .nix file outside templates/ and home/, skipping flake.nix and _-prefixed files like _disko.nix:
flowchart TD F["flake.nix (flake-parts)"] --> C["Core, Desktop and Headless Modules"] F --> H["Home Manager + wrapper-modules"] F --> P["Custom Packages (ninit, ssh-vault)"] C --> T["7 Targets (laptop, desktop, VMs, server, RPi4, ISO)"] H --> T P --> T
nixconf/
├── flake.nix # Flake inputs (nixpkgs, home-manager, disko, nixos-hardware)
├── bootstrap.sh # Interactive installer and host provisioning script
├── lib/ # Supported systems, formatter, lint checks, devShell, templates
├── home/ # Home Manager modules (core CLI + desktop dotfiles)
├── wrappedPrograms/ # Standalone wrapped apps (myKitty, myMango, myNiri, myNoctalia)
├── packages/ # Custom packages (ninit, keyhints, kssh, ssh-vault, mtp, tunnelmole)
├── templates/ # 27 project templates for `ninit` / `nix flake init`
└── nixos/
├── settings.nix # User identity, SSH keys, locale, and theme options
├── features/
│ ├── core/ # Headless-safe base OS, Home Manager wiring, desktop base
│ ├── system/ # Display sessions & hardware (mangowm, niri, noctalia, laptop, nvidia, wireguard)
│ ├── services/ # Single-purpose services (tailscale, mullvad, ollama, docker, virtualisation)
│ └── apps/ # desktopApps, dev (lean), security, gaming, vr, android, antigravity
└── hosts/ # Per-machine assemblies and _disko.nix layoutsDesign choices#
Hybrid Home Manager and wrapper-modules#
Home Manager (nixosModules.home-manager) manages user dotfiles (zsh, git, ssh, direnv, gtk, dconf, zathura, and Kitty SSH profiles). Graphical tools like myKitty, myMango (MangoWM Wayland compositor), myNiri, and myNoctalia live in wrappedPrograms/ via nix-wrapper-modules as standalone binaries, which keeps their configuration out of Home Manager’s way.
Headless and graphical split#
nixos/features/core/base.nix is headless-safe so servers, vm-minimal, and the Raspberry Pi 4 do not pull in audio or GUI dependencies. PipeWire, fonts, NetworkManager, Polkit, and desktop tools stay isolated in nixos/features/core/desktop.nix.
CUDA isolation and on-demand Ollama#
nvidia.nix sets custom.enableCuda = true. Services and apps like ollama.nix and Blender check this flag so hosts without an Nvidia GPU never download CUDA packages. On the laptop, Ollama has CUDA enabled but stays stopped at boot (0 VRAM idle) and is started or stopped on demand with ollama-up, ollama-down, and ollama-stat.
Minimal global dev packages and ninit#
Global tools in apps/dev.nix stay minimal (uv, python3, vscode, antigravity, docker, gcc, cmake). Language and domain toolchains (Rust, Go, LaTeX, Embedded, SDR, CTF) live in templates/ as 27 flake templates loaded per directory via direnv.
To speed up starting new projects, I wrote ninit (packages/ninit.nix), a Python CLI using rich and questionary. You can browse templates interactively or call an alias directly (ninit rust my-crate, ninit ctf-pwn challenge1). It runs nix flake init -t, initializes Git with a .gitignore that includes .direnv/, and runs direnv allow.
Security, CTF tooling, and ssh-vault#
For Capture The Flag competitions and reverse engineering, nixos/features/apps/security.nix installs ghidra, pwndbg, pwninit, pwntools, ropper, ropgadget, one_gadget, seccomp-tools, imhex, rizin, radare2, non-root wireshark/dumpcap, burpsuite, sage, mtp, and tunnelmole.
To avoid storing unencrypted SSH private keys on disk across machines, packages/ssh-vault.nix provides ssh-vault-add, ssh-vault-load, and ssh-vault-list on top of rbw and bitwarden-cli (bw). Keys stay in Bitwarden or Vaultwarden and are piped straight into ssh-agent when needed.
Provisioning, remote deploys, and CI#
bootstrap.shworks with per-host_disko.nixlayouts to partition disks (LUKS + Btrfs withzstdsubvolumes or ext4), generate hardware configs, and runnixos-installin one pass (./bootstrap.sh --host server --disko).- The flake exposes
nix build .#isofor a custom rescue USB,nix build .#raspberrypi-sdfor anaarch64Pi 4 image, andnix run .#deploy -- serverfor remote deployments over SSH or Tailscale. - A pre-commit hook and GitHub Actions CI run
alejandra(nix fmt),statix,deadnix,nix flake check, template evaluation checks, security scans, and image builds.
Repository links#
- GitHub: github.com/lilvirgola/nixconf
- Installation guide: INSTALL.md




