aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-11 17:06:38 +0000
committertv <tv@krebsco.de>2026-11-11 17:06:38 +0000
commitc59f05ae0b5a789f36b57f5839cd22af608dbf3d (patch)
tree5fdc202170511ef6542b9ed1be57ed48e3e1c657 /README.md
parent55b99bfba969bdaba40e4a151531abe41ac83923 (diff)
populate: generate flakes for inputs drawn from sources
For each source that draws inputs from other sources, populate generates a flake in .populate/flakes/<name>, 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.
Diffstat (limited to 'README.md')
-rw-r--r--README.md64
1 files changed, 64 insertions, 0 deletions
diff --git a/README.md b/README.md
index b6e3401..39ed6cb 100644
--- a/README.md
+++ b/README.md
@@ -264,6 +264,10 @@ Supported attributes:
if they exist on the target. This is passed to the `--delete-excluded` option
of rsync. Defaults to `true`.
+* `inputs` (optional) -
+ inputs of the flake in this source to draw from other sources, see
+ [Flake inputs from sources](#flake-inputs-from-sources).
+
### `flake`
@@ -300,6 +304,10 @@ Supported attributes:
and Nix with flake support (Nix 2.4 or later) on the target. Defaults to
`false`.
+* `inputs` (optional) -
+ inputs of the flake in this source to draw from other sources, see
+ [Flake inputs from sources](#flake-inputs-from-sources).
+
Instead of an attribute set, the flake reference can be given as a string.
The flake commands on the deploying machine run using krops' own Nix, so
@@ -339,6 +347,10 @@ Supported attributes:
boolean that controls whether only the requested commit ref. should be fetched
instead of the whole history, to save disk space and bandwith. Defaults to `false`.
+* `inputs` (optional) -
+ inputs of the flake in this source to draw from other sources, see
+ [Flake inputs from sources](#flake-inputs-from-sources).
+
### `pass`
@@ -397,6 +409,58 @@ Supported attributes:
* `target` -
Content of the symlink. This is typically a relative path.
+* `inputs` (optional) -
+ inputs of the flake in this source to draw from other sources, see
+ [Flake inputs from sources](#flake-inputs-from-sources).
+
+
+## Flake inputs from sources
+
+Sources of type `file`, `flake`, `git`, and `symlink` can declare which inputs
+of the flake they contain get drawn from other sources, in the style of
+`flake.nix`, where `follows` names a source instead of an input. This makes
+flakes on the target use what krops delivers there, much like `NIX_PATH` does
+for Nix expressions.
+
+```nix
+{
+ nixpkgs.flake = {
+ flake = toString ./.;
+ attribute = "nixpkgs";
+ };
+ crate2nix.flake = {
+ flake = "github:nix-community/crate2nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ myconf.file = {
+ path = toString ./.;
+ inputs = {
+ crate2nix.follows = "crate2nix";
+ stockholm.inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+}
+```
+
+For each source that draws inputs from other sources, populate generates a
+flake in `.populate/flakes/<name>`, which re-exports the outputs of the flake
+in the source, with those inputs drawn from the other sources. The source
+itself stays as it is, so `NIX_PATH` still refers to it. When a generated
+flake draws an input from a source that has a generated flake itself, it uses
+that one, so in the example above, myconf's crate2nix uses nixpkgs from the
+`nixpkgs` source as well. `writeDeploy`'s `flake` parameter uses a source's
+generated flake automatically.
+
+Sources in a Git work tree are referred to as `git+file:` (with submodules if
+there are any), all other sources as `path:`, with symlinks resolved.
+Generated flakes get locked on every run, so their lock files match the
+sources, and get removed once their sources no longer draw inputs from other
+sources. This requires Nix with flake support (Nix 2.4 or later) on the
+target. Populating fails if a source that draws inputs from other sources
+contains no `flake.nix`. Sources that inputs get drawn from don't need to be
+flakes, as long as the inputs drawing from them are declared with
+`flake = false`.
+
## References