Files
lix/tests
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
..
2022-06-22 23:33:15 +02:00
2020-04-14 18:45:06 +02:00
2021-07-07 10:48:47 +02:00
2019-12-13 19:05:26 +01:00
2014-08-21 21:50:19 +02:00
2022-06-22 23:33:15 +02:00
2021-07-07 11:30:35 +02:00
2018-02-13 14:26:19 +00:00
2022-06-02 21:21:10 +02:00
2020-07-30 16:38:04 -05:00
2022-04-19 13:41:32 +02:00
2022-06-22 23:33:15 +02:00
2022-03-11 10:00:19 -05:00
2021-11-04 15:04:04 +01:00
2022-01-19 14:24:14 +01:00
2006-07-21 13:21:43 +00:00
2022-07-05 19:44:26 +03:00
2022-06-22 23:33:15 +02:00
2021-01-21 11:02:09 +01:00
2022-06-07 14:27:10 +02:00
2022-05-13 22:02:28 +02:00
2020-07-30 16:38:04 -05:00
2022-06-22 23:33:15 +02:00
2018-01-16 19:23:18 +01:00
2021-10-15 16:58:21 +02:00
2022-06-07 14:27:10 +02:00
2018-01-16 19:23:18 +01:00
2019-11-27 00:05:30 +01:00
2018-02-25 16:40:05 -06:00
2016-04-11 16:20:15 +02:00
2022-06-07 14:27:10 +02:00
2021-12-07 21:45:09 +01:00
2007-08-13 13:15:02 +00:00
2022-01-26 14:15:03 +01:00
2012-12-04 14:47:50 +01:00
2021-04-09 23:13:08 +02:00