/cc-skills-nix:nixos-host-provisioningfrom cc-skills-nix
Adding or provisioning a NixOS host in a blueprint-based config flake — hosts/<name>/default.nix escape hatch wiring input modules (disko, sops-nix, nixos-hardware, nixos-facter), declarative partitioning with disko (GPT ESP+root, ext4 or btrfs subvolumes), hardware detection via nixos-facter instead of hardware-configuration.nix, and manual home-manager user wiring. Apply when adding a new machine to a NixOS flake; when writing or editing hosts/<name>/{default.nix,configuration.nix,disko.nix}; when generating or overriding facter.json; when a host needs modules from flake inputs; when home-manager users don't get created on a host. Do NOT use for non-NixOS projects, for nix-darwin-only hosts, or for flakes not using blueprint's hosts/ convention.
Ships in cc-skills-nix. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A host is a directory hosts/<name>/ with these entries (users/ only when the host has home-manager users; disko/facter only on bare metal). Reference implementations: the framework/sirius hosts in aldoborrero/nix-system. → Blueprint's host discovery rules and precedence: nix-blueprint skill.
hosts/<name>/
default.nix # escape hatch: nixosSystem call wiring input modules
configuration.nix # the host itself: imports shared modules + hardware quirks
disko.nix # declarative partitioning
facter.json # hardware report (replaces hardware-configuration.nix)
users/<user>.nix # home-manager config for the user on this host
Needed whenever the host imports modules from flake inputs (disko, facter, nixos-hardware, sops-nix have nowhere else to be imported):
{ flake, inputs, hostName }:
{
class = "nixos";
value = inputs.nixpkgs.lib.nixosSystem {
modules =
(with inputs; [
disko.nixosModules.disko
nixos-facter-modules.nixosModules.facter
nixos-hardware.nixosModules.framework-12th-gen-intel
sops-nix.nixosModules.sops
])
++ [ ./configuration.nix ./disko.nix ];
specialArgs = { inherit flake inputs hostName; };
};
}
Cost: hand-rolling nixosSystem means blueprint's automation for this host is off — you provide specialArgs yourself (as above), and home-manager users are NOT auto-wired. Re-add them manually in configuration.nix:
home-manager.users.<user> = import ./users/<user>.nix { inherit flake; };
with the home-manager bridge (a shared module importing inputs.home-manager.nixosModules.default, setting useGlobalPkgs/useUserPackages/backupFileExtension, extraSpecialArgs = { inherit inputs flake; ... } and third-party sharedModules) in the host's import list. perSystem is also not injected on this path. The standalone homeConfigurations."<user>@<host>" output still appears — blueprint derives it from users/ regardless of host type.
{ flake, hostName, lib, modulesPath, ... }:
with lib;
{
imports = [ "${modulesPath}/installer/scan/not-detected.nix" ]
++ (with flake.modules.nixos; [ core networking nix sops /* one topic per module */ ]);
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
facter.reportPath = ./facter.json;
facter.detected.dhcp.enable = lib.mkForce false; # override wrong detections case by case
networking.hostName = hostName;
nixpkgs.hostPlatform = mkDefault "x86_64-linux";
system.stateVersion = "<release>"; # the NixOS release current at FIRST install — then never change it
}
All real configuration lives in modules/nixos/<topic>.nix (import-only style, no enable options); the host file holds only what is unique to the machine. mkForce is reserved for documented conflicts; mkDefault for values a host may override.
Generate the report on the target machine and commit it:
sudo nix run nixpkgs#nixos-facter -- -o facter.json
facter.reportPath = ./facter.json gives kernel modules, firmware and hardware quirks; wrong detections are overridden with facter.detected.<thing>.enable = lib.mkForce false. Pair with the matching nixos-hardware module for the machine model. Keep "${modulesPath}/installer/scan/not-detected.nix" for non-free firmware detection.
Two verified layouts (both GPT, ESP 1MiB→512MiB type EF00 vfat on /boot with priority = 1, root 512MiB→100%) — plain ext4, or btrfs with compress=zstd discard noatime and /home /nix /log /persist subvolumes: full files in references/layouts.md. The disko.nix file is imported explicitly from default.nix — blueprint ignores extra files in the host dir, so forgetting the import silently yields a host with no filesystem config.
hosts/<name>/ with the files above; adapt device = /dev/... in disko.nix and the nixos-hardware module, and set system.stateVersion to the current NixOS release (new hosts only — never touch it on existing ones).git add -A (untracked files are invisible to the flake).nix eval .#nixosConfigurations --apply builtins.attrNames — the host must appear; nix build .#nixosConfigurations.<name>.config.system.build.toplevel (or let checks.<sys>.nixos-<name> do it via nix flake check).sops updatekeys before the first rebuild on the machine (→ nix-sops-secrets skill).facter.json, commit it, rebuild.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub aldoborrero/skills --plugin cc-skills-nix6 skills in this plugin
/nix-blueprintnumtide/blueprint — Nix flake framework that maps a fixed directory structure to flake outputs with zero glue code. Apply when a repo's flake.nix calls `inputs.blueprint { ... }`; when deciding where a package, devshell, host, module, check or template file must live; when a package/devshell/host is missing from `nix flake show` or `nix build` says the attribute doesn't exist; when adding the `prefix` option; when writing packages/<name>/default.nix, devshell.nix or modules/<class>/<name>.nix. Do NOT use for generic Nix flakes without blueprint (hand-written outputs, flake-parts, flake-utils), for nixpkgs contributions, or for NixOS module semantics unrelated to file placement. Prefer nix-project-scaffold for creating a NEW project, nix-treefmt-formatter for formatter.nix internals, and nixos-host-provisioning for adding hosts with disko/facter./nix-oci-imageBuilding and publishing OCI/Docker container images from Nix — dockerTools.buildLayeredImage over a buildEnv (app + cacert), non-root numeric User for Kubernetes runAsNonRoot, version-derived tags, and pushing with skopeo (docker-archive → OCI) to registries like Zot that reject `docker push`. Apply when adding a container image output to a flake; when writing packages/docker/*.nix or dockerTools code; when a Nix-built image fails TLS (missing CA bundle), lacks PATH, or runs as root; when pushing ./result to a private/homelab registry fails; when wiring an image build+push recipe into a justfile or CI. Do NOT use for Dockerfile-based builds, docker-compose, or Kubernetes manifest authoring./nix-project-scaffoldHouse-style scaffold for new Nix-flake projects (Go, Python, or other languages) — numtide/blueprint with prefix="nix", direnv .envrc, numtide devshell with in-repo toolchain caches, treefmt formatter, two-file package (default.nix shim + nixpkgs-style package.nix with src=flake), justfile facade, and GitHub Actions CI pinned to flake.lock's nixpkgs. Apply when creating a new project or repository that should use Nix; when adding Nix/flake tooling to an existing Go or Python repo; when asked for a devshell + formatter + CI setup 'like my other repos'; when wiring justfile targets to nix commands; when setting up direnv for a flake. Do NOT use for repos that already follow a different flake convention (flake-parts, devenv, hand-rolled outputs), for NixOS system configuration repos, or for nixpkgs contributions./nix-sops-secretsSecrets in NixOS flakes with sops-nix + age (+ age-plugin-yubikey) — .sops.yaml recipients and creation_rules, a centralized sops.secrets declaration module, and runtime consumption from /run/secrets. Apply when adding, editing or rotating an encrypted secret; when adding a recipient (new host key or YubiKey) or a new host that must decrypt; when a service or user can't read a secret (permission denied, file missing, empty env var); when wiring an API key or password into a NixOS service, home-manager tool or wrapper script; when configuring .sops.yaml, sops.defaultSopsFile or the age host key. Do NOT use for agenix or vault-based setups, for git-crypt, or for generic sops usage outside Nix./nix-treefmt-formattertreefmt-nix formatter for Nix flakes — `formatter.nix` via `treefmt-nix.lib.evalModule` (build.wrapper + build.check), lint→format ordering with priorities (deadnix→nixfmt, shellcheck→shfmt, ruff-check→ruff-format), and the format check wired into `nix flake check` via passthru.tests. Apply when writing or editing formatter.nix / treefmt config in a flake; when adding a language formatter (Go, Python, shell, YAML, TOML, Markdown, just); when `nix fmt` misbehaves, formats vendored files, or skips files (excludes, on-unmatched, default excludes); when CI passes `nix flake check` but formatting is actually broken (check never ran); when deadnix deletes wanted lambda args. Do NOT use for non-treefmt formatting setups, editor/IDE format-on-save config, or choosing code style rules of a language.