My Nix flake. The file-structure generates the configuration: every .nix
under a discovered path is auto-imported, so adding a file is the same as
enabling a module.
# NixOS host
sudo nixos-rebuild switch --flake .#<host>
# Home-Manager only (e.g. work machine)
home-manager switch --flake .#<user>@<host>
# Dev shell, formatter, templates
nix develop
nix fmt
nix flake new -t .#<template> <dest>| Host | Kind | User |
|---|---|---|
zephyrus |
NixOS (ASUS Zephyrus) | haru02w |
zephyrus-wsl |
NixOS-WSL | haru02w |
vm |
NixOS (QEMU guest) | haru02w |
QIN-120868 |
Home-Manager (work, non-NixOS) | joaomillane |
flake.nix
lib/ # helpers (auto-import, host/user discovery, pkgs-for-system)
hosts/ # per-host config (./hosts/<host>/{nixos,home-manager/<user>}/...)
modules/ # auto-imported NixOS / home-manager / nixvim modules
profiles/ # composable bundles, pulled in via the symlink chain (see below)
pkgs/ # flake packages (nixvim)
overlays/ # nixpkgs overlays
templates/ # `nix flake new -t self#<template>`
secrets/ # sops-encrypted (see `.sops.yaml`)
Profiles are not auto-discovered by the flake. Each host pulls them in via a
profile symlink under hosts/<host>/{nixos,home-manager/<user>}/, and
profiles themselves symlink to the ones they extend:
host ──► desktop ──► cli ──► global
(or)
host ──────────► cli ──► global
lib/default.nix:listFilesRecursive follows symlinks, so the auto-import
walks the whole chain.
mkdir -p hosts/<host>/nixos(and/orhosts/<host>/home-manager/<user>).- Create
hosts/<host>/default.nix— settings file consumed by the flake:_: { arch = "x86_64-linux"; }
- Drop host-specific
.nixfiles in the subdirs (e.g.hardware-configuration.nix,setup/default.nix). Everything under the dir auto-imports. - Link the deepest profile to inherit:
ln -s ../../../profiles/desktop/nixos hosts/<host>/nixos/profile ln -s ../../../../profiles/cli/home-manager hosts/<host>/home-manager/<user>/profile
- Add the row to the Hosts table above.
- Build with the commands in Build.
Secrets live in secrets/secrets.yaml, encrypted with the age key listed in
.sops.yaml. On a fresh machine, drop the matching private key at:
~/.config/sops/age/keys.txt
before the first rebuild. users.mutableUsers = false means the login password
is read from sops at activation — without the key, the rebuild will fail.