Quick Start
cattery is built with purr and works best inside a purr
flake. It also works with plain nixosSystem, homeManagerConfiguration, and
darwinSystem calls if you pass the few arguments purr would otherwise provide.
Add the input
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:nix-darwin/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
cattery-modules = {
url = "https://flakehub.com/f/nixcafe/cattery-modules/0.1.*.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
inputs.darwin.follows = "darwin";
};
};
}Several modules install unfree packages, such as Visual Studio Code and Zoom. Set
nixpkgs.config.allowUnfree = true (or nixpkgsConfig.allowUnfree in purr) unless you
only use modules without them.
With purr
purr discovers hosts under systems/ and homes under homes/, and it passes each host the
purr metadata that the shared cattery modules read. Add the cattery bundles to
extraModules so every host and home imports them:
# flake.nix
{
inputs.purr.url = "https://flakehub.com/f/nixcafe/purr/0.1.*.tar.gz";
outputs =
inputs:
inputs.purr.lib.mkFlake {
inherit inputs;
src = ./.;
nixpkgsConfig.allowUnfree = true;
extraModules = {
nixos = [ inputs.cattery-modules.nixosModules.default ];
darwin = [ inputs.cattery-modules.darwinModules.default ];
home = [ inputs.cattery-modules.homeModules.default ];
};
};
}{
imports = [ ./hardware.nix ];
cattery = {
user.name = "alice";
room.desktop.dev.enable = true;
desktop.plasma.enable = true;
};
system.stateVersion = "25.11";
}{
cattery.room.desktop.dev.enable = true;
home.stateVersion = "25.11";
}The home alice@workstation is linked into the workstation host through Home Manager's
NixOS module, and it is also built on its own as homeConfigurations."alice@workstation".
sudo nixos-rebuild switch --flake .#workstation
home-manager switch --flake .#alice@workstationThe nix-config template sets all
of this up, with example NixOS, NixOS-WSL, and nix-darwin hosts and installer images.
NixOS without purr
The shared modules read purr.meta.isLinux, purr.meta.isDarwin, and purr.meta.host.
Pass them through specialArgs. The NixOS bundle also forwards some settings into Home
Manager, so give Home Manager the cattery home modules with home-manager.sharedModules:
# flake.nix
{
outputs =
{ nixpkgs, cattery-modules, ... }:
{
nixosConfigurations.workstation = nixpkgs.lib.nixosSystem {
specialArgs.purr.meta = {
host = "workstation";
isLinux = true;
isDarwin = false;
};
modules = [
cattery-modules.nixosModules.default
./configuration.nix
{
nixpkgs.hostPlatform = "x86_64-linux";
nixpkgs.config.allowUnfree = true;
home-manager.sharedModules = [ cattery-modules.homeModules.default ];
}
];
};
};
}# configuration.nix
{
imports = [ ./hardware.nix ];
networking.hostName = "workstation";
cattery = {
user.name = "alice";
room.desktop.dev.enable = true;
home.extraOptions.home.stateVersion = "25.11";
};
system.stateVersion = "25.11";
}Home Manager
Standalone
The Home Manager bundle needs no purr arguments. Set the user name, and cattery sets
home.username and home.homeDirectory from it:
# flake.nix
{
outputs =
{ nixpkgs, home-manager, cattery-modules, ... }:
{
homeConfigurations.alice = home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
system = "x86_64-linux";
config.allowUnfree = true;
};
modules = [
cattery-modules.homeModules.default
{
cattery = {
user.name = "alice";
room.desktop.dev.enable = true;
};
home.stateVersion = "25.11";
}
];
};
};
}home-manager switch --flake .#aliceThe same configuration works on macOS with system = "aarch64-darwin". Modules that only
apply to one platform skip themselves on the other.
From a NixOS or nix-darwin host
Both system bundles include Home Manager's module. cattery.home.extraOptions is a Home
Manager configuration for the primary user, cattery.user.name. cattery forwards it to
home-manager.users.<name> and sets home-manager.useGlobalPkgs and
home-manager.useUserPackages with lib.mkDefault true:
{
cattery = {
user.name = "alice";
room.desktop.dev.enable = true;
home.extraOptions = {
cattery.room.desktop.dev.enable = true;
programs.git.lfs.enable = true;
home.stateVersion = "25.11";
};
};
}extraOptions uses cattery.* Home Manager options, so the user's Home Manager
configuration needs the cattery home modules. purr provides them for homes linked through
homes/<arch>-<format>/<user>@<host>. Without purr, add them with
home-manager.sharedModules as shown above.
nix-darwin
Desktop Mac
# flake.nix
{
outputs =
{ darwin, cattery-modules, ... }:
{
darwinConfigurations.macbook = darwin.lib.darwinSystem {
specialArgs.purr.meta = {
host = "macbook";
isLinux = false;
isDarwin = true;
};
modules = [
cattery-modules.darwinModules.default
{
nixpkgs.hostPlatform = "aarch64-darwin";
home-manager.sharedModules = [ cattery-modules.homeModules.default ];
cattery = {
user.name = "alice";
room.desktop.dev.enable = true;
home.extraOptions = {
cattery.room.desktop.dev.enable = true;
home.stateVersion = "25.11";
};
};
system.stateVersion = 6;
}
];
};
};
}sudo darwin-rebuild switch --flake .#macbookIn a purr flake, put the host in systems/aarch64-darwin/macbook/default.nix and drop the
specialArgs and nixpkgs.hostPlatform lines. Move the Home Manager settings into
homes/aarch64-darwin/alice@macbook/default.nix, where purr links them with the cattery
home modules, or keep home-manager.sharedModules.
cattery.user sets system.primaryUser to the user name, which nix-darwin needs for
user-level settings.
room.desktop.basis turns on cattery.brew. nix-darwin manages Homebrew packages but
does not install Homebrew itself, so install it once by hand first.
Headless Mac mini
room.server is for a Mac that runs without a screen. It turns on the OpenSSH server and
cattery.system.power, which restarts the machine after a power failure or a freeze and
keeps it from sleeping. It leaves out Homebrew, Touch ID for sudo, the Finder defaults,
and the fonts:
{
cattery = {
user.name = "alice";
user.authorizedKeys.keys = [ "ssh-ed25519 AAAA... alice@laptop" ];
room.server.enable = true;
home.extraOptions.home.stateVersion = "25.11";
};
system.stateVersion = 6;
}NixOS-WSL and Proxmox LXC
{
cattery = {
user.name = "alice";
# Turns on cattery.system.wsl, which sets wsl.defaultUser to the user name.
room.desktop.wsl.enable = true;
};
}{
cattery = {
user.name = "alice";
room.container.enable = true;
system.proxmox.lxc.enable = true;
};
}NixOS-WSL needs a non-root user, because it uses cattery.user.name as wsl.defaultUser.
Opt-in tools
The Home Manager room.desktop.dev leaves out the language toolchains and the JetBrains
IDEs. Turn them on yourself:
{
cattery = {
room.desktop.dev = {
enable = true;
# Every cli-apps.dev-kit module: C and C++, dive, Go, Java with Maven and Gradle,
# JavaScript, Lua, Rust, and WebAssembly.
allDevKit = true;
};
# JetBrains IDEs and Android Studio.
apps.jetbrains.enable = true;
};
}You can also enable single toolchains, for example cattery.cli-apps.dev-kit.rust.enable.
User settings
Several modules read cattery.user for their defaults, such as the Git identity, the
signing key, mail accounts, and the login shell. Set it once on the host and in each home:
{ pkgs, ... }:
{
cattery.user = {
name = "alice";
realName = "Alice Liddell";
email.address = "[email protected]";
gpg.signKey = "0x0123456789ABCDEF";
authorizedKeys.keys = [ "ssh-ed25519 AAAA... alice@laptop" ];
defaultUserShell = pkgs.fish;
};
}On NixOS and nix-darwin, cattery.user.home, uid, and gid are read-only and come from
the system user.
Templates with beans
cattery.nix is part of room.basis on every platform. Besides flakes, automatic garbage
collection, and store optimisation, it registers the flake registry entry beans with
nix.registry.beans.to, pointing at github:nixcafe/develop-templates:
nix flake init -t beans#rustThe develop-templates docs list every template.