bblanchon / pdfium-binaries

📰 Binary distribution of PDFium
789 stars 166 forks source link

[Feature] NixOS package distribution #160

Open DennisJensen95 opened 2 months ago

DennisJensen95 commented 2 months ago

Hey!

Thanks for your guys hard work!

It would be awesome if these packages were made available in NixOS packages as well so you could import them in your Nix flakes. Would be a supreme developer experience.

bblanchon commented 2 months ago

Hi @DennisJensen95,

Would you be able to prepare a pull request?

Best regards, Benoit

DennisJensen95 commented 2 months ago

I would like to, but I am a bit strained on time. I have made a few nix derivations that does install the binaries though. I will leave it here if anyone wants to pick it up, else i might come back later at a day where I have more time :)

{ stdenv, fetchurl }:

stdenv.mkDerivation {
  name = "pdfium-linux-x64  ";
  src = fetchurl {
    url = "https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F6309/pdfium-linux-x64.tgz";
    sha256 = "as+hRy1Mg5l8oEAOyDXY9crRHx2PRT0RQC+YEUD/ako=";
  };

  sourceRoot = "lib";

  # Assuming the tarball contains binaries and doesn't need building
  installPhase = ''
    mkdir -p $out/lib
    cp -r * $out/lib
  '';

  meta = {
    description = "PDFium library for linux x64";
    homepage = "https://github.com/bblanchon/pdfium-binaries";
  };
}

And for anyone interested, this is how i import it in my nix flake:

pdfiumPackageForSystem = system:
if system == "x86_64-linux" then "pdfium-linux-x64"
else if system == "aarch64-darwin" then "pdfium-mac-arm64"
else if system == "aarch64-linux" then "pdfium-linux-arm64"
else throw "Unsupported system: ${system}";

callPdfiumPackage = name: pkgs.callPackage (./nix/${name}.nix) { };
pdfium = callPdfiumPackage (pdfiumPackageForSystem system);

⚠️ DISCLAIMER

I am by no means, no nix expert. So this might not be the correct way to do things 😊