Is `inputs.*.inputs.nixpkgs.follows = "nixpkgs"` any useful?

From nix flake - Nix 2.28.6 Reference Manual :

Overrides and follows can be combined, e.g.

inputs.nixops.inputs.nixpkgs.follows = "dwarffs/nixpkgs";

sets the nixpkgs input of nixops to be the same as the nixpkgs input of dwarffs.

It is worth noting, however, that it is generally not useful to eliminate transitive nixpkgs flake inputs in this way. Most flakes provide their functionality through Nixpkgs overlays or NixOS modules, which are composed into the top-level flake’s nixpkgs input; so their own nixpkgs input is usually irrelevant.

I am skeptical about the bolded part above

Especially because I have an example proving otherwise:

Example

flake.nix

{
  inputs = {
    determinate.url = "github:DeterminateSystems/determinate";

    nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-25.05";
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";

    nixos-hardware.url = "github:NixOS/nixos-hardware/master";

    fh.url = "github:DeterminateSystems/fh";

    declarative-flatpak.url = "github:in-a-dil-emma/declarative-flatpak/v4.0.1";

    mcp-nixos.url = "github:utensils/mcp-nixos";

    l5p-keyboard-rgb.url = "github:4JX/L5P-Keyboard-RGB";
  };
}

nix flake metadata

