From c59f05ae0b5a789f36b57f5839cd22af608dbf3d Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 11 Nov 2026 17:06:38 +0000 Subject: populate: generate flakes for inputs drawn from sources For each source that draws inputs from other sources, populate generates a flake in .populate/flakes/, which re-exports the outputs of the source's flake with those inputs drawn from the other sources. The source itself stays as it is, so NIX_PATH still refers to it. Generated flakes refer to each other's generated flakes, so a source's own declarations apply wherever it gets drawn from, and get generated in dependency order. Evaluation fails for sources drawing inputs from missing sources, from themselves, or from each other. Generated flakes get locked on every run, and get removed once their sources no longer draw inputs from other sources. --- lib/types/populate.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/types') diff --git a/lib/types/populate.nix b/lib/types/populate.nix index 319a7ba..b1d4151 100644 --- a/lib/types/populate.nix +++ b/lib/types/populate.nix @@ -77,6 +77,21 @@ }; }); + # Inputs of the flake in a source that get drawn from other sources, in the + # style of flake.nix, e.g. { nixpkgs.follows = "nixpkgs"; }. + flake-inputs = lib.types.attrsOf (lib.types.submodule { + options = { + follows = lib.mkOption { + default = null; + type = lib.types.nullOr lib.types.str; # TODO lib.types.label + }; + inputs = lib.mkOption { + default = {}; + type = flake-inputs; + }; + }; + }); + filter = lib.types.submodule { options = { type = lib.mkOption { @@ -99,6 +114,10 @@ }; file = lib.types.submodule { options = { + inputs = lib.mkOption { + default = {}; + type = flake-inputs; + }; path = lib.mkOption { type = lib.types.absolute-pathname; }; @@ -172,6 +191,10 @@ type = lib.types.bool; default = false; }; + inputs = lib.mkOption { + default = {}; + type = flake-inputs; + }; ref = lib.mkOption { type = lib.types.str; # TODO lib.types.git.ref }; @@ -218,6 +241,10 @@ }; symlink = lib.types.submodule { options = { + inputs = lib.mkOption { + default = {}; + type = flake-inputs; + }; target = lib.mkOption { type = lib.types.pathname; # TODO relative-pathname }; -- cgit v1.3.1