<< All versions

Skill v1.0.0

currentAutomated scan100/100
codebam/hermes-skills/nixos-flake-maintenance
──Details
PublishedNovember 22, 2026 at 06:03 PM
Content Hashsha256:a2048a3634c92413...
Git SHA7ee252ca1d0c
──Files
Files (1 file, 12.0 KB)
SKILL.md12.0 KBactive
SKILL.md · 75 lines · 12.0 KB

name: nixos-flake-maintenance description: Use when fixing NixOS flake builds or trimming packages. version: 1.0.0 author: Hermes Agent license: MIT metadata: hermes: tags: [nixos, nix, flake, build-failure, dependency-triage] related_skills: [nixos-flake-verify-in-sandbox, nixos-remote-host-updates]


NixOS flake maintenance (codebam/nixos)

Repo: /persistent/etc/nixos. Hosts: nixos-desktop, nixos-laptop, nixos-steamdeck, plus homeConfigurations."droid@debian". Shared config lives in home/ and modules/; per-host dirs sit at the top level.

When to Use

  • A nixos-rebuild / flake build fails and the failing derivation is not one the user wrote — trace who pulls it in and remove it. If the failing package is current nixpkgs and upstream itself broke it at the locked rev (a build flag newer/older than the source understands), it is a transient regression instead: pin-and-wait or a local override, never removal — see the update-regression procedure below.
  • Evaluation dies inside a flake input's own /nix/store/<hash>-source/nix/*.nix (lib.customisation.callPackageWith: Function called without required argument "<arg>", or a head-builtin trace whose derivations are home-manager-generation/home-manager-files). The missing argument is usually at the user's re-call of an upstream internal file, not upstream's fault — see the flake-input procedure below.
  • The user asks what a package is for, wants to stop depending on something, or wants a package added/changed in the config.

Standing preferences

  • When a package in the closure breaks its build, prefer REMOVING the dependency over repairing the broken package (no patches, overlays, or doCheck = false workarounds unless asked). Show where the package is used and what is lost, then remove it; only add a replacement binding or tool when the user asks.
  • One edit to a shared module (home/, shell-common.nix) covers all three hosts and the droid home config — make the change once, don't repeat it per host.

Procedure: stop depending on package X

  1. Find the consumers in nixpkgs:

np=$(nix eval --raw '.#nixosConfigurations.nixos-desktop.pkgs.path') grep -rln "<x>" "$np/pkgs/by-name" Then grep the config repo for each consumer name to see which are actually installed.

  1. Confirm the chain on the affected host:

nix why-depends --derivation '.#nixosConfigurations.<host>.config.system.build.toplevel' <consumer.drv> Check the override-variant pitfall before trusting a "does not depend" result.

  1. Remove the consumer: drop it from package lists, delete the config that uses it (tmux bindings pin binaries by ${pkgs.X} store path), fix comments that name it.
  2. Verify all three: grep -rn "<name>" . --include='*.nix' returns nothing; nix why-depends --derivation ... says "does not depend" for the consumer and for X; the toplevel still evaluates (a successful why-depends run re-evaluates it, which proves eval).

Procedure: failure inside a nixpkgs-packaged tool (update regression)

Symptom: after nix flake update, something the user did not write (Lix itself, a language runtime) starts failing mid-build in a configure-style phase, while the previous rev built. Recipe file: references/nixpkgs-regression-triage.md.

  1. Read the package expression in the LOCKED nixpkgs, not the error text: np=$(nix eval --raw '.#nixosConfigurations.<host>.pkgs.path' 2>/dev/null). Versioned package sets (lixPackageSets, …) share ONE expression across every version, so a flag added for the newest version can break every older pinned one.
  2. Diff that file between the old and new locked revs via raw.githubusercontent.com/NixOS/nixpkgs/<rev>/<pkgs/path>. Classic culprit: a build flag the newest source version declares and older ones do not — meson hard-errors on an unknown -D option, it does not warn.
  3. Confirm the option/attribute exists (or not) in the upstream source at the pinned tag before asserting anything about it — fetch the source's own option file, don't reason from memory.
  4. Never say "the fix is upstream, just update again" from master alone: fetch the file at the branch the flake actually tracks (.../nixpkgs/nixos-unstable/<path>). nixos-unstable can lag master by days or sit on the broken rev. State the branch head you observed and the time you observed it (the user audits present-tense claims).
  5. If the tracked branch is still broken, offer the local scope-level override and verify by evaluation first: the unpatched attr's .drvPath must equal the drv in the user's failure output (that proves you reproduced their failure), and the patched one must drop the offending flag. Then ask Nix what it would do: nix build --dry-run --impure --expr '<flake attr>' — "will be fetched" means the minimal override reproduced the exact drv upstream's fix produces and the cache already has it, so fetch it and run the binary instead of building; "will be built" means a real build is still the only proof.

Consumers inside a versioned set take the package from the scope (self.lix), so overriding only nix.package still leaves nix-eval-jobs/colmena pulling the broken derivation — override the whole scope AND repoint pkgs.lixPackageSets at the patched instance so anything else reading the set gets it too (committed shape in modules/lix.nix; full template in the recipe file). Construct the patched scope from prev inside the overlay: an overlay that redefines pkgs.lixPackageSets cannot build it from pkgs — that is a self-reference.

User's pin: modules/lix.nix sets nix.package = pkgs.lixPackageSets.latest.lix and inherits nixpkgs-review, nix-eval-jobs, nix-fast-build, colmena from the same scope, so a nixpkgs regression in the lix scope lands on every host.

Procedure: evaluation dies inside a flake input's own nix/ file

