Skip to content

Commit 5f1e68b

Browse files
committed
Use stable zip hashes for plugin downloads
1 parent 9df3c82 commit 5f1e68b

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

flake.nix

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,26 @@
1818
outputs =
1919
inputs:
2020
inputs.flake-utils.lib.eachDefaultSystem (
21-
system: with import inputs.nixpkgs { inherit system; }; {
21+
system:
22+
with import inputs.nixpkgs { inherit system; };
23+
let
24+
# Fetch zips but take a stable hash of its contents, not the zip itself.
25+
# Sometimes zip files change.
26+
fetchStableZip =
27+
{ url, hash }:
28+
let
29+
unpacked = pkgs.fetchzip {
30+
inherit url hash;
31+
recursiveHash = true;
32+
stripRoot = false;
33+
};
34+
in
35+
pkgs.runCommand ((lib.nameFromURL url ".zip") + ".zip") { buildInputs = [ pkgs.zip ]; } ''
36+
cd ${unpacked}
37+
zip -r $out .
38+
'';
39+
in
40+
{
2241
devShells.default = pkgs.mkShell {
2342
buildInputs = with pkgs; [
2443
fd
@@ -39,18 +58,18 @@
3958
'';
4059
};
4160
packages = {
42-
litespeed-cache = fetchurl {
61+
litespeed-cache = fetchStableZip {
4362
url = "https://downloads.wordpress.org/plugin/litespeed-cache.7.6.2.zip";
44-
hash = "sha256-BVkpCYn+4+8z5QLnmeFsVS5zHWo/aG4eWmTC5mdxgnk=";
63+
hash = "sha256-AduSCRqawoBvb0kVBDiM90mZ9naLhUcbPt3kcHoqlKU=";
4564
};
46-
redis-cache = fetchurl {
65+
redis-cache = fetchStableZip {
4766
url = "https://downloads.wordpress.org/plugin/redis-cache.2.7.0.zip";
48-
hash = "sha256-DLxB3qNRaIaTuOfbEWW12StsjvcjGsD/Wr7HuD1ixjU=";
67+
hash = "sha256-+BlAD31TBABJOeFvF7j7uelFO8nYfIkoKyhtIk38KpE=";
4968
};
5069
snapcache = inputs.snapcache.packages.${system}.pluginWpOrg;
51-
wp-redis = fetchurl {
70+
wp-redis = fetchStableZip {
5271
url = "https://downloads.wordpress.org/plugin/wp-redis.1.4.6.zip";
53-
hash = "sha256-Cuw8ofc215EUMnVRVBxfwWxIg22cx8zKuJDgiKkZvLc=";
72+
hash = "sha256-bB2xEF+w7o6mb1OzBPJPfnR1EFNNBfT/MkV6l0MrtA8=";
5473
};
5574
};
5675
}

0 commit comments

Comments
 (0)