Patch de connaissances Nix

VérifiéSûr

Utilisez cette compétence lors de la modification d'expressions Nix, d'automatisation CLI, de flakes, de stores, de modules NixOS, de paquets Nixpkgs ou de configurations Home Manager.

Spar Skills Guide Bot
DevOpsAvancé
26/08/2026
Claude CodeCursorWindsurfCodex
#nix#nixos#nixpkgs#flakes#migrations

Recommandé pour

Synthèse automatique

Cette compétence fournit un index de référence sur les changements cassants récents de Nix, NixOS, Nixpkgs et Home Manager, avec des points de contrôle de compatibilité basés sur les versions d'état et les révisions de flake.

Points forts

  • Impose de vérifier `nix --version`, `system.stateVersion` et `home.stateVersion` avant toute modification, ce qui évite des migrations involontaires
  • Organise les références par domaine : CLI/évaluation, flakes, stores et caches, API natives, modules NixOS, packaging Nixpkgs et Home Manager
  • Cible des migrations concrètes : systemd en initrd, remplacement des options libres par des attributs `settings` typés, passage à `cargoHash`/`buildGoModule`
  • Rappelle d'utiliser les sorties JSON explicites plutôt que le texte lisible pour l'automatisation en CI

Limites

  • Le fichier n'est qu'un index : le contenu détaillé se trouve dans les fichiers de référence liés, absents de ce SKILL.md
  • Suppose une bonne connaissance préalable de Nix et des flakes ; ce n'est pas un tutoriel d'apprentissage
  • Correspond à un instantané de l'écosystème et peut être en retard sur les évolutions très récentes de Nixpkgs
Quand l'utiliser

À utiliser lorsqu'on modifie une expression Nix, un flake, un module NixOS, un paquet Nixpkgs ou une configuration Home Manager et qu'on veut savoir quels défauts et migrations s'appliquent.

Quand l'éviter

À éviter pour apprendre Nix depuis zéro ou pour du code applicatif sans rapport avec l'écosystème Nix.

Analyse de sécurité

Sûr
Score qualité80/100

This is purely a documentation/reference skill for Nix with no declared tools and no executable payloads. The shell snippets shown (nix profile add, nix copy, nix eval, nix path-info) are benign, standard read/build commands with no destructive operations, no curl|sh piping, no secret exfiltration, and no attempts to disable safety controls. It actively advises keeping secrets out of the Nix store and verifying backups/rollback before activation, which is good practice.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

Fix a package after a nixpkgs bump
I bumped the nixpkgs input in my flake.lock and my Go package using buildGoModule now fails. Check my system.stateVersion and pinned revision, then update the derivation to current builder conventions.
Migrate NixOS modules to typed settings
My NixOS config sets the Postfix config as a free-form string and uses flat systemd options. Migrate them to the current typed `settings` attributes, removing the old options, without raising system.stateVersion.
Parse Nix output safely in CI
Write a CI script that uses `nix path-info --json` with an explicit JSON schema to check store closure sizes, rather than parsing the human-readable output.

name: nix-knowledge-patch description: Nix version: null license: MIT metadata: author: Nevaberry

Nix Knowledge Patch

Use this skill when changing Nix expressions, Nix CLI automation, flakes, stores, binary caches, NixOS modules, Nixpkgs packages, or Home Manager configurations. Check the project and host versions first, because several defaults and migrations are gated by system.stateVersion or home.stateVersion.

Reference index

| Reference | Topics | | --- | --- | | Core CLI, Evaluation, and Configuration | CLI behavior, evaluator rules, configuration, profiles, REPL, JSON formats, installers, and build execution | | Flakes and Fetchers | Inputs, lock files, Git features, registries, prefetching, archives, and flake checks | | Stores, Caches, and Remote Builds | GC roots, daemon stores, substituters, SSH, S3, HTTP, signing, retries, hooks, and build traces | | Native APIs and Source Builds | C and C++ API migrations, headers, plugins, and the Nix source build system | | NixOS System and Service Migrations | Rebuilds, boot, networking, storage, security, and service-module migrations | | Nixpkgs Packaging | Builder migrations, language ecosystems, hooks, library APIs, platforms, and package scopes | | Home Manager | Activation, profile ownership, state-gated defaults, module renames, XDG paths, and application configuration |

Start with compatibility gates

Before editing:

  1. Read nix --version and the pinned Nixpkgs or flake lock revision.
  2. Read system.stateVersion and home.stateVersion; do not raise either as a general upgrade step.
  3. Identify experimental features used by the configuration.
  4. Check whether automation consumes unstable JSON or human-readable output.
  5. For remote stores, inspect the exact store URI, authentication provider, signing configuration, and underlying cache ordering.
  6. For NixOS switches, inspect boot, initrd, storage, database, and secret migrations before activation.

Highest-impact breaking changes

Treat state versions as migration switches

New defaults for databases, Home Manager paths and formats, service data, and other modules can be state-version gated. Preserve existing state versions unless the operator deliberately performs every associated migration. A package-channel update and a state-version change are separate operations.

Use structured settings and current option names

Many NixOS and Home Manager modules replaced free-form configuration strings, flat options, or renamed modules with typed settings attributes. Remove old options rather than setting both old and new forms. Pay special attention to systemd manager, coredump, sleep, SSH, Postfix, rsyncd, Yggdrasil, firewall, and application-service modules.

Expect systemd in the initrd

Current NixOS uses systemd stage 1 by default. Use stable device paths for the root filesystem and LUKS mapping, review LVM-on-LUKS timeouts, and keep the scripted initrd only as a temporary compatibility measure.

Update packaging builders and hashes