Symptom: evaluation aborts in a /nix/store/<hash>-source/nix/<file>.nix the user did not write, with a missing callPackage argument. The store path is only the input's source; the call that lacks the argument is normally in the user's own repo.

  1. Locate the caller before reading upstream. grep -rn "<file>.nix" --include='*.nix' . — a hand-rolled pkgs.callPackage "${inputs.<input>}/nix/<file>.nix" { ... } is the failing call, and it is the one that must gain the argument or go.
  2. Read the function's argument list and upstream's own call site in the pinned source: grep -n "<arg>\|<file>.nix" /nix/store/<hash>-source/nix/*.nix. Upstream computes the argument in a let binding of its package expression and passes it explicitly (<arg> = callPackage ./<argfile>.nix { ... }; then inherit ... <arg>;). pkgs.callPackage resolves only package-set attributes, so those local bindings are unreachable by a re-call — do not add them to pkgs and do not rebuild the chain by hand first.
  3. Ask whether the re-call's reason still exists before repairing it. A local callPackage of upstream internals is a workaround for an upstream defect (a pinned fetchurl/hash, an unfree dep, a missing flag). Grep the new upstream file for the mechanism it patched: no fetchurl / artifacts.<vendor> / --nodedir=${pinned path} left means upstream absorbed the fix. Then the correct change is deleting the override, not teaching a dead workaround the new argument.
  4. Prefer the module's passthru default. The option description names it: programs.<x>.desktop.package defaults to config.programs.<x>.package.<passthruName>. It is a callPackage result, so the module's own .override { extraEnv; extraRun; } still applies and the launcher environment is unchanged. Delete package = <localOverride>; plus the let bindings that existed only for it, then re-grep: only comments may still name the upstream file.
  5. Verify the phase that failed, then the wiring. nix eval --raw '.#nixosConfigurations.<host>.config.system.build.toplevel.drvPath' must succeed (that is the eval gate; ~40 s on the desktop host). Then nix eval --raw '.#nixosConfigurations.<host>.config.home-manager.users.<user>.programs.<x>.desktop.package.drvPath' and prove the new argument reached the build: nix-store -q --references <drv> | grep -iE '<arg-dep>|electron'. nix build --dry-run on that attr shows the real rebuild cost — a package bump legitimately rebuilds its venv and renderer closure (hundreds of derivations is normal, not a symptom).
  6. If the re-call genuinely must stay, take the argument from the passthru upstream already exposes — pkgs.callPackage "${inputs.<input>}/nix/<argfile>.nix" { venv = pkg.passthru.<venvAttr>; } — and pass the passthru attr; never reconstruct the internal let-binding chain.

Pitfalls

  • A package built via .override (e.g. foo.override { buildGoModule = buildGo127Module; }) is a different derivation than pkgs.foo.drvPath, so nix why-depends against the un-overridden drv reports "does not depend" while the variant IS in the closure. Get ground truth with nix-store -q --references <consumer.drv> | grep <name>, then run why-depends against the drv that reference returns.
  • Capture nix eval --raw output with 2>/dev/null — flake "fetching git input"/"tree is dirty" noise mixed into $(...) poisons the variable and the next command fails with "is not a valid URL".
  • pkgs.callPackage "${inputs.X}/nix/file.nix" against a flake input's INTERNAL expression is coupled to that file's argument list, which upstream changes without notice: a bump that adds a required argument fails evaluation with callPackageWith: Function called without required argument "arg" at that file. Only re-call an input's internals while there is a specific interception to make (e.g. a pinned fetchurl), and drop the re-call as soon as upstream removes the reason — use the input's packages.*.default.passthru.<attr> otherwise. When the input's module offers the attr as an option default (hermes-agent: programs.hermes-agent.desktop.package = package.hermesDesktop), deleting the local override is the whole fix.
  • The module re-overrides the desktop package with extraEnv/extraRun, so the built output is a DIFFERENT drv than desktop.package's; nix-store --check-validity on the un-overridden output reports invalid even after a successful build. Look in the home-manager generation's closure (nix-store -qR <toplevel> | grep hermes-desktop) for the real one.
  • Removing a package from the package list is not enough when config text references ${pkgs.X}/bin/... (tmux bindings do this deliberately to survive PATH changes); every reference must go or evaluation fails.
  • If terminal commands abort before running with a cd/permission error against the default cwd, pass workdir explicitly (the repo root) — the whole command dies before the real work runs, so a failed call proves nothing about the command itself.
  • Forcing a scope attr that modules/lix.nix aliases into top-level pkgs (pkgs.colmena, pkgs.nix-fast-build, pkgs.nixpkgs-review) hits infinite recursion inside nixpkgs' lix scope — the scope's wrappers read their deps back out of the package set that contains the alias. This recurses on committed HEAD too, so it is not caused by an override; nothing in the config references those attrs. pkgs.nix-eval-jobs is the one that forces cleanly — use it (plus nix.package) as the verification gate, and lab-diff against HEAD before blaming your own change for a recursion.
  • A flake input that tracks a branch (github:owner/repo/main) changes its internal nix/*.nix signatures on any nix flake update, including one the user did not make for that input. A hand-rolled callPackage of an input's internal file is therefore a standing breakage risk: prefer the module option/passthru, and re-read the file's argument list at every lock bump that touches nix/.
  • The trace names the input's store source, not the repo that owns the failing call. Read the store file for the signature, but grep the user's repo for the call site before concluding upstream broke — blaming upstream sends the fix to the wrong file, and a missing argument defined in upstream's own let block can never arrive through callPackage anyway.
All versions