From 8e8b3fa1bb3aaabae1cf7fabd6e91e4f4300cb6d Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 29 Sep 2021 14:34:24 +0200 Subject: [PATCH] invalidateFetcherByDrvHash: Add self-check ... so it won't break when the fetcher doesn't use name correctly. --- pkgs/top-level/all-packages.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2865279cbddb..d28ff9fdb813 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -618,7 +618,15 @@ with pkgs; drvPath = (f args).drvPath; # It's safe to discard the context, because we don't access the path. salt = builtins.unsafeDiscardStringContext (lib.substring 0 12 (baseNameOf drvPath)); - in f (args // { name = "${args.name or "source"}-salted-${salt}"; }); + # New derivation incorporating the original drv hash in the name + salted = f (args // { name = "${args.name or "source"}-salted-${salt}"; }); + # Make sure we did change the derivation. If the fetcher ignores `name`, + # `invalidateFetcherByDrvHash` doesn't work. + checked = + if salted.drvPath == drvPath + then throw "invalidateFetcherByDrvHash: Adding the derivation hash to the fixed-output derivation name had no effect. Make sure the fetcher's name argument ends up in the derivation name. Otherwise, the fetcher will not be re-run when its implementation changes. This is important for testing." + else salted; + in checked; lazydocker = callPackage ../tools/misc/lazydocker { };