بنقرة واحدة
nix-os
Comprehensive Nix package and configuration management following Determinate Systems best practices.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Comprehensive Nix package and configuration management following Determinate Systems best practices.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use when creating, editing, or debugging Factorio mods — writing prototypes in data.lua, handling events in control.lua, defining mod settings, structuring info.json, writing locale files, or diagnosing desync and prototype errors.
Use when creating, editing, or debugging Factorio mods — writing prototypes in data.lua, handling events in control.lua, defining mod settings, structuring info.json, writing locale files, or diagnosing desync and prototype errors.
Manage Nix packages, flakes, and configurations using Determinate Nix installer patterns. Use when installing/updating packages, creating flakes, troubleshooting Nix issues, or optimizing Nix workflows. Keywords: nix, flake, package, nixpkgs, nix profile, flake.nix, flake.lock, determinate, nix-installer
Use when working with Obsidian vaults — creating or editing .md notes, wikilinks, callouts, frontmatter, embeds, tags, or Obsidian-specific syntax; or when interacting with a vault via the obsidian CLI to read, create, search, manage notes/tasks/properties, or develop and debug plugins and themes.
Use when working with Obsidian Canvas files as cognitive modeling tools — compiling spatial/visual structure into deterministic JSON, designing canvas layouts with semantic color and edge conventions, exporting structured data from canvas, or importing JSON into canvas form.
Use when working with Obsidian vaults — creating or editing .md notes, wikilinks, callouts, frontmatter, embeds, tags, or Obsidian-specific syntax; or when interacting with a vault via the obsidian CLI to read, create, search, manage notes/tasks/properties, or develop and debug plugins and themes.
| name | nix-os |
| description | Comprehensive Nix package and configuration management following Determinate Systems best practices. |
| metadata | {"version":"1.0.0","author":"zk::anticompiler","category":"development"} |
Comprehensive Nix management following Determinate Systems best practices and this repository's patterns.
The primary orchestrator for Declarative Skill Management.
SKILL.md (instructions/YAML frontmatter).~/.claude/skills).jq or curl) directly into the SKILL.md so the agent doesn't have to guess where they are or download them, saving context tokens.A daily-updated collection of Nix packages for AI agents.
claude-code, codex, amp, and more.Beyond just "skills," this repo is a masterclass in Nix Meta-Programming for AI context.
lib.importSubdirs + mapAttrs) to translate a single source of truth for agents and commands into:
mcp-servers-nix, treats MCP tools as system-level resources available across all host archetypes.khanelivim) or shell environments without breaking the core system logic.Every config change follows this sequence — no shortcuts:
mcp-nixos to find correct package attr or option path. Never guess.inspect_state or Read tool).zcli deploy <host> for system switches.rollback_generation so user can recover: sudo nixos-rebuild switch --rollback.On validation failure: extract the first error: line, surface it, stop. Don't retry blind.
System config vs Home Manager:
/mnt/repository/nix-os/hosts/, modules/) → zcli deploy <host>home-manager build then home-manager switch (no sudo)Check current Nix setup:
/mnt/repository/nix-os/zcli deploy <host>Read current flake.nix to understand:
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable")packages, devShells, formatterProcess:
mcp-nixos for correct package attribute name/mnt/repository/nix-os/zcli deploy <host> to applyProcess:
# Update flake inputs
nix flake update -C /mnt/repository/nix-os
# Apply updates to mesh host
zcli deploy <host>
Process:
zcli deploy <host> or nh os switchNote: Garbage collection removes unreferenced packages:
nh clean all
Common operations:
Add new input:
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Add new input
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs"; # Prevent duplicate nixpkgs
};
Add host-specific packages:
paths = [
# Universal packages
git gh lazygit
] ++ lib.optionals (config.networking.hostName == "nxiz") [
# nxiz-only
nvidia-vaapi-driver
];
Modify devShell:
devShells = forAllSystems ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
fish
nixpkgs-fmt
shellcheck
# Add development tools here
];
inputsFrom = [ self.packages.${pkgs.system}.default ];
shellHook = ''
echo "🐠 Dotfiles development environment"
echo "Ready for development."
'';
};
});
Choose the right tool for the scope of change:
# Dry-run full host eval (standard gate before deploy)
zcli deploy <host> --dry
# Evaluate a specific attribute without building
nix eval /mnt/repository/nix-os#nixosConfigurations.<host>.config.<attr.path>
# Check a specific package is resolvable
nix eval /mnt/repository/nix-os#nixosConfigurations.<host>.config.environment.systemPackages --json
# Build only the system closure, no switch
nix build /mnt/repository/nix-os#nixosConfigurations.<host>.config.system.build.toplevel --dry-run
# Fast syntax+eval check without building anything
nix flake check /mnt/repository/nix-os --no-build
# Quick metadata check (no eval)
nix flake metadata /mnt/repository/nix-os
On error: extract the first error: line and surface it. Stop. Don't retry blind.
Common issues:
du-dust → dust)When to update:
How:
# Update all inputs
nix flake update
# Update specific input only
nix flake lock --update-input nixpkgs
# Verify changes
git diff flake.lock
Diagnosis:
nix store info # Check store size
nix store gc --dry-run # See what can be cleaned
Solutions:
nix-collect-garbage -d to remove old generationsnix store optimise to deduplicate filesError: error: attribute 'package-name' missing
Solutions:
nix search nixpkgs package-nameError: error: ... while evaluating ...
Common causes:
flake.nixDebug:
nix eval .#packages.aarch64-darwin.default.name # Test specific attribute
nix repl # Interactive REPL
:lf . # Load flake in REPL
packages.aarch64-darwin.default.name # Evaluate in REPL
Error: error: flake.lock is dirty
Solutions:
# Regenerate lock file
rm flake.lock
nix flake update
# Or accept uncommitted changes
nix flake check --impure # NOT recommended for reproducibility
Rollback to previous generation: Use the boot menu on restart, or temporarily switch:
/nix/var/nix/profiles/system-*-link/bin/switch-to-configuration test
Reasoning:
nixos-unstable: Tested, passes Hydra CImaster: Untested, may have broken packagesCurrent setup:
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
Problem: Breaks reproducibility by allowing environment variable access
Correct:
nix flake check # Pure evaluation
Incorrect:
nix flake check --impure # BAD: non-reproducible
Exception: Only use --impure if flake explicitly uses getEnv or similar
Why:
How:
# Always commit flake.lock
git add flake.lock
git commit -m "chore: update flake lock"
Pattern in this repo:
packages.default = pkgs.buildEnv {
name = "system-packages";
paths = [ git gh lazygit ... ];
};
Benefits:
User-level config (~/.config/nix/nix.conf):
experimental-features = nix-command flakes
Use repository root as template:
# Copy flake structure
cp flake.nix /path/to/new-project/
# Customize for project needs
cd /path/to/new-project
$EDITOR flake.nix
Or use templates directory:
# Use template (if available in .claude/skills/nix-manager/templates/)
nix flake init -t .#template-name
Without installing:
# Enter dev shell
nix develop
# Build without installing
nix build
# Run specific package
nix run .#package-name
Using formatter output:
nix fmt # Uses nixpkgs-fmt (defined in flake.nix)
Manual formatting:
nixpkgs-fmt flake.nix
This skill enables agents to maintain a local Nix profile in a user-provided directory, allowing dynamic installation of tools without requiring system-wide package management or sudo access.
The DAEMON_PROFILE env var is automatically set to ~/.local/state/daemon-profile and its bin directory is added to the $PATH via Home Manager. The agent can use:
nix profile add --profile "$DAEMON_PROFILE" "nixpkgs#git"
The --profile flag stores the profile metadata in that location.
(Note: on older Nix versions, the add sub-command was called install).
Search for Packages:
# Search in nixpkgs flake
nix search nixpkgs git
# Search in specific (fully qualified) flake
nix search "github:user/repo[/branch]" <package-name>
# Get detailed JSON output
nix search nixpkgs python3 --json | jq '.[].pname'
Manage Daemon Profile:
# Add package
nix profile add --profile "$DAEMON_PROFILE" "<flake>#<package>"
# List installed packages
nix profile list --profile "$DAEMON_PROFILE"
# Remove by index or element number
nix profile remove --profile "$DAEMON_PROFILE" 0
# Upgrade packages
nix profile upgrade --profile "$DAEMON_PROFILE" <package_name>
nix profile upgrade --profile "$DAEMON_PROFILE" --all
# 1. Verify profile path
echo $DAEMON_PROFILE
# 2. Search for the package
nix search nixpkgs git
# 3. Add it
nix profile add --profile "$DAEMON_PROFILE" "nixpkgs#git"
# 4. Use it!
git --version
Important Details:
$DAEMON_PROFILE/bin) is automatically in $PATH.nixpkgs#git resolves to the current nixpkgs version. Use github:user/repo/ref#package to pin.When modifying flake.nix:
Use Edit tool for existing files:
Use Write tool for new files:
After changes, always:
nix eval or zcli deploy <host> --dryzcli deploy <host>Include testing commands:
# Validate changes
nix flake check
# Show what changed
nix flake show
This NixOS mesh repository follows these conventions:
File Structure:
flake.nix - Package definitions and outputsflake.lock - Pinned dependency versionshosts/ - Host-specific configuration (nxiz, zrrh, adeck)modules/ - Shared configuration modulesPackage Organization: Packages grouped by purpose with comments:
paths = [
# Version control
git gh lazygit
# Build tools
gnumake cmake pkg-config
# Programming languages
rustup go python3 deno
# ... etc
];
Common Commands:
zcli deploy <host> --dry - Dry-run eval without applyingzcli deploy <host> - Build and apply to a hostnh clean all - Garbage collectPatterns this flake uses that agents must recognize and preserve.
my.* Option NamespaceHost identity and opt-in features flow through my.* options defined in modules/system.nix and modules/performance.nix:
# modules/system.nix
options.my.host = lib.mkOption {
type = lib.types.enum [ "nxiz" "adeck" "zrrh" ];
description = "Host identifier — selects per-host blocks in shared modules";
};
# modules/performance.nix
options.my.performance.enable = lib.mkEnableOption "system-wide performance optimizations";
Each host's configuration.nix sets my.host = "<name>"; — every shared module keys off this.
perHost Lookup TablesInstead of cascading lib.mkIf checks, shared modules declare a perHost attrset and select with h = perHost.${config.my.host}. Found in modules/{boot,networking,storage,nh}.nix:
let
perHost = {
nxiz = { flake = "/mnt/repository/nix-os"; resolvedDns = true; };
adeck = { flake = "/etc/nixos"; resolvedDns = false; };
zrrh = { flake = "/etc/nixos"; resolvedDns = true; };
};
h = perHost.${config.my.host};
in {
programs.nh.flake = h.flake;
services.resolved.enable = h.resolvedDns;
}
When adding host-divergent config, extend perHost rather than sprinkling conditionals.
HM is bound into each nixosConfiguration via home-manager.nixosModules.home-manager in flake.nix. Key settings:
home-manager.useGlobalPkgs = true; # share nixpkgs with system
home-manager.useUserPackages = true; # install to /etc/profiles/per-user/zk
home-manager.backupFileExtension = "hm-bak";
home-manager.overwriteBackup = true; # resolves dotfile collisions on deploy
home-manager.extraSpecialArgs = { inherit inputs; }; # threads flake inputs into HM
HM modules live under modules/home/** and per-host HM entry is hosts/<host>/home.nix.
home.packagesAd-hoc derivations live next to their install site — avoid creating separate files for one-off packages. Found in hosts/{nxiz,adeck,zrrh}/home.nix:
# Prebuilt binary with ELF patch
pkgs.runCommand "nullclaw-2026.3.1" {
src = pkgs.fetchurl { url = "..."; hash = "..."; };
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
} ''install -Dm755 $src $out/bin/nullclaw''
# Go module from GitHub
pkgs.buildGoModule {
pname = "picoclaw";
src = pkgs.fetchFromGitHub { owner = "..."; repo = "..."; rev = "..."; hash = "..."; };
vendorHash = "...";
}
# Shell wrapper with runtime deps
pkgs.writeShellApplication {
name = "fzf-emoji";
runtimeInputs = [ fzf jq wl-clipboard curl coreutils ];
text = ''...'';
}
Rule of thumb: if it's one derivation used in one place, inline it. If it's used across hosts, make it a module with options.programs.<name> (see modules/home/msgvault.nix for the reference pattern: mkEnableOption + mkOption + lib.mkIf cfg.enable).
modules/overlays.nix holds all overrideAttrs surgeries. Pattern is always _final: prev: { pkg = prev.pkg.overrideAttrs (old: {...}); }. Real examples:
tumbler rebuilt without libgepub to drop webkitgtk deplmstudio rebuilt with patchelf to fix Bun ELF layout corruptionyaziPlugins namespace created from flake = false input source treeInput-provided overlays are applied per-host in flake.nix via nixpkgs.overlays = [ inputs.nix-cachyos-kernel.overlays.pinned ];.
Secrets encrypted with recipient SSH keys, decrypted at boot into /run/secrets/:
# modules/user.nix
age.identityPaths = [
"/etc/ssh/ssh_host_ed25519_key"
"/home/zk/.ssh/id_ed25519"
];
age.secrets.github-token = {
file = ../secrets/github-token.age;
owner = "zk"; group = "users"; mode = "0400";
path = "/run/secrets/github-token";
};
Recipients declared in secrets/secrets.nix (per-file publicKeys list). To add a new secret: agenix -e secrets/new.age (after adding to secrets.nix), then reference via config.age.secrets.new.path in the module.
HM activation scripts use config.lib.dag.entryAfter [ "writeBoundary" ] to run after file symlinks are in place:
home.activation.ensureLocalBin = config.lib.dag.entryAfter [ "writeBoundary" ] ''
mkdir -p "$HOME/.local/bin"
'';
System activation uses system.activationScripts.<name> = { text = "..."; deps = [ "etc" ]; } — the deps list controls ordering (e.g. SSH host key staging runs after /etc is populated).
mkOutOfStoreSymlink for Live FilesFor dotfiles that point at mutable paths outside /nix/store (edited live, not baked into the system closure):
home.file.".pi".source = config.lib.file.mkOutOfStoreSymlink
"/mnt/repository/daemonturgy/pi/.pi";
Use for editable config dirs, large data caches, or anything that shouldn't trigger a rebuild on change.
nixosConfigurations.{nxiz,adeck,zrrh} — host configsformatter.x86_64-linux — nixfmt-rfc-style (run nix fmt)devShells.x86_64-linux.default — includes nixd, nil, nixfmt, statix, deadnix (nix develop)checks.x86_64-linux.{statix,deadnix} — lint gates (nix flake check)Run nix fmt before committing .nix changes. Run nix flake check --no-build to catch lint regressions cheaply.
Essential Commands:
# Deploy
zcli deploy <host> # Apply flake changes
zcli deploy <host> --dry # Dry-run eval, no switch
zcli deploy all # Deploy all mesh hosts
# Targeted evaluation (prefer over full deploy for validation)
nix eval /mnt/repository/nix-os#nixosConfigurations.<host>.config.<attr>
nix build /mnt/repository/nix-os#nixosConfigurations.<host>.config.system.build.toplevel --dry-run
nix flake check /mnt/repository/nix-os --no-build
# Package discovery (use mcp-nixos first)
nix search nixpkgs <package> # Fallback search
# Flake management
nix flake update /mnt/repository/nix-os # Update all inputs
nix flake show /mnt/repository/nix-os # Display outputs
nix flake metadata /mnt/repository/nix-os # Show metadata
# Garbage collection
nh clean all # Clean old generations
nix store gc --dry-run # Preview cleanup
# Development
nix develop # Enter dev shell
nix fmt # Format Nix code
nix shell nixpkgs#<tool> # Transient tool (one-shot)