Skip to main content
  1. TIL/

Nix flakes silently duplicate nixpkgs

·1 min

When you compose Nix flakes, each input can silently pull in its own copy of nixpkgs unless you explicitly tell it to follow your top-level one.

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    some-flake.url = "github:someone/cool-flake";

    # without this, cool-flake brings its own nixpkgs
    some-flake.inputs.nixpkgs.follows = "nixpkgs";
  };
}

Without the follows line you end up with multiple full copies of nixpkgs in the Nix store. Gigabytes of duplication, slower rebuilds, bigger closures, and the classic “why is my /nix/store suddenly 30 GB bigger?” surprise.

This is the kind of thing that makes the difference between a flake that “works great” and one that “feels heavy.” If you’re publishing a flake meant for others to consume, documenting the follows pattern (or structuring your inputs so it’s obvious) saves every downstream user from hitting this silently.

Related