summary refs log tree commit diff
path: root/pkgs/applications/misc/zathura
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2022-02-05 02:35:39 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2022-02-05 19:27:24 +0100
commitc0bd479d7799b92370c61ad198654a4876c1769e (patch)
tree25c5bc8b9eaa99d68014963e73fad6be029600ce /pkgs/applications/misc/zathura
parentf1e012775f644bc09839efb8ff907fc05e2cf9d0 (diff)
downloadnixpkgs-c0bd479d7799b92370c61ad198654a4876c1769e.tar
nixpkgs-c0bd479d7799b92370c61ad198654a4876c1769e.tar.gz
nixpkgs-c0bd479d7799b92370c61ad198654a4876c1769e.tar.bz2
nixpkgs-c0bd479d7799b92370c61ad198654a4876c1769e.tar.lz
nixpkgs-c0bd479d7799b92370c61ad198654a4876c1769e.tar.xz
nixpkgs-c0bd479d7799b92370c61ad198654a4876c1769e.tar.zst
nixpkgs-c0bd479d7799b92370c61ad198654a4876c1769e.zip
zathura: improve overridability; set plugin dir through the environment
The current package setup has two issues:

* You can only access `pkgs.zathura` which is the "final" derivation,
  i.e. a wrapper. This is a problem if you want to apply a patch to
  `zathura(1)` in an overlay. To make this a bit easier, I decided to
  expose `zathuraPkgs` entirely and `zathura` is now
  `zathuraPkgs.zathuraWrapper`.

  With this change, patches can now be added like this:

  ```
  with import ./. {
    overlays = [
      (self: super: {
        zathura = super.zathura.override {
          zathura_core = super.zathuraPkgs.zathura_core.overrideAttrs (_: {
            patches = [
              ~/Projects/zathura/0001-Fix-remote-link-resolution-in-zathura.patch
            ];
          });
        };
      })
    ];
  };
  zathura
  ```

* As soon as you open another window in `zathura` from `zathura` (e.g.
  to follow a PDF-embedded link to another PDF), it currently fails
  because `--plugins-dir=` isn't passed along. This is because `zathura`
  uses `argv[0]`[1] to open another process and the GApps-wrapper inside
  `zathuraPkgs.zathura_core` does a `exec -a "$0"` which isn't the
  `bin/zathura` from the wrapper that appends `--plugins-dir=`:

  ```
  execve("/nix/var/nix/profiles/per-user/ma27/home-manager-140-link/home-path/bin/zathura", ["/nix/var/nix/profiles/per-user/ma27/home-manager-140-link/home-path/bin/zathura", "/home/ma27/Documents/Uni/Studium/Notepad/Aktuell/Index.pdf"], 0x7ffd7a4bf4b0 /* 108 vars */) = 0
  execve("/nix/store/2wjhxbgzcnn0qqdwqy0m01hw39dxwfmk-zathura-0.4.8-bin/bin/zathura", ["/nix/store/2wjhxbgzcnn0qqdwqy0m01hw39dxwfmk-zathura-0.4.8-bin/bin/zathura", "--plugins-dir=/nix/store/wcch63yzwykc9x5393dzjfdxsf80mrb8-zathura-with-plugins-0.4.8/lib/zathura", "/home/ma27/Documents/Uni/Studium/Notepad/Aktuell/Index.pdf"], 0x1442010 /* 107 vars */) = 0
  execve("/nix/store/2wjhxbgzcnn0qqdwqy0m01hw39dxwfmk-zathura-0.4.8-bin/bin/.zathura-wrapped", ["/nix/store/2wjhxbgzcnn0qqdwqy0m01hw39dxwfmk-zathura-0.4.8-bin/bin/zathura", "--plugins-dir=/nix/store/wcch63yzwykc9x5393dzjfdxsf80mrb8-zathura-with-plugins-0.4.8/lib/zathura", "/home/ma27/Documents/Uni/Studium/Notepad/Aktuell/Index.pdf"], 0x81d010 /* 108 vars */) = 0
  ```

  I figured it's way simpler to actually use the environment variable
  `ZATHURA_PLUGINS_PATH` for that purpose as the environment is
  inherited when a new process is started.

[1] https://git.pwmt.org/pwmt/zathura/-/blob/242329b534af9cf04b423bf1e4fa7a7f8bac9030/zathura/links.c#L205-215
Diffstat (limited to 'pkgs/applications/misc/zathura')
-rw-r--r--pkgs/applications/misc/zathura/default.nix2
-rw-r--r--pkgs/applications/misc/zathura/wrapper.nix2
2 files changed, 2 insertions, 2 deletions
diff --git a/pkgs/applications/misc/zathura/default.nix b/pkgs/applications/misc/zathura/default.nix
index 1548b0581b6..67fe3032d05 100644
--- a/pkgs/applications/misc/zathura/default.nix
+++ b/pkgs/applications/misc/zathura/default.nix
@@ -30,4 +30,4 @@ let
     };
   };
 
-in self.zathuraWrapper
+in self
diff --git a/pkgs/applications/misc/zathura/wrapper.nix b/pkgs/applications/misc/zathura/wrapper.nix
index ccbde19d2aa..60ff0bd6885 100644
--- a/pkgs/applications/misc/zathura/wrapper.nix
+++ b/pkgs/applications/misc/zathura/wrapper.nix
@@ -11,7 +11,7 @@ symlinkJoin {
   in ''
     makeWrapper ${zathura_core.bin}/bin/zathura $out/bin/zathura \
       --prefix PATH ":" "${lib.makeBinPath [ file ]}" \
-      --add-flags --plugins-dir="$out/lib/zathura"
+      --prefix ZATHURA_PLUGINS_PATH : "$out/lib/zathura"
 
     # zathura fish completion references the zathura_core derivation to
     # check for supported plugins which live in the wrapper derivation,