testers.invalidateFetcherByDrvHash: Move from top-level

main
Robert Hensing 2 years ago
parent 4bd62b75f7
commit c071530ca5
  1. 2
      pkgs/build-support/docker/examples.nix
  2. 6
      pkgs/build-support/fetchfirefoxaddon/tests.nix
  3. 6
      pkgs/build-support/fetchgit/tests.nix
  4. 8
      pkgs/build-support/fetchpatch/tests.nix
  5. 8
      pkgs/build-support/node/fetch-yarn-deps/tests/default.nix
  6. 18
      pkgs/build-support/testers/default.nix
  7. 1
      pkgs/top-level/aliases.nix
  8. 17
      pkgs/top-level/all-packages.nix

@ -97,7 +97,7 @@ rec {
};
# Same example, but re-fetches every time the fetcher implementation changes.
# NOTE: Only use this for testing, or you'd be wasting a lot of time, network and space.
testNixFromDockerHub = pkgs.invalidateFetcherByDrvHash pullImage {
testNixFromDockerHub = pkgs.testers.invalidateFetcherByDrvHash pullImage {
imageName = "nixos/nix";
imageDigest = "sha256:85299d86263a3059cf19f419f9d286cc9f06d3c13146a8ebbb21b3437f598357";
sha256 = "19fw0n3wmddahzr20mhdqv6jkjn1kanh6n2mrr08ai53dr8ph5n7";

@ -1,7 +1,7 @@
{ invalidateFetcherByDrvHash, fetchFirefoxAddon, fetchurl, ... }:
{ testers, fetchFirefoxAddon, fetchurl, ... }:
{
simple = invalidateFetcherByDrvHash fetchFirefoxAddon {
simple = testers.invalidateFetcherByDrvHash fetchFirefoxAddon {
name = "image-search-options";
# Chosen because its only 147KB
url = "https://addons.mozilla.org/firefox/downloads/file/3059971/image_search_options-3.0.12-fx.xpi";
@ -14,7 +14,7 @@
sha256 = "sha256-H73YWX/DKxvhEwKpWOo7orAQ7c/rQywpljeyxYxv0Gg=";
};
in
invalidateFetcherByDrvHash fetchFirefoxAddon {
testers.invalidateFetcherByDrvHash fetchFirefoxAddon {
name = "image-search-options";
src = image-search-options;
};

@ -1,14 +1,14 @@
{ invalidateFetcherByDrvHash, fetchgit, ... }:
{ testers, fetchgit, ... }:
{
simple = invalidateFetcherByDrvHash fetchgit {
simple = testers.invalidateFetcherByDrvHash fetchgit {
name = "nix-source";
url = "https://github.com/NixOS/nix";
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
sha256 = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY=";
};
sparseCheckout = invalidateFetcherByDrvHash fetchgit {
sparseCheckout = testers.invalidateFetcherByDrvHash fetchgit {
name = "nix-source";
url = "https://github.com/NixOS/nix";
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";

@ -1,18 +1,18 @@
{ invalidateFetcherByDrvHash, fetchpatch, ... }:
{ testers, fetchpatch, ... }:
{
simple = invalidateFetcherByDrvHash fetchpatch {
simple = testers.invalidateFetcherByDrvHash fetchpatch {
url = "https://github.com/facebook/zstd/pull/2724/commits/e1f85dbca3a0ed5ef06c8396912a0914db8dea6a.patch";
sha256 = "sha256-PuYAqnJWAE+L9bsroOnnBGJhERW8LHrGSLtIEkKU9vg=";
};
relative = invalidateFetcherByDrvHash fetchpatch {
relative = testers.invalidateFetcherByDrvHash fetchpatch {
url = "https://github.com/boostorg/math/commit/7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b.patch";
relative = "include";
sha256 = "sha256-KlmIbixcds6GyKYt1fx5BxDIrU7msrgDdYo9Va/KJR4=";
};
full = invalidateFetcherByDrvHash fetchpatch {
full = testers.invalidateFetcherByDrvHash fetchpatch {
url = "https://github.com/boostorg/math/commit/7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b.patch";
relative = "test";
stripLen = 1;

@ -1,15 +1,15 @@
{ invalidateFetcherByDrvHash, fetchYarnDeps, ... }:
{ testers, fetchYarnDeps, ... }:
{
simple = invalidateFetcherByDrvHash fetchYarnDeps {
simple = testers.invalidateFetcherByDrvHash fetchYarnDeps {
yarnLock = ./simple.lock;
sha256 = "sha256-Erdkw2E8wWT09jFNLXGkrdwKl0HuSZWnUDJUrV95vSE=";
};
gitDep = invalidateFetcherByDrvHash fetchYarnDeps {
gitDep = testers.invalidateFetcherByDrvHash fetchYarnDeps {
yarnLock = ./git.lock;
sha256 = "sha256-lAqN4LpoE+jgsQO1nDtuORwcVEO7ogEV53jCu2jFJUI=";
};
githubDep = invalidateFetcherByDrvHash fetchYarnDeps {
githubDep = testers.invalidateFetcherByDrvHash fetchYarnDeps {
yarnLock = ./github.lock;
sha256 = "sha256-Tsfgyjxz8x6gNmfN0xR7G/NQNoEs4svxRN/N+26vfJU=";
};

@ -15,4 +15,22 @@
echo "$output" >&2 && exit 1
fi
'';
# See doc/builders/testers.chapter.md or
# https://nixos.org/manual/nixpkgs/unstable/#tester-invalidateFetcherByDrvHash
invalidateFetcherByDrvHash = f: args:
let
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));
# 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;
}

@ -1278,6 +1278,7 @@ mapAliases ({
terraform_1_0_0 = throw "terraform_1_0_0 has been renamed to terraform_1"; # Added 2021-06-15
tesseract_4 = throw "'tesseract_4' has been renamed to/replaced by 'tesseract4'"; # Converted to throw 2022-02-22
testVersion = testers.testVersion; # Added 2022-04-20
invalidateFetcherByDrvHash = testers.invalidateFetcherByDrvHash; # Added 2022-05-05
tex-gyre-bonum-math = throw "'tex-gyre-bonum-math' has been renamed to/replaced by 'tex-gyre-math.bonum'"; # Converted to throw 2022-02-22
tex-gyre-pagella-math = throw "'tex-gyre-pagella-math' has been renamed to/replaced by 'tex-gyre-math.pagella'"; # Converted to throw 2022-02-22
tex-gyre-schola-math = throw "'tex-gyre-schola-math' has been renamed to/replaced by 'tex-gyre-math.schola'"; # Converted to throw 2022-02-22

@ -744,23 +744,6 @@ with pkgs;
installShellFiles = callPackage ../build-support/install-shell-files {};
# See doc/builders/testers.chapter.md or
# https://nixos.org/manual/nixpkgs/unstable/#tester-invalidateFetcherByDrvHash
invalidateFetcherByDrvHash = f: args:
let
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));
# 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 { };
ld-is-cc-hook = makeSetupHook { name = "ld-is-cc-hook"; }

Loading…
Cancel
Save