nixos
Skill1 starsChanged 41 days agoMITView on GitHub
NixOS and nix-darwin system configuration — module shape, typed options with lib.mkOption, composing modules, nixosConfigurations, secrets (agenix/sops-nix), and cross-platform via nix-darwin + Home Manager. Use when writing a system module or config. Triggers: nixosConfiguration, nixos module, home-manager, nix-darwin, agenix, sops-nix, systemd service.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- iuliandita/skillstheir own version, first seen Nov 15, 2026
- marceloeatworld/nixos-ai-skilltheir own version, first seen Jul 11, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- marceloeatworld/nixos-ai-skill★ 36same name
- iuliandita/skills★ 12same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- addressing-findingsSkill
- auditSkill
- codebase-onboardingSkill
- codex-reviewSkill
- compatibilitySkill
- debuggingSkill
- developSkill
- distributed-racesSkill
- memorySkill
- nix-dev-envSkill
- nix-flakesSkill
- nix-packagingSkill
- nix-reviewSkill
- refactoringSkill
- retroSkill
- review-initSkill
- review-rulesSkill
- rust-architecture-reviewSkill
- rust-architectureSkill
- rust-cliSkill
- rust-cloud-nativeSkill
- rust-concurrencySkill
- rust-ecosystemSkill
- rust-embeddedSkill
- rust-errorsSkill
- rust-fintechSkill
- rust-idiomsSkill
- rust-macrosSkill
- rust-mlSkill
- rust-navigationSkill
- rust-ownershipSkill
- rust-performanceSkill
- rust-pluginsSkill
- rust-reviewSkill
- rust-securitySkill
- rust-testingSkill
- rust-traitsSkill
- rust-unsafeSkill
- rust-webSkill
- specsSkill
- sql-reviewSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Every NixOS module is a function that returns an attrset with options and/or config:
- Very specific: line 74
Never shadow argument names with let bindings (e.g.
- Very specific: line 131
Use specialArgs to thread inputs (e.g.
- Distinctive: line 158
Use an encrypted secret manager that decrypts at activation time:
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
NixOS Modules
NixOS configuration is a module system: every .nix file that contributes to a
system is a module. Modules declare options and set values; the evaluator merges them,
type-checks every option, and produces a single system configuration.
When to Use
- Writing or debugging a NixOS module (service, option, overlay, system config)
- Composing
nixosConfigurations.<host>in a flake - Managing secrets in a NixOS system (agenix, sops-nix)
- Cross-platform configs: NixOS on Linux, nix-darwin on macOS, Home Manager on both
- Wiring a
systemdservice or system-level unit
The module shape
Every NixOS module is a function that returns an attrset with options and/or config:
{ config, lib, pkgs, ... }:
{
options.services.myApp = {
enable = lib.mkEnableOption "my application";
port = lib.mkOption {
type = lib.types.port;
default = 8080;
description = "TCP port the application listens on.";
};
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/my-app";
description = "Directory for persistent application data.";
};
};
config = lib.mkIf config.services.myApp.enable {
systemd.services.my-app = {
description = "My Application";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${pkgs.my-app}/bin/my-app --port ${toString config.services.myApp.port}";
User = "my-app";
StateDirectory = "my-app";
};
};
users.users.my-app = {
isSystemUser = true;
group = "my-app";
};
users.groups.my-app = {};
};
}Key points:
- The argument list
{ config, lib, pkgs, ... }uses...to accept additional inputs (e.g.inputs,modulesPath) without breaking when they are absent. config(the argument) is the merged system configuration;config(the return key) is this module's contribution.lib.mkIfgates the entireconfigblock on the option being enabled — avoids unconditional side-effects.- Never shadow argument names with
letbindings (e.g.let config = ...hides the system config and breaks everyconfig.*reference inside theletbody).
Declaring typed options with lib.mkOption
lib.mkOption {
type = lib.types.str; # the type — enforced at eval time
default = "hello"; # optional; absence makes the option mandatory
example = "world"; # shown in nixos-option output
description = "Human-readable docs."; # shown in the manual
}Common types
| Type | Notes |
lib.types.bool | true / false |
lib.types.int | any integer |
lib.types.port | integer 0–65535 |
lib.types.str | any string |
lib.types.path | filesystem path |
lib.types.package | a derivation |
lib.types.listOf lib.types.str | list of strings |
lib.types.attrsOf lib.types.int | attribute set of ints |
lib.types.nullOr lib.types.str | string or null |
lib.types.enum [ "a" "b" ] | one of a fixed set |
lib.types.submodule { options = …; } | nested structured option |
lib.mkEnableOption "description" is shorthand for a bool option defaulting to
false — prefer it over a raw lib.mkOption for toggle-style options.
Composing modules
Modules are composed by listing them in nixosSystem:
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hardware-configuration.nix # generated by nixos-generate-config
./modules/my-app.nix # custom module
./users/alice.nix # per-user module
{ # inline anonymous module
networking.hostName = "myhost";
time.timeZone = "Europe/Berlin";
}
];
};The evaluator merges all modules: lists are concatenated, booleans are OR'd (with
lib.mkForce available to override), and type errors surface at nix build time.
Passing extra arguments to modules
Use specialArgs to thread inputs (e.g. flake inputs) into every module:
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; }; # makes `inputs` available as a module arg
modules = [ ./configuration.nix ];
};Inside ./configuration.nix:
{ config, lib, pkgs, inputs, ... }: # `inputs` now in scope
{
# use inputs.agenix.packages.${pkgs.system}.agenix, etc.
}Secrets must never land in the Nix store
The Nix store at /nix/store is world-readable. Any string you put into a derivation —
including a systemd ExecStart argument or an environment.etc file — becomes
readable by every user on the machine.
Rule: never put a secret string into a module option or derivation.
Use an encrypted secret manager that decrypts at activation time:
agenix
agenix encrypts secrets with age keys; the private key lives on the host (typically an
SSH host key). Secrets are decrypted into /run/agenix/ (a tmpfs) at activation.
# flake.nix — add the input
inputs.agenix.url = "github:ryantm/agenix";
inputs.agenix.inputs.nixpkgs.follows = "nixpkgs";
# nixosConfigurations.myhost
modules = [
inputs.agenix.nixosModules.default
{
age.secrets.db-password = {
file = ./secrets/db-password.age; # encrypted file in the repo
owner = "my-app"; # who may read the decrypted file
};
systemd.services.my-app.serviceConfig = {
# Point at the decrypted path — never embed the value
EnvironmentFile = config.age.secrets.db-password.path;
};
}
];Encrypt secrets with the agenix CLI and the host's public key (or any age recipient).
The encrypted .age file is safe to commit; the plaintext never touches the store.
sops-nix
sops-nix uses Mozilla SOPS with age or PGP keys. Secrets are decrypted at activation
into /run/secrets/.
inputs.sops-nix.url = "github:Mic92/sops-nix";
inputs.sops-nix.inputs.nixpkgs.follows = "nixpkgs";
modules = [
inputs.sops-nix.nixosModules.sops
{
sops.defaultSopsFile = ./secrets/secrets.yaml; # SOPS-encrypted file
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
sops.secrets.db-password = {
owner = "my-app";
};
systemd.services.my-app.serviceConfig = {
EnvironmentFile = config.sops.secrets.db-password.path;
};
}
];Both tools follow the same pattern: the secret value is never a Nix string; the module receives a path to the decrypted file on tmpfs and passes that path to the service.
Cross-platform: nix-darwin and Home Manager
NixOS modules only run on Linux. For macOS use nix-darwin, which mirrors the NixOS module system for macOS system configuration.
# flake.nix
inputs.nix-darwin.url = "github:LnL7/nix-darwin";
inputs.nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
darwinConfigurations.macbook = inputs.nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
./modules/common.nix # shared options work on both platforms
./modules/darwin.nix # macOS-specific
];
};Inside a shared module, guard platform-specific options with pkgs.stdenv.isLinux /
pkgs.stdenv.isDarwin:
{ config, lib, pkgs, ... }:
{
config = lib.mkMerge [
{
# common to both platforms
environment.systemPackages = [ pkgs.ripgrep pkgs.fd ];
}
(lib.mkIf pkgs.stdenv.isLinux {
# Linux / NixOS only
services.openssh.enable = true;
})
(lib.mkIf pkgs.stdenv.isDarwin {
# macOS / nix-darwin only
system.defaults.dock.autohide = true;
})
];
}Home Manager handles per-user dotfiles and programs on both platforms — see home-manager.md.
Boundaries
flake.nixinputs,nixosConfigurationswiring inoutputs,flake.lockpinning →nix-flakes. That skill owns the flake schema; this skill owns what goes insidenixosSystem { modules = […]; }.- Derivations, overlays,
callPackage,mkDerivation, overrides →nix-packaging. - Dev shells,
direnv, per-project toolchains →nix-dev-env. - The
craft:reviewworkflow's Nix profile consumes the modules rules from this skill when reviewing NixOS configuration changes: option types,lib.mkIfdiscipline, and the secrets-not-in-store rule are its primary checklist items for module diffs.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

