A modern, delicious implementation of the Nix package manager, focused on correctness, usability, and growth — and committed to doing right by its community
Find a file
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
.github Fix the hydra_status CI job 2022-07-05 16:28:39 +02:00
config
contrib
doc/manual Branch 2.10 release notes 2022-07-11 21:10:23 +02:00
m4
maintainers
misc nix-daemon.service: sync LimitNOFILE with the nixos service 2022-05-19 21:16:07 +03:00
mk Fix incremental static builds 2022-06-22 17:53:58 +02:00
perl Remove std::string alias (for real this time) 2022-02-25 16:13:02 +01:00
scripts install-multi-user: check if selinux is enabled and if it is then abort 2022-06-10 05:12:03 +03:00
src flakes: throw an error if follows-declaration for an input is invalid 2022-07-12 10:18:38 +02:00
tests flakes: throw an error if follows-declaration for an input is invalid 2022-07-12 10:18:38 +02:00
.dir-locals.el
.editorconfig
.gitignore Add unit tests for libexpr (#5377) 2022-05-06 18:05:27 +02:00
.version Bump version 2022-05-30 21:11:20 +02:00
boehmgc-coroutine-sp-fallback.diff
bootstrap.sh
configure.ac Embed the sandbox shell into the statically linked 'nix' binary 2022-06-23 04:08:28 +02:00
COPYING
default.nix
docker.nix Allow specification of extra packages, maxLayers in Docker image 2022-07-01 17:53:14 -04:00
flake.lock flake: update to 22.05 2022-05-31 11:51:17 -07:00
flake.nix Fix buildStatic.aarch64-linux 2022-07-11 20:57:29 +02:00
local.mk
Makefile Merge branch 'master' into lto 2022-05-25 11:55:13 +00:00
Makefile.config.in Embed the sandbox shell into the statically linked 'nix' binary 2022-06-23 04:08:28 +02:00
precompiled-headers.h
README.md
shell.nix

Nix

Open Collective supporters Test

Nix is a powerful package manager for Linux and other Unix systems that makes package management reliable and reproducible. Please refer to the Nix manual for more details.

Installation

On Linux and macOS the easiest way to install Nix is to run the following shell command (as a user other than root):

$ curl -L https://nixos.org/nix/install | sh

Information on additional installation methods is available on the Nix download page.

Building And Developing

See our Hacking guide in our manual for instruction on how to build nix from source with nix-build or how to get a development environment.

Additional Resources

License

Nix is released under the LGPL v2.1.