Skip to content

Commit 7cb6c93

Browse files
author
emaryn
committed
pdfium-binaries: refactor
1 parent 1bc34e6 commit 7cb6c93

File tree

3 files changed

+54
-32
lines changed

3 files changed

+54
-32
lines changed
Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,52 @@
11
{
22
lib,
3-
fetchzip,
43
stdenv,
4+
fetchzip,
55
python3Packages,
6+
withV8 ? false,
67
}:
7-
let
8+
9+
stdenv.mkDerivation (finalAttrs: {
10+
pname = "pdfium-binaries";
811
# also update rev of headers in python3Packages.pypdfium2
912
version = "7087";
13+
1014
src =
1115
let
12-
inherit (stdenv.hostPlatform) system;
13-
selectSystem = attrs: attrs.${system};
14-
suffix = selectSystem {
16+
selectSystem =
17+
attrs:
18+
attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
19+
system = selectSystem {
1520
x86_64-linux = "linux-x64";
1621
aarch64-linux = "linux-arm64";
1722
x86_64-darwin = "mac-x64";
1823
aarch64-darwin = "mac-arm64";
1924
};
20-
hash = selectSystem {
21-
x86_64-linux = "sha256-zn7QlTvChQa2mQCe5K+zEGVUtuD+l/jEtlKticrrSKg=";
22-
aarch64-linux = "sha256-080X72NNfKaanHeVtmxE/4uNV6Ue4f/1Mri/p3nOT8c=";
23-
x86_64-darwin = "sha256-XMStU0MN9ieCrLQnQL4/jKrNWxgQl9OtZHg9EmemPhU=";
24-
aarch64-darwin = "sha256-Q8R/p1hX6+JeVTFc6w7MC9GPNGqxlu6m+iawRIMndic=";
25-
};
2625
in
2726
fetchzip {
28-
url = "https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F${version}/pdfium-${suffix}.tgz";
29-
inherit hash;
27+
url = "https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F${finalAttrs.version}/pdfium${lib.optionalString withV8 "-v8"}-${system}.tgz";
28+
hash =
29+
if withV8 then
30+
selectSystem {
31+
x86_64-linux = "sha256-nKHXcBTEp165g18HLzaNGfKt8MtTYpKBGNgwIpSO0u4=";
32+
aarch64-linux = "sha256-wip/ry42aDbyGiwYSUX8koxDuf88BLGZAmMZE0s+fL0=";
33+
x86_64-darwin = "sha256-7pUMfNFgGqQ8Dnox57sHfrKKke+i8CGEma4tePJaTDA=";
34+
aarch64-darwin = "sha256-o59kmTNC4nSCFLfww3E+4iIYs2kQ30yyFaX9f2Za7os=";
35+
}
36+
else
37+
selectSystem {
38+
x86_64-linux = "sha256-zn7QlTvChQa2mQCe5K+zEGVUtuD+l/jEtlKticrrSKg=";
39+
aarch64-linux = "sha256-080X72NNfKaanHeVtmxE/4uNV6Ue4f/1Mri/p3nOT8c=";
40+
x86_64-darwin = "sha256-XMStU0MN9ieCrLQnQL4/jKrNWxgQl9OtZHg9EmemPhU=";
41+
aarch64-darwin = "sha256-Q8R/p1hX6+JeVTFc6w7MC9GPNGqxlu6m+iawRIMndic=";
42+
};
3043
stripRoot = false;
3144
};
32-
in
33-
stdenv.mkDerivation {
34-
pname = "pdfium-binaries";
35-
inherit version src;
3645

3746
installPhase = ''
3847
runHook preInstall
3948
40-
mkdir $out
41-
cp -r ./ $out/
49+
cp -r . $out
4250
4351
runHook postInstall
4452
'';
@@ -53,7 +61,10 @@ stdenv.mkDerivation {
5361
meta = {
5462
description = "Binary distribution of PDFium";
5563
homepage = "https://github.com/bblanchon/pdfium-binaries";
56-
license = with lib.licenses; [ asl20 ];
64+
license = with lib.licenses; [
65+
asl20
66+
mit
67+
];
5768
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
5869
maintainers = with lib.maintainers; [ ];
5970
platforms = [
@@ -63,4 +74,4 @@ stdenv.mkDerivation {
6374
"x86_64-darwin"
6475
];
6576
};
66-
}
77+
})
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env nix-shell
2-
#!nix-shell -i bash -p bash nixVersions.latest curl coreutils jq common-updater-scripts
2+
#!nix-shell -i bash -p bash nix curl coreutils jq common-updater-scripts
33

44
set -eou pipefail
55

66
latestVersion=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/bblanchon/pdfium-binaries/releases/latest | jq -r '.tag_name | ltrimstr("chromium/")')
7-
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; pdfium-binaries.version" | tr -d '"')
7+
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; pdfium-binaries.version or (lib.getVersion pdfium-binaries)" | tr -d '"')
88

99
echo "latest version: $latestVersion"
1010
echo "current version: $currentVersion"
@@ -14,13 +14,22 @@ if [[ "$latestVersion" == "$currentVersion" ]]; then
1414
exit 0
1515
fi
1616

17-
for i in \
18-
"x86_64-linux linux-x64" \
19-
"aarch64-linux linux-arm64" \
20-
"x86_64-darwin mac-x64" \
21-
"aarch64-darwin mac-arm64"; do
22-
set -- $i
23-
prefetch=$(nix-prefetch-url --unpack "https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F$latestVersion/pdfium-$2.tgz")
24-
hash=$(nix hash convert --hash-algo sha256 --to sri $prefetch)
25-
update-source-version pdfium-binaries $latestVersion $hash --system=$1 --ignore-same-version
17+
update-source-version pdfium-binaries $latestVersion || true
18+
19+
for system in \
20+
x86_64-linux \
21+
aarch64-linux \
22+
x86_64-darwin \
23+
aarch64-darwin; do
24+
hash=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url --unpack $(nix-instantiate --eval -E "with import ./. {}; pdfium-binaries.src.url" --system "$system" | tr -d '"')))
25+
update-source-version pdfium-binaries $latestVersion $hash --system=$system --ignore-same-version
26+
done
27+
28+
for system in \
29+
x86_64-linux \
30+
aarch64-linux \
31+
x86_64-darwin \
32+
aarch64-darwin; do
33+
hash=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url --unpack $(nix-instantiate --eval -E "with import ./. {}; pdfium-binaries-v8.src.url" --system "$system" | tr -d '"')))
34+
update-source-version pdfium-binaries-v8 $latestVersion $hash --system=$system --ignore-same-version
2635
done

pkgs/top-level/all-packages.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4145,6 +4145,8 @@ with pkgs;
41454145

41464146
pdfminer = with python3Packages; toPythonApplication pdfminer-six;
41474147

4148+
pdfium-binaries-v8 = pdfium-binaries.override { withV8 = true; };
4149+
41484150
pgsync = callPackage ../development/tools/database/pgsync { };
41494151

41504152
pdsh = callPackage ../tools/networking/pdsh {

0 commit comments

Comments
 (0)