From 7e4597a38a29f66fd8bbc7415973caeaa9442bde Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 20 Nov 2026 02:33:17 +0000 Subject: populate: file sources' record setting, for provenance in the run record A consumer recording what a build used gets the commit of git sources, and the store paths of flake, flake-input, and derivation sources, but nothing for file sources, which often hold the configuration, taken from work trees on the deploying machine. Recording nothing about them stays the default, since they may hold secrets, whose hash could give them away. file sources' record setting, with flags that default to false, adds to the source's entry in the record: - commit: if path is in a Git work tree, the commit HEAD names, and dirty, whether git status lists anything in path. Git runs on the deploying machine, without hooks, file system monitors, and writing the index, on every run, which is cheap: a new commit can change HEAD without changing any file. - digest: what nix-hash --type sha256 --sri prints for the target path, after the flakes step, which may have rewritten its lock file. That takes reading all of it, so populate only computes it if the source changed since the last record, and else takes it from that record, which the command taking the lock prints, so a run that changes nothing reads nothing more. The record's format stays version 0: the fields are optional additions. The README documents that the record tells what populate delivered, which something changing the target directory meanwhile would make it miss, and how rsync can leave out much of what Git ignores, with :- .gitignore in a .rsync-filter file, and what that misses. record-file checks the commit, dirty, and the digest, also taken from the last record. --- pkgs/populate/README.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'pkgs/populate/README.md') diff --git a/pkgs/populate/README.md b/pkgs/populate/README.md index a947c60..6ceb610 100644 --- a/pkgs/populate/README.md +++ b/pkgs/populate/README.md @@ -254,7 +254,12 @@ the record of the run, which a systemd path unit can watch, e.g.: - What got delivered: `commit` for `git` sources, `storePath` for `flake`, `flake-input`, and `derivation` sources, `derived` for `flake` and `flake-input` sources whose copy got patched or got its lock file - rewritten, and `target` for `symlink` sources. + rewritten, and `target` for `symlink` sources. A `file` source's `record` + setting can add `commit`, `dirty`, and `digest`. + +The record tells what populate delivered, which is what's there unless +something else changed the target directory meanwhile, which populate +doesn't notice. The lock ends with the command holding it, which ends with populate, or with the ssh connection, which keepalives end a minute after the target @@ -322,6 +327,30 @@ Supported attributes: the target path of a local target; with `false`, rsync syncs without them. Both print a warning. Older versions of rsync aren't affected. +* `record` (optional) - + what the [run record](#the-run-record-and-the-lock) tells about what got + delivered, besides whether it changed, an attribute set of flags, which + default to `false`, so nothing about a source that may hold secrets gets + recorded unless asked for: + + * `commit`: if `path` is in a Git work tree, the commit `HEAD` names, as + `commit`, and whether `git status` lists anything in `path`, as + `dirty`: changes of tracked files, or untracked files that Git doesn't + ignore. Files that rsync's filters exclude, or that Git ignores but + rsync delivers, don't count, so `dirty` tells whether `path` is the + commit as Git sees it. Git runs on the deploying machine, without + hooks and file system monitors, on every run. + * `digest`: the hash of what's at the target path, after drawing inputs, + as `nix-hash --type sha256 --sri` prints it. Populate only computes it + when the source changed since the last record, which takes reading all + of it, and else takes it from that record. + + rsync can leave out what Git ignores, with `:- .gitignore` in a + `.rsync-filter` file in `path`, which reads the `.gitignore` files + therein as exclude patterns, though not exactly as Git does: rsync takes + a line `!` for clearing the patterns, not for including again, and it + doesn't read `.git/info/exclude`, or `core.excludesFile`. + * `inputs` (optional) - inputs of the flake in this source to draw from other sources, see [Flake inputs from sources](#flake-inputs-from-sources). -- cgit v1.3.1