lix/src
Maximilian Bosch c1c37f3200
flakes: throw an error if follows-declaration for an input is invalid
I recently got fairly confused why the following expression didn't have
any effect

    {
      description = "Foobar";
      inputs.sops-nix = {
        url = github:mic92/sops-nix;
        inputs.nixpkgs_22_05.follows = "nixpkgs";
      };
    }

until I found out that the input was called `nixpkgs-22_05` (please note
the dash vs. underscore).

IMHO it's not a good idea to not throw an error in that case and
probably leave end-users rather confused, so I implemented a small check
for that which basically checks whether `follows`-declaration from
overrides actually have corresponding inputs in the transitive flake.

In fact this was done by accident already in our own test-suite where
the removal of a `follows` was apparently forgotten[1].

Since the key of the `std::map` that holds the `overrides` is a vector
and we have to find the last element of each vector (i.e. the override)
this has to be done with a for loop in O(n) complexity with `n` being
the total amount of overrides (which shouldn't be that large though).

Please note that this doesn't work with nested expressions, i.e.

    inputs.fenix.inputs.nixpkgs.follows = "...";

which is a known problem[2].

For the expression demonstrated above, an error like this will be
thrown:

    error: sops-nix has a `follows'-declaration for a non-existant input nixpkgs_22_05!

[1] 2664a216e5
[2] https://github.com/NixOS/nix/issues/5790
2022-07-12 10:18:38 +02:00
..
build-remote Generalize DerivationType in preparation for impure derivations 2022-03-18 14:59:56 +00:00
libcmd Merge pull request #6693 from ncfavier/complete-flake-inputs 2022-07-12 09:12:00 +02:00
libexpr flakes: throw an error if follows-declaration for an input is invalid 2022-07-12 10:18:38 +02:00
libfetchers fetchGit: document shallow argument 2022-06-26 12:00:00 +00:00
libmain Avoid fmt when constructor already does it 2022-04-19 01:44:11 +00:00
libstore Don't fail if we can't create ~/.local/share/nix/root 2022-06-29 12:16:51 +02:00
libutil Merge pull request #6693 from ncfavier/complete-flake-inputs 2022-07-12 09:12:00 +02:00
nix Merge pull request #6693 from ncfavier/complete-flake-inputs 2022-07-12 09:12:00 +02:00
nix-build nix-shell: restore backwards-compat with old nixpkgs 2022-06-13 23:29:28 +02:00
nix-channel Fix segfault in headerCallback() 2022-03-03 11:11:16 +01:00
nix-collect-garbage Add missing rethrows in conditional exception handlers 2022-06-10 10:52:41 -07:00
nix-copy-closure copyPaths: Pass store by reference 2021-07-22 09:59:51 +02:00
nix-env nix-env: A small std::move() optimization 2022-06-09 20:01:01 +05:30
nix-instantiate store Symbols in a table as well, like positions 2022-04-21 21:56:31 +02:00
nix-store nix-store: small std::move() optimization 2022-06-09 16:25:26 +05:30
resolve-system-dependencies Get rid of most .at calls (#6393) 2022-05-04 07:44:32 +02:00
toml11 Replace cpptoml with toml11 2021-12-17 22:03:33 +01:00