mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 19:55:41 +03:00
pdfium-binaries: refactor (#409245)
This commit is contained in:
commit
657d143faa
3 changed files with 54 additions and 32 deletions
|
@ -1,44 +1,52 @@
|
|||
{
|
||||
lib,
|
||||
fetchzip,
|
||||
stdenv,
|
||||
fetchzip,
|
||||
python3Packages,
|
||||
withV8 ? false,
|
||||
}:
|
||||
let
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "pdfium-binaries";
|
||||
# also update rev of headers in python3Packages.pypdfium2
|
||||
version = "7087";
|
||||
|
||||
src =
|
||||
let
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
selectSystem = attrs: attrs.${system};
|
||||
suffix = selectSystem {
|
||||
selectSystem =
|
||||
attrs:
|
||||
attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
||||
system = selectSystem {
|
||||
x86_64-linux = "linux-x64";
|
||||
aarch64-linux = "linux-arm64";
|
||||
x86_64-darwin = "mac-x64";
|
||||
aarch64-darwin = "mac-arm64";
|
||||
};
|
||||
hash = selectSystem {
|
||||
x86_64-linux = "sha256-zn7QlTvChQa2mQCe5K+zEGVUtuD+l/jEtlKticrrSKg=";
|
||||
aarch64-linux = "sha256-080X72NNfKaanHeVtmxE/4uNV6Ue4f/1Mri/p3nOT8c=";
|
||||
x86_64-darwin = "sha256-XMStU0MN9ieCrLQnQL4/jKrNWxgQl9OtZHg9EmemPhU=";
|
||||
aarch64-darwin = "sha256-Q8R/p1hX6+JeVTFc6w7MC9GPNGqxlu6m+iawRIMndic=";
|
||||
};
|
||||
in
|
||||
fetchzip {
|
||||
url = "https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F${version}/pdfium-${suffix}.tgz";
|
||||
inherit hash;
|
||||
url = "https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F${finalAttrs.version}/pdfium${lib.optionalString withV8 "-v8"}-${system}.tgz";
|
||||
hash =
|
||||
if withV8 then
|
||||
selectSystem {
|
||||
x86_64-linux = "sha256-nKHXcBTEp165g18HLzaNGfKt8MtTYpKBGNgwIpSO0u4=";
|
||||
aarch64-linux = "sha256-wip/ry42aDbyGiwYSUX8koxDuf88BLGZAmMZE0s+fL0=";
|
||||
x86_64-darwin = "sha256-7pUMfNFgGqQ8Dnox57sHfrKKke+i8CGEma4tePJaTDA=";
|
||||
aarch64-darwin = "sha256-o59kmTNC4nSCFLfww3E+4iIYs2kQ30yyFaX9f2Za7os=";
|
||||
}
|
||||
else
|
||||
selectSystem {
|
||||
x86_64-linux = "sha256-zn7QlTvChQa2mQCe5K+zEGVUtuD+l/jEtlKticrrSKg=";
|
||||
aarch64-linux = "sha256-080X72NNfKaanHeVtmxE/4uNV6Ue4f/1Mri/p3nOT8c=";
|
||||
x86_64-darwin = "sha256-XMStU0MN9ieCrLQnQL4/jKrNWxgQl9OtZHg9EmemPhU=";
|
||||
aarch64-darwin = "sha256-Q8R/p1hX6+JeVTFc6w7MC9GPNGqxlu6m+iawRIMndic=";
|
||||
};
|
||||
stripRoot = false;
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "pdfium-binaries";
|
||||
inherit version src;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir $out
|
||||
cp -r ./ $out/
|
||||
cp -r . $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
@ -53,7 +61,10 @@ stdenv.mkDerivation {
|
|||
meta = {
|
||||
description = "Binary distribution of PDFium";
|
||||
homepage = "https://github.com/bblanchon/pdfium-binaries";
|
||||
license = with lib.licenses; [ asl20 ];
|
||||
license = with lib.licenses; [
|
||||
asl20
|
||||
mit
|
||||
];
|
||||
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
|
||||
maintainers = with lib.maintainers; [ ];
|
||||
platforms = [
|
||||
|
@ -63,4 +74,4 @@ stdenv.mkDerivation {
|
|||
"x86_64-darwin"
|
||||
];
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p bash nixVersions.latest curl coreutils jq common-updater-scripts
|
||||
#!nix-shell -i bash -p bash nix curl coreutils jq common-updater-scripts
|
||||
|
||||
set -eou pipefail
|
||||
|
||||
latestVersion=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/bblanchon/pdfium-binaries/releases/latest | jq -r '.tag_name | ltrimstr("chromium/")')
|
||||
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; pdfium-binaries.version" | tr -d '"')
|
||||
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; pdfium-binaries.version or (lib.getVersion pdfium-binaries)" | tr -d '"')
|
||||
|
||||
echo "latest version: $latestVersion"
|
||||
echo "current version: $currentVersion"
|
||||
|
@ -14,13 +14,22 @@ if [[ "$latestVersion" == "$currentVersion" ]]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
for i in \
|
||||
"x86_64-linux linux-x64" \
|
||||
"aarch64-linux linux-arm64" \
|
||||
"x86_64-darwin mac-x64" \
|
||||
"aarch64-darwin mac-arm64"; do
|
||||
set -- $i
|
||||
prefetch=$(nix-prefetch-url --unpack "https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F$latestVersion/pdfium-$2.tgz")
|
||||
hash=$(nix hash convert --hash-algo sha256 --to sri $prefetch)
|
||||
update-source-version pdfium-binaries $latestVersion $hash --system=$1 --ignore-same-version
|
||||
update-source-version pdfium-binaries $latestVersion || true
|
||||
|
||||
for system in \
|
||||
x86_64-linux \
|
||||
aarch64-linux \
|
||||
x86_64-darwin \
|
||||
aarch64-darwin; do
|
||||
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 '"')))
|
||||
update-source-version pdfium-binaries $latestVersion $hash --system=$system --ignore-same-version
|
||||
done
|
||||
|
||||
for system in \
|
||||
x86_64-linux \
|
||||
aarch64-linux \
|
||||
x86_64-darwin \
|
||||
aarch64-darwin; do
|
||||
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 '"')))
|
||||
update-source-version pdfium-binaries-v8 $latestVersion $hash --system=$system --ignore-same-version
|
||||
done
|
||||
|
|
|
@ -4144,6 +4144,8 @@ with pkgs;
|
|||
|
||||
pdfminer = with python3Packages; toPythonApplication pdfminer-six;
|
||||
|
||||
pdfium-binaries-v8 = pdfium-binaries.override { withV8 = true; };
|
||||
|
||||
pgsync = callPackage ../development/tools/database/pgsync { };
|
||||
|
||||
pdsh = callPackage ../tools/networking/pdsh {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue