Okular with custom poppler version

Hi,

I am trying to install Okular with custom poppler version. For that, I try to create nix shell with following shell.nix config:

{ pkgs ? import <nixpkgs> { } }:
with pkgs;
let
  inherit (pkgs) stdenv fetchurl which;
in
mkShell {
  buildInputs = [
    (poppler.overrideAttrs (old: {
      pname = "poppler";
      src = fetchurl {
        url = "https://poppler.freedesktop.org/poppler-23.05.0.tar.xz";
        sha256 = "sha256-OClN5xSevkWBkabm0OKDfafbqGg5AKY1JS9tDuI1+ZA=";
      };
    }))
    (okular.override { poppler = poppler; })
  ];
}

Unfortunately, the Okular compilation fails and I do not see poppler to be installed. Here is the relevant part of the error message:

-- The following REQUIRED packages have not been found:

 * Poppler (required version >= 0.86.0), A PDF rendering library, <https://poppler.freedesktop.org/>
   Support for PDF files in okular. You can make the dependency optional adding Poppler to the FORCE_NOT_REQUIRED_DEPENDENCIES cmake option

CMake Error at /nix/store/yryyq6r1l4plmq3f3w6r8max6452pfs0-cmake-3.24.3/share/cmake-3.24/Modules/FeatureSummary.cmake:464 (message):
  feature_summary() Error: REQUIRED package(s) are missing, aborting CMake
  run.
Call Stack (most recent call first):
  CMakeLists.txt:649 (feature_summary)

Could you tell me what do I do wrong?

There are two issues:

  • You are overriding poppler in the shell. But since Nix builds each package in a sandbox, okular will not see your changes.
  • In your okular.override, you are passing pkgs.poppler. But okular is injected dependencies by pkgs.libsForQt5.callPackage (or something), rather than pkgs.callPackage so it expects pkgs.libsForQt5.poppler given to it – see the following very convoluted call chain:

You should be able to override it using:

(okular.override { poppler = pkgs.libsForQt5.poppler.overrideAttrs (…); })

or better, by overriding the original arguments passed by callPackage:

(okular.override (args: { poppler = args.poppler.overrideAttrs (…); }))
2 Likes

This is my final shell.nix:

{ pkgs ? import <nixpkgs> { } }:
let
  popplerSrc = builtins.fetchTarball {
    url = "https://poppler.freedesktop.org/poppler-23.05.0.tar.xz";
    sha256 = "1rnghfd49l44fscsm1srjqiz3597vgz3n3d8saw105sxlfmzidk4";
  };
in
pkgs.mkShell {
  nativeBuildInputs = with pkgs; [
    (okular.override (args: {
      poppler = args.poppler.overrideAttrs
        (
          finalAttrs: previousAttrs: {
            src = popplerSrc;

            doCheck = false;
          }
        );
    }
    ))
  ];

  doCheck = false;
}