Out-of-tree packages commonly need these migrations:

  • Rust packages use cargoHash and the stable vendoring path.
  • Go packages use buildGoModule; put CGO_ENABLED in env.
  • Python packages declare a modern build format and build system.
  • Node and Yarn packages use current top-level helpers and hooks.
  • pnpm packages use top-level dependency fetchers and regenerate current hashes.
  • buildEnv and derivations that need structured behavior use structured attributes.

Parse machine output by explicit schema

Pass an explicit JSON format to commands that offer one. Derivation JSON, path-info JSON, content addresses, signatures, store paths, and build traces have all gained structured or versioned representations. Never parse human-readable sizes as fixed MiB values, and do not assume terminal JSON is single-line.

Audit service data and secrets before switching

Database major versions, Nextcloud stepping, Immich vector extensions, TaskChampion and Stalwart directories, OAuth2 Proxy secrets, Grafana keys, Yggdrasil private keys, ACME dependencies, and PostgreSQL readiness semantics can require operator action. Keep secret values out of the Nix store and verify backup and rollback procedures first.

Common Nix CLI patterns

Profiles and copied paths

Use nix profile add for profile additions. When copying a path that must survive concurrent garbage collection, create its profile or output-link root as part of the copy operation.

nix profile add nixpkgs#hello
nix copy --from ssh://builder --out-link ./result "$path"

Stable JSON in automation

Force formatting behavior when terminal detection could vary, and select the document schema for versioned commands.

nix eval --json --no-pretty --expr '{ answer = 42; }'
nix path-info --json --json-format 3 "$path"

Evaluation diagnostics

Use stack sampling for performance investigations, IFD tracing for migration work, and JSON log mirroring for structured observability. Short and absolute path-literal checks are tri-state lints; choose warn during migration and fatal only after cleanup.

trace-import-from-derivation = true
lint-short-path-literals = warn
lint-absolute-path-literals = warn

Flake fetching

Declare submodule and LFS requirements on the flake where possible. Relative path inputs affect lock-file compatibility. Use parallel input prefetching when fetching unused inputs is acceptable, and use output links when a prefetched or checked result must be retained.

Store and cache safety

Configure complete substituter chains

An overlay cache must be listed with the cache that supplies its referenced closure. Incomplete substituted closures are no longer filled by mixing a partial substitution with local builds.

Make remote behavior explicit

SSH store URLs may include ports and bracketed IPv6 addresses; percent-encode IPv6 zone separators. Shell-style NIX_SSHOPTS parsing supports quoted proxy commands. For HTTPS or S3 stores, configure authentication, retry policy, compression, addressing style, and metadata lifetime deliberately.

Write concurrent-safe hooks

Post-build hooks may overlap up to max-jobs; dependent builds still wait for their own hook. Build hooks receive graceful termination, so handle SIGTERM and clean up temporary resources. Do not infer a derivation name from an opaque temporary build-directory name.

NixOS migration workflow

  1. Evaluate with warnings enabled and resolve removed or renamed options.
  2. Build without switching and inspect the resulting unit and boot changes.
  3. Check database and service-data migrations, secret paths, filesystem types, and initrd device paths.
  4. Use a test or boot activation only after rollback access is confirmed.
  5. Treat switch inhibitors as actionable checks; use NIXOS_NO_CHECK=1 only for an understood emergency override.
  6. Reboot when changing the D-Bus implementation or other changes that cannot be completed safely by a live switch.

Nixpkgs package review

For every package update:

  • Flatten nested build and runtime input lists.
  • Check for dangling or build-directory symlinks.
  • Keep env as an attribute set and use env.env for a variable literally named env.
  • Confirm meta.mainProgram, since it now affects the build environment.
  • Add explicit dependencies for split tools, metadata, modules, and wrapper outputs.
  • Re-run fixed-output hash discovery after changing language-specific dependency fetchers.
  • Check platform floors, toolchain defaults, filesystem feature requirements, and provider defaults rather than inheriting them accidentally.

Home Manager review

Do not invoke a generated activation script as if it owned profile updates. Use supported switch flows, choose legacy profile management only as a temporary bridge, and consider login-time activation for late-mounted homes. When raising home.stateVersion, audit application paths, generated formats, service integration, automatic updates, and renamed per-profile options.

Final verification

After a change:

  • Run evaluation and the narrowest relevant build or check.
  • Confirm lock-file changes are intentional and usable by deployment clients.
  • Verify store paths remain rooted for as long as needed.
  • Exercise parsers against the selected JSON schema.
  • Inspect generated systemd units and secret references.
  • Confirm hooks and cache clients behave under concurrency and authentication failures.
  • Keep rollback generations until stateful migrations are verified.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/nix-knowledge-patch-mt9mgmuv' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/nix-knowledge-patch-mt9mgmuv/download' --output '.skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md.part' && mv '.skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md.part' '.skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md' && test -s '.skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/nix-knowledge-patch' && cp -R '.skill-downloads/nix-knowledge-patch-mt9mgmuv' '.claude/skills/nix-knowledge-patch'

Cursor
test -f '.skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md' && test -s '.skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/nix-knowledge-patch' && cp -R '.skill-downloads/nix-knowledge-patch-mt9mgmuv' '.cursor/skills/nix-knowledge-patch'

Codex
test -f '.skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md' && test -s '.skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/nix-knowledge-patch' && cp -R '.skill-downloads/nix-knowledge-patch-mt9mgmuv' '.agents/skills/nix-knowledge-patch'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/nix-knowledge-patch-mt9mgmuv'

openskills read 'nix-knowledge-patch-mt9mgmuv'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/nix-knowledge-patch-mt9mgmuv/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires