nix-philosophy

Guides Nix flake design covering outputs, pure evaluation, and IFD boundaries.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing a Nix flake structure without clear principles leads to tangled flake.nix files, duplicated registries, impure evaluation, and slow evaluators. This Skill codifies the design philosophy for structuring flakes so outputs, packages, and workflows stay consistent and maintainable. ## Core Features & Use Cases - Flake Structure Guidance: Treats flake.nix as a manifest that delegates outputs to lib/, discovery, and package-specific files, using standard outputs like packages, checks, devShells, overlays, and nixosModules. - Data-Before-Commands Principle: Exposes aggregate knowledge as lib.<name> values inspectable via nix eval --json before wrapping them in CLI commands. - Purity and IFD Boundaries: Enforces pure evaluation, explicit Import From Derivation boundaries, batched discovery derivations, and checked command generation via lib.getExe. - Use Case: When adding a new workflow command to a Nix monorepo, use this Skill to decide whether it belongs as a package with meta.mainProgram, where versions and hashes should live, and how to validate it through checkPhase and passthru.tests. ## Quick Start Review my flake.nix and tell me how to restructure its outputs according to Nix design philosophy.

Frequently Asked Questions about nix-philosophy

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

FAQPage Schema
How do I structure a Nix flake.nix file?▼

Treat flake.nix as a manifest that exposes inputs and delegates outputs to lib/, discovery, and package-specific files. Use standard outputs such as packages, checks, formatter, devShells, templates, overlays, nixosModules, and lib.

What are standard Nix flake outputs?▼

Standard flake outputs include packages, checks, formatter, devShells, templates, overlays, nixosModules, and lib. A workflow command should be a package with meta.mainProgram so nix run and nix build target the same derivation.

When is Import From Derivation acceptable in Nix?▼

IFD is acceptable when another tool must reveal the real build graph. Keep the boundary explicit, expose the generated artifact, and batch discovery into one larger derivation when many tiny IFDs would serialize the evaluator.

Why does Nix flake evaluation fail on new files?▼

Nix source filtering and flakes only see tracked or staged source files. Stage new source files before running Nix validation so failures describe the expression under test instead of a missing path.

How do I keep Nix evaluation pure?▼

Flow inputs through flake.nix or typed parameters only. Avoid host environment reads, channel references, ad hoc flake paths, and eval-time network fetches.

Where should package tests live in a Nix flake?▼

Package invariants belong in the owning derivation through checkPhase, installCheckPhase, or passthru.tests. Keep flake checks as aggregation and policy gates, starting validation narrow and broadening as confidence grows.