From 333144080f4a03f1adc1eb7ded0a9d3ae1bfa9ee Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 12 Nov 2026 18:24:47 +0000 Subject: populate: draw inputs by rewriting lock files, add materialize and patches Sources drawing inputs from other sources get the lock file of their flake rewritten with nix flake lock --override-input, so the flake in the source itself uses the other sources, and needs no generated flake to be found. file and git sources get their lock file rewritten in place. flake and flake-input sources get delivered as a copy with the rewritten lock file, which gets added to the store with nix-store --add-fixed, and the target path links to that. With rewriteLock set to false, and for symlink sources, the source stays as it is and gets a generated flake in .populate/flakes/, which writeDeploy's flake parameter uses. flake and flake-input sources get two more options: - patches: patches on the deploying machine, which get uploaded to .populate/patches/ and applied in order with patch -p1 on the target, in the directory the target path shows. - materialize: the target path becomes a writable copy instead of a link into the store. Sources that get patched, rewritten, or materialized get delivered to .populate/derived//original, which also roots the delivered store path, and the flakes step derives the target path from there. Copies get made again only if what they derive from changes, which a key in .populate/derived/ records. The matrices of the file, flake, flake-input, and git tests cover both ways of drawing inputs, those of flake and flake-input materialize, the deploy test a source with a rewritten lock file, and features and edge cases run the scenarios drawing inputs both ways. New features cover patches, a patch that doesn't apply, patches in a subdirectory, reusing copies, and materializing. --- lib/types/populate.nix | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'lib/types') diff --git a/lib/types/populate.nix b/lib/types/populate.nix index 4523dad..a278ffd 100644 --- a/lib/types/populate.nix +++ b/lib/types/populate.nix @@ -125,6 +125,10 @@ path = lib.mkOption { type = lib.types.absolute-pathname; }; + rewriteLock = lib.mkOption { + default = true; + type = lib.types.bool; + }; useChecksum = lib.mkOption { default = false; type = lib.types.bool; @@ -185,6 +189,19 @@ default = {}; type = flake-inputs; }; + materialize = lib.mkOption { + default = false; + type = lib.types.bool; + }; + patches = lib.mkOption { + apply = map toString; + default = []; + type = lib.types.listOf lib.types.path; + }; + rewriteLock = lib.mkOption { + default = true; + type = lib.types.bool; + }; }; }; flake-input = lib.types.submodule { @@ -200,6 +217,19 @@ default = {}; type = flake-inputs; }; + materialize = lib.mkOption { + default = false; + type = lib.types.bool; + }; + patches = lib.mkOption { + apply = map toString; + default = []; + type = lib.types.listOf lib.types.path; + }; + rewriteLock = lib.mkOption { + default = true; + type = lib.types.bool; + }; name = lib.mkOption { type = lib.types.str; }; @@ -224,6 +254,10 @@ ref = lib.mkOption { type = lib.types.str; # TODO lib.types.git.ref }; + rewriteLock = lib.mkOption { + default = true; + type = lib.types.bool; + }; url = lib.mkOption { type = lib.types.str; # TODO lib.types.git.url }; -- cgit v1.3.1