Skip to content
Public template

About

NixOS, nix-darwin, and Home Manager config template with installer images.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

21 Commits

Folders and files

Repository files navigation

Nix configuration template

Flake template for NixOS, nix-darwin, and Home Manager. Uses purr for directory discovery and cattery-modules for system and user modules.

Part of develop-templates.

Getting started

Initialize from the flake template:

nix flake init -t "github:nixcafe/develop-templates#nix-config" --refresh

Or add the registry alias once (already set on hosts using cattery-modules):

nix registry add beans "github:nixcafe/develop-templates"
nix flake init -t beans#nix-config

Or create a repository on GitHub:

gh repo create my-nixos-config --template nixcafe-develop/nix-config --clone

Enter the shell and inspect outputs:

direnv allow
# or: nix develop
nix flake show

Before deploying

  1. Edit lib/host/default.nix with your username, name, email, timezone, default login shell, and SSH authorized keys. Starship settings live in lib/host/config/starship.toml.
  2. Generate hardware.nix with nixos-generate-config --show-hardware-config > systems/<arch-format>/<name>/hardware.nix and import ./hardware.nix from the host's default.nix. Both hostname-nixos and hostname-server ship with lib.mkDefault placeholders for fileSystems."/" (and boot.loader.grub.device on hostname-server) so the flake evaluates cleanly before real hardware config is added.
  3. Secrets are disabled by default in lib/secrets/default.nix. Point my-secrets in flake.nix at your own repository and set enable = true when ready.

Included hosts and homes

Systems under systems/:

  • x86_64-linux/hostname-nixos: NixOS desktop with KDE Plasma and dev room.
  • x86_64-linux/hostname-server: NixOS server with root user and IP forwarding.
  • x86_64-linux/hostname-wsl: NixOS-WSL host using the default nixos user (NixOS-WSL requires a non-root defaultUser).
  • aarch64-darwin/hostname-mbp: macOS host using nix-darwin.
  • x86_64-linux/{graphical,minimal,minimal-no-zfs}: ISO installer image recipes declared with images = [ "iso-installer" ] in meta.nix. Image-only hosts appear under images and are omitted from nixosConfigurations unless deployable = true is set in meta.nix.

Homes under homes/<arch-format>/<user>@<host>/ are exposed as standalone homeConfigurations and linked into the matching host automatically.

Adding hosts, homes, and images

Add a NixOS host by creating systems/<arch-format>/<name>/default.nix:

{
  imports = [ ./hardware.nix ];
  cattery.room.desktop.dev.enable = true;
  system.stateVersion = "25.11";
}

For a nix-darwin host, create systems/aarch64-darwin/<name>/default.nix without hardware.nix and use an integer system.stateVersion (such as 5). purr sets networking.hostName from the directory name. Put optional host metadata in a sibling meta.nix.

Add a home by creating homes/<arch-format>/<user>@<host>/default.nix:

{
  cattery.room.desktop.dev.enable = true;
}

purr sets home.username and home.homeDirectory from the directory name, and modules/home/home/default.nix sets the default home.stateVersion.

Add an image recipe by setting images in systems/<arch-format>/<name>/meta.nix:

{
  images = [ "iso-installer" ];
}

Build it with:

nix build .#images.graphical.iso-installer

Layout

.
├── flake.nix
├── checks/git-hooks/default.nix    # nixfmt, deadnix, statix hooks
├── shells/default/default.nix      # dev shell with git hooks
├── systems/
│   ├── aarch64-darwin/hostname-mbp/
│   └── x86_64-linux/
│       ├── graphical/
│       ├── hostname-nixos/
│       ├── hostname-server/
│       ├── hostname-wsl/
│       ├── minimal/
│       └── minimal-no-zfs/
├── homes/
│   ├── aarch64-darwin/nixos@hostname-mbp/
│   └── x86_64-linux/
│       ├── nixos@graphical/
│       ├── nixos@hostname-nixos/
│       ├── nixos@hostname-wsl/
│       ├── nixos@minimal/
│       ├── nixos@minimal-no-zfs/
│       └── root@hostname-server/
├── modules/
│   ├── darwin/{brew,user}/
│   ├── home/{home,secrets,user}/
│   ├── nixos/user/
│   └── shared/secrets/
├── lib/
│   ├── host/
│   ├── module/
│   └── secrets/
└── statix.toml

Commands

nix develop
nix flake show
nix flake check
nix fmt
pre-commit run --all-files
nix build .#nixosConfigurations.hostname-nixos.config.system.build.toplevel
nix build .#images.graphical.iso-installer
sudo nixos-rebuild switch --flake .#hostname-nixos

About

NixOS, nix-darwin, and Home Manager config template with installer images.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

Generated from nixcafe-develop/nix