about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/graphics/imv/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/graphics/imv/default.nix')
-rw-r--r--nixpkgs/pkgs/applications/graphics/imv/default.nix101
1 files changed, 71 insertions, 30 deletions
diff --git a/nixpkgs/pkgs/applications/graphics/imv/default.nix b/nixpkgs/pkgs/applications/graphics/imv/default.nix
index faf748730583..3f6a27cbc76a 100644
--- a/nixpkgs/pkgs/applications/graphics/imv/default.nix
+++ b/nixpkgs/pkgs/applications/graphics/imv/default.nix
@@ -1,66 +1,107 @@
-{ asciidoc
+{ stdenv
+, lib
+, fetchFromGitHub
+, asciidoc
 , cmocka
 , docbook_xsl
-, fetchFromGitHub
+, libxslt
 , fontconfig
-, freeimage
+, meson
+, ninja
+, pkg-config
 , icu
+, pango
+, inih
+, withWindowSystem ? "all"
+, xorg
+, libxkbcommon
 , libGLU
-, libheif
+, wayland
+, withBackends ? [ "freeimage" "libtiff" "libjpeg" "libpng" "librsvg" "libnsgif" "libheif" ]
+, freeimage
+, libtiff
 , libjpeg_turbo
 , libpng
 , librsvg
-, libtiff
-, libxkbcommon
-, libxslt
 , netsurf
-, pango
-, pkgconfig
-, stdenv
-, wayland
+, libheif
 }:
 
+let
+  windowSystems = {
+    all = windowSystems.x11 ++ windowSystems.wayland;
+    x11 = [ libGLU xorg.libxcb xorg.libX11 ];
+    wayland = [ wayland ];
+  };
+
+  backends = {
+    inherit freeimage libtiff libpng librsvg libheif;
+    libjpeg = libjpeg_turbo;
+    inherit (netsurf) libnsgif;
+  };
+
+  backendFlags = builtins.map
+    (b: if builtins.elem b withBackends
+        then "-D${b}=enabled"
+        else "-D${b}=disabled")
+    (builtins.attrNames backends);
+in
+
+# check that given window system is valid
+assert lib.assertOneOf "withWindowSystem" withWindowSystem
+  (builtins.attrNames windowSystems);
+# check that every given backend is valid
+assert builtins.all
+  (b: lib.assertOneOf "each backend" b (builtins.attrNames backends))
+  withBackends;
+
 stdenv.mkDerivation rec {
   pname = "imv";
-  version = "4.1.0";
+  version = "4.2.0";
 
   src = fetchFromGitHub {
     owner = "eXeC64";
     repo = "imv";
     rev = "v${version}";
-    sha256 = "0gk8g178i961nn3bls75a8qpv6wvfvav6hd9lxca1skaikd33zdx";
+    sha256 = "07pcpppmfvvj0czfvp1cyq03ha0jdj4whl13lzvw37q3vpxs5qqh";
   };
 
-  nativeBuildInputs = [ asciidoc cmocka docbook_xsl libxslt ];
+  mesonFlags = [
+    "-Dwindows=${withWindowSystem}"
+    "-Dtest=enabled"
+    "-Dman=enabled"
+  ] ++ backendFlags;
+
+  nativeBuildInputs = [
+    asciidoc
+    cmocka
+    docbook_xsl
+    libxslt
+    meson
+    ninja
+    pkg-config
+  ];
 
   buildInputs = [
-    freeimage
     icu
-    libGLU
-    libjpeg_turbo
-    librsvg
     libxkbcommon
-    netsurf.libnsgif
     pango
-    pkgconfig
-    wayland
-  ];
-
-  installFlags = [ "PREFIX=$(out)" "CONFIGPREFIX=$(out)/etc" ];
-
-  makeFlags = [ "BACKEND_LIBJPEG=yes" "BACKEND_LIBNSGIF=yes" ];
+    inih
+  ] ++ windowSystems."${withWindowSystem}"
+    ++ builtins.map (b: backends."${b}") withBackends;
 
-  postFixup = ''
+  postFixup = lib.optionalString (withWindowSystem == "all") ''
     # The `bin/imv` script assumes imv-wayland or imv-x11 in PATH,
     # so we have to fix those to the binaries we installed into the /nix/store
 
-    sed -i "s|\bimv-wayland\b|$out/bin/imv-wayland|" $out/bin/imv
-    sed -i "s|\bimv-x11\b|$out/bin/imv-x11|" $out/bin/imv
+    substituteInPlace "$out/bin/imv" \
+      --replace "imv-wayland" "$out/bin/imv-wayland" \
+      --replace "imv-x11" "$out/bin/imv-x11"
   '';
 
   doCheck = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "A command line image viewer for tiling window managers";
     homepage = "https://github.com/eXeC64/imv";
     license = licenses.gpl2;