From 361b504079389cfd6f8cf3160da96b88cc5e5a69 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 14 Nov 2026 01:24:34 +0000 Subject: populate: tell whether a Git work tree drawn from changed by its commit Whether a derived copy of a flake or flake-input source needs to be made again depends on the sources it draws inputs from. For one that isn't in the store, the key had its hash, so every run read all of it, e.g. all of a nixpkgs work tree, .git included, which takes long even when nothing changed. For a Git work tree that Nix gets as git+file:, whose commit and tracked files are all Nix uses, the key has its commit instead, if no tracked file differs from it, which Git tells quickly. git_flake decides what Nix gets as git+file:, for resolve as well. Keys of copies drawing from such work trees change once, so those copies get made again on the first run, also after deploying with krops 1. rewrite-cache-git checks that such a copy gets made again for a new commit, but not for redeploying, nor for an untracked file. --- pkgs/populate/src/flake.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'pkgs/populate/src/flake.rs') diff --git a/pkgs/populate/src/flake.rs b/pkgs/populate/src/flake.rs index f992231..22b49e8 100644 --- a/pkgs/populate/src/flake.rs +++ b/pkgs/populate/src/flake.rs @@ -203,7 +203,8 @@ struct DerivedState<'a> { target_kind: &'a str, /// A line of sha256sum for each patch. patch_sums: &'a [String], - /// The hash of each source drawn from, or empty if it's in the store. + /// What tells whether each source drawn from changed: git and its + /// commit, its hash, or empty if it's in the store. hashes: &'a [String], } @@ -230,10 +231,11 @@ impl<'a> DerivedState<'a> { } } -/// The text whose hash is the key of a derived copy, like the shell -/// implementation computes it: the original's path, the spec, the patches' -/// sums, and, for a copy drawing inputs, nix flake lock's arguments and the -/// hashes of the sources drawn from that aren't in the store. +/// The text whose hash is the key of a derived copy: the original's path, +/// the spec, the patches' sums, and, for a copy drawing inputs, nix flake +/// lock's arguments and what tells whether the sources drawn from that +/// aren't in the store changed: the commit of a Git work tree that Nix gets +/// as git+file:, and else a hash of the source. fn key_text( original: &str, spec: &Value, @@ -535,7 +537,7 @@ impl<'a> Flakes<'a> { /// the patches, or what inputs get drawn from which sources changes, /// and others also if the sources they draw inputs from change. The /// key of a copy, in .populate/derived//key, is the hash of all - /// that. + /// that, see key_text. fn derive(&self, name: &str) -> Result<()> { let settings = &self.sources[name].settings; let materialize = bool_setting(settings, "materialize", false); -- cgit v1.3.1