[malix@nixos:~/Repositories/Malix_Labs/dotfiles/nix]$ nix flake metadata
Resolved URL:  git+file:///home/malix/Repositories/Malix_Labs/dotfiles?dir=nix
Locked URL:    git+file:///home/malix/Repositories/Malix_Labs/dotfiles?dir=nix&ref=refs/heads/main&rev=c74d1c09e269d9597ddaee6dca9e7b2a8da72f54
Revision:      c74d1c09e269d9597ddaee6dca9e7b2a8da72f54
Revisions:     33
Last modified: 2025-10-11 01:35:30
Fingerprint:   aed8ba4db3a4c7a9a43570e8cdddc866c7cfc28076f1e620092b1fdec4c41a70
Inputs:
├───declarative-flatpak: github:in-a-dil-emma/declarative-flatpak/bb69a3ffa6a03d907832fe9795abadd1b3635c5b?narHash=sha256-FaxAZGEZrKncKjV/5wy%2BXv6iP1fT1vGsoMQ994lAxAs%3D (2025-09-26 09:30:50)
├───determinate: github:DeterminateSystems/determinate/a3becf5149650592a821daeb2b63d26597506652?narHash=sha256-h/JQLcAfRNAo3QSobPxzTY/KxSwEmwmFJmUd5dGchQw%3D (2025-10-09 17:56:40)
│   ├───determinate-nixd-aarch64-darwin: https://install.determinate.systems/determinate-nixd/tag/v3.11.3/macOS?narHash=sha256-Nug8jpanW4BbUfzq508ZWtCG24YGvyO8AOeTAyDMOKQ%3D
│   ├───determinate-nixd-aarch64-linux: https://install.determinate.systems/determinate-nixd/tag/v3.11.3/aarch64-linux?narHash=sha256-kRAuNurPaJBhuOq1SpcCBmDOqCXvGDMKuMAb5vJRqtk%3D
│   ├───determinate-nixd-x86_64-darwin follows input 'determinate/determinate-nixd-aarch64-darwin'
│   ├───determinate-nixd-x86_64-linux: https://install.determinate.systems/determinate-nixd/tag/v3.11.3/x86_64-linux?narHash=sha256-7AF8O33I/xlMengDU6tHvmPVvXJZF7XQEdAbjfTPJ6s%3D
│   ├───nix: https://api.flakehub.com/f/pinned/DeterminateSystems/nix-src/3.11.3/0199c9f4-3aa1-723c-a5e0-be7fb957ff9f/source.tar.gz?narHash=sha256-1aMQb%2BeSrGDbTrX7PvtpD142CniIvKFxej9hZxBWeMY%3D (2025-10-09 16:32:07)
│   │   ├───flake-parts: https://api.flakehub.com/f/pinned/hercules-ci/flake-parts/0.1.377%2Brev-49f0870db23e8c1ca0b5259734a02cd9e1e371a1/01972f28-554a-73f8-91f4-d488cc502f08/source.tar.gz?narHash=sha256-F82%2BgS044J1APL0n4hH50GYdPRv/5JWm34oCJYmVKdE%3D (2025-06-01 23:38:36)
│   │   │   └───nixpkgs-lib follows input 'determinate/nix/nixpkgs'
│   │   ├───git-hooks-nix: https://api.flakehub.com/f/pinned/cachix/git-hooks.nix/0.1.1026%2Brev-80479b6ec16fefd9c1db3ea13aeb038c60530f46/0196d79a-1b35-7b8e-a021-c894fb62163d/source.tar.gz?narHash=sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo%2BbnXU9D9k%3D (2025-05-16 05:19:14)
│   │   │   ├───flake-compat: github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33?narHash=sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U%3D (2023-10-04 13:37:54)
│   │   │   ├───gitignore follows input 'determinate/nix'
│   │   │   └───nixpkgs follows input 'determinate/nix/nixpkgs'
│   │   ├───nixpkgs: https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2505.808723%2Brev-b1b3291469652d5a2edb0becc4ef0246fff97a7c/0198daf7-011a-7703-95d7-57146e794342/source.tar.gz?narHash=sha256-wY1%2B2JPH0ZZC4BQefoZw/k%2B3%2BDowFyfOxv17CN/idKs%3D (2025-08-23 04:07:17)
│   │   ├───nixpkgs-23-11: github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446?narHash=sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw%3D (2024-05-31 12:45:33)
│   │   └───nixpkgs-regression: github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2?narHash=sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw%3D (2022-01-24 19:20:45)
│   └───nixpkgs: https://api.flakehub.com/f/pinned/DeterminateSystems/nixpkgs-weekly/0.1.871443%2Brev-d7f52a7a640bc54c7bb414cca603835bf8dd4b10/0199bd2b-6c92-7223-94cf-69e43f5561ee/source.tar.gz?narHash=sha256-krgZxGAIIIKFJS%2BUB0l8do3sYUDWJc75M72tepmVMzE%3D (2025-10-05 02:43:53)
├───fh: github:DeterminateSystems/fh/3abaad486737b012e3ecef83e15b4c98b8293424?narHash=sha256-ZR%2BhcJxJLircUzOAhdmBp8%2B45c7SfY/f05/1M6bl1Ls%3D (2025-09-04 09:11:38)
│   ├───crane: https://api.flakehub.com/f/pinned/ipetkov/crane/0.21.0/019823c9-9d32-7d49-aa52-b8209fd297f7/source.tar.gz?narHash=sha256-g5uP3jIj%2BSTUcfTJDKYopxnSijs2agRg13H0SGL5iE4%3D (2025-07-19 17:39:13)
│   ├───fenix: https://api.flakehub.com/f/pinned/nix-community/fenix/0.1.2342%2Brev-451f184de2958f8e725acba046ec10670dd771a1/019864bb-9457-74e4-91eb-576a61bf0c54/source.tar.gz?narHash=sha256-EA7Qh5OUc3tgYrLHfG7zU6wxltvWsJ0%2BsFxOcVsbjOY%3D (2025-08-01 06:46:16)
│   │   ├───nixpkgs follows input 'fh/nixpkgs'
│   │   └───rust-analyzer-src: github:rust-lang/rust-analyzer/68e7ec90bf29c9b17d0dcdb3358de5dee7f4afb5?narHash=sha256-Ya4Ecj8JaKkapgYCCybzZBcypXpblhuG0hVDzdy2zyo%3D (2025-07-31 15:11:22)
│   └───nixpkgs: https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2505.808723%2Brev-b1b3291469652d5a2edb0becc4ef0246fff97a7c/0198daf7-011a-7703-95d7-57146e794342/source.tar.gz?narHash=sha256-wY1%2B2JPH0ZZC4BQefoZw/k%2B3%2BDowFyfOxv17CN/idKs%3D (2025-08-23 04:07:17)
├───l5p-keyboard-rgb: github:4JX/L5P-Keyboard-RGB/d72863419d080fd6437456b7f1534668263302fc?narHash=sha256-ehFTi9q4vT0Px0IUapD52C8814HdbdDasMQfweqUZks%3D (2025-07-21 14:55:55)
│   ├───crane: github:ipetkov/crane/544d09fecc8c2338542c57f3f742f1a0c8c71e13?narHash=sha256-g5uP3jIj%2BSTUcfTJDKYopxnSijs2agRg13H0SGL5iE4%3D (2025-07-19 17:39:13)
│   ├───flake-utils: github:numtide/flake-utils/11707dc2f618dd54ca8739b309ec4fc024de578b?narHash=sha256-l0KFg5HjrsfsO/JpG%2Br7fRrqm12kzFHyUHqHCVpMMbI%3D (2024-11-13 21:27:16)
│   │   └───systems: github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e?narHash=sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768%3D (2023-04-09 08:27:08)
│   ├───nixpkgs: github:NixOS/nixpkgs/6b4955211758ba47fac850c040a27f23b9b4008f?narHash=sha256-dPALCtmik9Wr14MGqVXm%2BOQcv7vhPBXcWNIOThGnB/Q%3D (2025-07-19 04:40:28)
│   └───rust-overlay: github:oxalica/rust-overlay/0751b65633a1785743ca44fd7c14a633c54c1f91?narHash=sha256-j2UBrfDRIePGx3532Bbb9UeosNX2F73hfOAHtmACfnM%3D (2025-07-21 02:50:49)
│       └───nixpkgs follows input 'l5p-keyboard-rgb/nixpkgs'
├───mcp-nixos: github:utensils/mcp-nixos/50b02bcba32b941d2ec48fedef68641702ca5b0f?narHash=sha256-mdlUFcrOfvT0Pm%2BHko/6aR3xf1ao5JA2iem4KsEVjP4%3D (2025-10-01 18:22:13)
│   ├───devshell: github:numtide/devshell/7c9e793ebe66bcba8292989a68c0419b737a22a0?narHash=sha256-kWNaq6wQUbUMlPgw8Y%2B9/9wP0F8SHkjy24/mN3UAppg%3D (2025-03-08 22:32:38)
│   │   └───nixpkgs: github:NixOS/nixpkgs/e36e9f57337d0ff0cf77aceb58af4c805472bfae?narHash=sha256-OpX0StkL8vpXyWOGUD6G%2BMA26wAXK6SpT94kLJXo6B4%3D (2024-07-27 09:52:18)
│   ├───flake-utils: github:numtide/flake-utils/11707dc2f618dd54ca8739b309ec4fc024de578b?narHash=sha256-l0KFg5HjrsfsO/JpG%2Br7fRrqm12kzFHyUHqHCVpMMbI%3D (2024-11-13 21:27:16)
│   │   └───systems: github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e?narHash=sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768%3D (2023-04-09 08:27:08)
│   └───nixpkgs: github:NixOS/nixpkgs/94def634a20494ee057c76998843c015909d6311?narHash=sha256-K2ViRJfdVGE8tpJejs8Qpvvejks1%2BA4GQej/lBk5y7I%3D (2025-07-31 05:30:45)
├───nixos-hardware: github:NixOS/nixos-hardware/9ed85f8afebf2b7478f25db0a98d0e782c0ed903?narHash=sha256-2GoxVaKWTHBxRoeUYSjv0AfSOx4qw5CWSFz2b%2BVolKU%3D (2025-10-10 14:30:35)
├───nixpkgs-stable: github:NixOS/nixpkgs/5da4a26309e796daa7ffca72df93dbe53b8164c7?narHash=sha256-wSK%2B3UkalDZRVHGCRikZ//CyZUJWDJkBDTQX1%2BG77Ow%3D (2025-10-09 07:19:42)
└───nixpkgs-unstable: github:NixOS/nixpkgs/0b4defa2584313f3b781240b29d61f6f9f7e0df3?narHash=sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw%3D (2025-10-09 19:42:10)

