python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / applications / graphics / imv / default.nix
blobf78a4f6068154665d82fbe3bd79f6bf6e7d95428
1 { stdenv
2 , lib
3 , fetchFromSourcehut
4 , asciidoc
5 , cmocka
6 , docbook_xsl
7 , libxslt
8 , meson
9 , ninja
10 , pkg-config
11 , icu
12 , pango
13 , inih
14 , withWindowSystem ? "all"
15 , xorg
16 , libxkbcommon
17 , libGLU
18 , wayland
19 , withBackends ? [ "freeimage" "libtiff" "libjpeg" "libpng" "librsvg" "libnsgif" "libheif" ]
20 , freeimage
21 , libtiff
22 , libjpeg_turbo
23 , libpng
24 , librsvg
25 , netsurf
26 , libheif
29 let
30   windowSystems = {
31     all = windowSystems.x11 ++ windowSystems.wayland;
32     x11 = [ libGLU xorg.libxcb xorg.libX11 ];
33     wayland = [ wayland ];
34   };
36   backends = {
37     inherit freeimage libtiff libpng librsvg libheif;
38     libjpeg = libjpeg_turbo;
39     inherit (netsurf) libnsgif;
40   };
42   backendFlags = builtins.map
43     (b: if builtins.elem b withBackends
44         then "-D${b}=enabled"
45         else "-D${b}=disabled")
46     (builtins.attrNames backends);
49 # check that given window system is valid
50 assert lib.assertOneOf "withWindowSystem" withWindowSystem
51   (builtins.attrNames windowSystems);
52 # check that every given backend is valid
53 assert builtins.all
54   (b: lib.assertOneOf "each backend" b (builtins.attrNames backends))
55   withBackends;
57 stdenv.mkDerivation rec {
58   pname = "imv";
59   version = "4.3.1";
60   outputs = [ "out" "man" ];
62   src = fetchFromSourcehut {
63     owner = "~exec64";
64     repo = "imv";
65     rev = "v${version}";
66     sha256 = "sha256-gMAd8skst72QT4jGFH7aRdWeAd4tf/uQgXhGaM/Dpgc=";
67   };
69   mesonFlags = [
70     "-Dwindows=${withWindowSystem}"
71     "-Dtest=enabled"
72     "-Dman=enabled"
73   ] ++ backendFlags;
75   nativeBuildInputs = [
76     asciidoc
77     cmocka
78     docbook_xsl
79     libxslt
80     meson
81     ninja
82     pkg-config
83   ];
85   buildInputs = [
86     icu
87     libxkbcommon
88     pango
89     inih
90   ] ++ windowSystems."${withWindowSystem}"
91     ++ builtins.map (b: backends."${b}") withBackends;
93   postInstall = ''
94     # fix the executable path and install the desktop item
95     substituteInPlace ../files/imv.desktop --replace "imv %F" "$out/bin/imv %F"
96     install -Dm644 ../files/imv.desktop $out/share/applications/
97   '';
99   postFixup = lib.optionalString (withWindowSystem == "all") ''
100     # The `bin/imv` script assumes imv-wayland or imv-x11 in PATH,
101     # so we have to fix those to the binaries we installed into the /nix/store
103     substituteInPlace "$out/bin/imv" \
104       --replace "imv-wayland" "$out/bin/imv-wayland" \
105       --replace "imv-x11" "$out/bin/imv-x11"
106   '';
108   doCheck = true;
110   meta = with lib; {
111     description = "A command line image viewer for tiling window managers";
112     homepage = "https://github.com/eXeC64/imv";
113     license = licenses.mit;
114     maintainers = with maintainers; [ rnhmjoj markus1189 ];
115     platforms = platforms.all;
116   };