nix-style

Enforces Nix code style rules and idioms for writing and reviewing Nix code.

Updated Aug 5, 2026
One-click install
npx skills add https://github.com/harivansh-afk/loom-index-e2e --skill nix-style-harivansh-afk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nix-style
Source: https://github.com/harivansh-afk/loom-index-e2e/tree/main/skills/nix/style
Command: npx skills add https://github.com/harivansh-afk/loom-index-e2e --skill nix-style-harivansh-afk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Nix codebases accumulate inconsistent patterns, deprecated APIs, and lint violations that slow review and break builds. This Skill provides a complete style checklist and the mechanical rules enforced by the repo's astlog lint so new Nix code passes review on the first attempt. ## Core Features & Use Cases - Design and idiom checklist: Guides new Nix code toward functional patterns, reuse of builtins and nixpkgs.lib, and reified structure over validation. - Lint rule reference: Documents the hard rules enforced by alejandra, Statix, Deadnix, and astlog, covering scope access, eval paths, deprecated APIs, derivations, types, hashes, licenses, and error handling. - Exception workflow: Explains how to suppress legitimate findings with # astlog-ignore: <rule> comments that name the reason. - Use Case: When a lint failure like prefer-sri-hash appears in CI, consult this Skill to learn the rule, the fix (move the hash to the SRI hash slot), and the documented exception path. ## Quick Start Review my new Nix derivation against the nix-style rules and fix any lint violations before I commit.

Frequently Asked Questions about nix-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix Nix lint failures from astlog or Statix?▼

Run the repo's pinned lint with `nix run .#lint` to reproduce the failure locally, then apply the rule's documented fix, such as replacing `with pkgs;` with `inherit (pkgs) ...`. Legitimate exceptions are suppressed inline with an `# astlog-ignore: <rule>` comment naming the reason.

What Nix style rules replace deprecated APIs like cargoSha256?▼

Deprecated hash attributes are replaced by current names: `cargoHash` or `cargoLock` for `cargoSha256`, `vendorHash` for `vendorSha256`, and `npmDepsHash` for `npmDepsSha256`. Hashes belong in the SRI `hash = "sha256-...="` slot, never a legacy `sha256` attribute.

Why is `with pkgs;` banned in Nix code?▼

The `with` keyword obscures where names come from and breaks static analysis, so lint rules reject `with pkgs;`, `with lib;`, and `with builtins;`. Use `inherit (pkgs) ...` or qualified references like `lib.foo` instead.

Can I use builtins.fetchurl instead of pkgs fetchers in Nix?▼

No, the style rules require `pkgs.*` fetchers such as `pkgs.fetchurl` instead of `builtins.fetch*`. The hash must use the SRI `hash` slot, and raw fetched artifact URLs must stay out of `flake.nix`.

How should mkDerivation self-reference work without rec?▼

Use the `finalAttrs:` argument pattern on `mkDerivation` instead of `rec { }` for self-reference. Every derivation must also set `strictDeps = true` and use `preFixup`/`postFixup` hooks rather than overriding `fixupPhase`.

When is an astlog-ignore suppression acceptable in Nix code?▼

Suppression is acceptable only for legitimate exceptions, such as a hex digest that must round-trip verbatim into `.cargo-checksum.json`. Place `# astlog-ignore: <rule>` on the finding's line or the line above with a comment naming the reason.