14 , withWindowSystem ? "all"
19 , withBackends ? [ "freeimage" "libtiff" "libjpeg" "libpng" "librsvg" "libnsgif" "libheif" ]
31 all = windowSystems.x11 ++ windowSystems.wayland;
32 x11 = [ libGLU xorg.libxcb xorg.libX11 ];
33 wayland = [ wayland ];
37 inherit freeimage libtiff libpng librsvg libheif;
38 libjpeg = libjpeg_turbo;
39 inherit (netsurf) libnsgif;
42 backendFlags = builtins.map
43 (b: if builtins.elem b withBackends
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
54 (b: lib.assertOneOf "each backend" b (builtins.attrNames backends))
57 stdenv.mkDerivation rec {
60 outputs = [ "out" "man" ];
62 src = fetchFromSourcehut {
66 sha256 = "sha256-gMAd8skst72QT4jGFH7aRdWeAd4tf/uQgXhGaM/Dpgc=";
70 "-Dwindows=${withWindowSystem}"
90 ] ++ windowSystems."${withWindowSystem}"
91 ++ builtins.map (b: backends."${b}") withBackends;
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/
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"
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;