You can see there are a lot of different nixpkgs inputs in the different flakes dependencies

I am guessing the fact that my nixpkgs input is named nixpkgs-stable instead of nixpkgs or pkgs doesn’t make any difference, right?

So is it really true that

it is generally not useful to eliminate transitive nixpkgs flake inputs

?

What they meant was that changing the nixpkgs wouldn’t have an effect on the outputs themselves (if the outputs never needed that input in the first place). It will definitely have an impact on the amount of stuff the flake downloads to the store, as you’ve seen.

Generally I like to replace nixpkgs for everything, with exceptions being made when I know it’s unsafe.

2 Likes

I understand what you mean for sure but I also really struggle to derive that meaning from this paragraph:

It is worth noting, however, that it is generally not useful to eliminate transitive nixpkgs flake inputs in this way. Most flakes provide their functionality through Nixpkgs overlays or NixOS modules, which are composed into the top-level flake’s nixpkgs input; so their own nixpkgs input is usually irrelevant.

I think the current phrasing is quite misleading

Agreed. I’d argue opposite to that paragraph and say that it’s useful to eliminate transitive dependencies on nixpkgs and other notably large inputs whenever it’s safe to do.

Nixpkgs takes 40~ MB in the store, having multiple copies is so wasteful. If it can be avoided safely then imo it always should be.

4 Likes

Arguably, I don’t really know when it’s safe.

For example, some flakes inputs doesn’t state so, which includes fh

The only way to know is to read the code and see how the input is used.
IME if nixpkgs wasn’t needed, it wouldn’t be an input, so using follows will likely affect the outputs. I think that bit of the docs is simply incorrect.

Just expect additional cache misses (additional rebuilds) if you’re using some external cache, and if the external input depends on something in nixpkgs that doesn’t exist in the nixpkgs input that you provide to it, it will of course error.

There are plenty of flakes that use it for tests (since recursive flakes haven’t always existed), and others which just use it for a random devshell or something while exposing the actual functionality through overlays. nixpkgs inputs are really important for all kinds of things, but flakes are quite bad at expressing granular dependency requirements.

Not to detract from your point that it’s never safe unless you know exactly what the code does (which in theory also means you have to check every time you nix flake update), but often enough the nixpkgs input is actually effectively unused.

1 Like