Skip to content

Drop flake-parts: zero flake inputs via npins + haskell-flake standalone#627

Open
srid wants to merge 4 commits intomasterfrom
switch-to-npins
Open

Drop flake-parts: zero flake inputs via npins + haskell-flake standalone#627
srid wants to merge 4 commits intomasterfrom
switch-to-npins

Conversation

@srid
Copy link
Copy Markdown
Owner

@srid srid commented Mar 28, 2026

Zero flake inputs. All 13 flake inputs replaced with npins pins. flake-parts, nixos-unified, and fourmolu-nix dependencies eliminated entirely. Uses haskell-flake's new standalone evalHaskellProject API (srid/haskell-flake#495) and git-hooks.nix standalone run function. Fourmolu settings moved to fourmolu.yaml (read by fourmolu directly, no nix wrapper needed).

The flake.nix is now plain Nix — no module system, no framework. The exported flakeModule for downstream flake-parts consumers is unchanged.


Benchmarks (10 runs each, ~/.cache/nix nuked before every cold-cache run):

Commit 1 — move flake = false inputs to npins (13 → 5 inputs):

Command Cache master 5-input
nix develop -c echo cold 2.84s 2.88s
nix develop -c echo warm 0.17s 0.18s
nix run . -- --version cold 1.77s 1.79s
nix run . -- --version warm 0.14s 0.14s

No differenceflake = false inputs have near-zero resolution cost.

Commit 2 — move remaining inputs to npins (5 → 1 input, flake-parts only):

Command Cache master 1-input
nix develop -c echo cold 2.84s 3.30s
nix develop -c echo warm 0.17s 0.21s
nix run . -- --version cold 1.77s 2.08s
nix run . -- --version warm 0.14s 0.14s

Commit 3 — drop flake-parts, zero inputs, haskell-flake standalone:

Command Cache master 0-input
nix develop -c echo cold 2.84s 3.81s
nix develop -c echo warm 0.17s 0.19s
nix run . -- --version cold 1.77s 2.01s
nix run . -- --version warm 0.14s 0.14s

Observation: warm-cache performance is identical across all variants (~0.14-0.19s). Cold-cache is ~34% slower with zero inputs because npins uses builtins.fetchTarball which hash-checks each source even when nix-store-cached, whereas flake lock resolution skips this entirely. The ~2.8s cold-cache baseline on master is dominated by the flake-parts/haskell-flake module system evaluation, not input resolution.

Methodology: time nix develop -c echo done / time nix run . -- --version. Cold = rm -rf ~/.cache/nix before each run (nix store retained). Warm = consecutive runs. Medians of 10 runs reported.

Depends on srid/haskell-flake#495 for the standalone evalHaskellProject API.

Try it locally

nix run github:srid/emanote/switch-to-npins

srid added 2 commits March 28, 2026 10:20
Migrate 8 `flake = false` inputs (ema, lvar, heist-extra, unionmount,
commonmark-simple, commonmark-wikilink, git-hooks, emanote-template) to
npins. These source-only pins don't need the flake machinery and were
slowing down `nix run`, `nix develop`, etc. by requiring flake input
resolution.

The 5 actual flake module inputs (nixpkgs, flake-parts, haskell-flake,
fourmolu-nix, nixos-unified) remain as flake inputs.
Inline `sources` bindings in pre-commit.nix and toplevel.nix where they
were only used once. Mark npins/default.nix as linguist-generated in
.gitattributes.
@srid srid marked this pull request as ready for review March 28, 2026 14:33
srid added 2 commits March 28, 2026 10:52
Move nixpkgs, haskell-flake, fourmolu-nix to npins. Drop nixos-unified
entirely and call flake-parts mkFlake directly, replicating the
auto-discovery of modules under nix/modules/flake-parts/.

Flake inputs: 13 → 1 (flake-parts only).
Use haskell-flake's new standalone evalHaskellProject API (srid/haskell-flake#495)
to eliminate flake-parts entirely. All dependencies now come from npins.

flake.nix is now plain Nix with zero inputs — no module system overhead.
Fourmolu settings moved to fourmolu.yaml (read by fourmolu directly).
nixos-unified, flake-parts, and fourmolu-nix dependencies removed.

The exported flakeModule for downstream consumers remains unchanged.
@srid srid changed the title Replace non-flake inputs with npins Drop flake-parts: zero flake inputs via npins + haskell-flake standalone Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant