14 , withWindowSystem ? null
19 # "libnsgif" is disabled until https://todo.sr.ht/~exec64/imv/55 is solved
20 , withBackends ? [ "libjxl" "libtiff" "libjpeg" "libpng" "librsvg" "libheif" ]
32 # default value of withWindowSystem
34 if withWindowSystem != null then withWindowSystem
35 else if stdenv.hostPlatform.isLinux then "all"
39 all = windowSystems.x11 ++ windowSystems.wayland;
40 x11 = [ libGLU xorg.libxcb xorg.libX11 ];
41 wayland = [ wayland ];
45 inherit freeimage libtiff libpng librsvg libheif libjxl;
46 libjpeg = libjpeg_turbo;
47 inherit (netsurf) libnsgif;
50 backendFlags = builtins.map
51 (b: if builtins.elem b withBackends
53 else "-D${b}=disabled")
54 (builtins.attrNames backends);
57 # check that given window system is valid
58 assert lib.assertOneOf "withWindowSystem" withWindowSystem'
59 (builtins.attrNames windowSystems);
60 # check that every given backend is valid
62 (b: lib.assertOneOf "each backend" b (builtins.attrNames backends))
65 stdenv.mkDerivation rec {
68 outputs = [ "out" "man" ];
70 src = fetchFromSourcehut {
74 sha256 = "sha256-aJ2EXgsS0WUTxMqC1Q+uOWLG8BeuwAyXPmJB/9/NCCU=";
78 "-Dwindows=${withWindowSystem'}"
100 ] ++ windowSystems."${withWindowSystem'}"
101 ++ builtins.map (b: backends."${b}") withBackends;
104 # fix the executable path and install the desktop item
105 substituteInPlace ../files/imv.desktop --replace "imv %F" "$out/bin/imv %F"
106 install -Dm644 ../files/imv.desktop $out/share/applications/
109 postFixup = lib.optionalString (withWindowSystem' == "all") ''
110 # The `bin/imv` script assumes imv-wayland or imv-x11 in PATH,
111 # so we have to fix those to the binaries we installed into the /nix/store
113 substituteInPlace "$out/bin/imv" \
114 --replace "imv-wayland" "$out/bin/imv-wayland" \
115 --replace "imv-x11" "$out/bin/imv-x11"
121 description = "Command line image viewer for tiling window managers";
122 homepage = "https://sr.ht/~exec64/imv/";
123 license = licenses.mit;
124 maintainers = with maintainers; [ rnhmjoj markus1189 ];
125 platforms = platforms.all;
126 badPlatforms = platforms.darwin;