aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/populate/src/flake.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-14 01:24:34 +0000
committertv <tv@krebsco.de>2026-11-14 02:45:43 +0100
commit361b504079389cfd6f8cf3160da96b88cc5e5a69 (patch)
treea74d65e8365b9244211057aaeac144de83bae546 /pkgs/populate/src/flake.rs
parente4991d754160dd851b980f142e4b9a23815eafa3 (diff)
populate: tell whether a Git work tree drawn from changed by its commitHEADmaster
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.
Diffstat (limited to 'pkgs/populate/src/flake.rs')
-rw-r--r--pkgs/populate/src/flake.rs14
1 files changed, 8 insertions, 6 deletions
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/<name>/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);