4a7f99d55d
Part of: https://github.com/NixOS/nixpkgs/issues/108938 meta = with stdenv.lib; is a widely used pattern. We want to slowly remove the `stdenv.lib` indirection and encourage people to use `lib` directly. Thus let’s start with the meta field. This used a rewriting script to mostly automatically replace all occurances of this pattern, and add the `lib` argument to the package header if it doesn’t exist yet. The script in its current form is available at https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
111 lines
2.3 KiB
Nix
111 lines
2.3 KiB
Nix
{ stdenv
|
|
, lib
|
|
, fetchFromGitHub
|
|
, asciidoc
|
|
, cmocka
|
|
, docbook_xsl
|
|
, libxslt
|
|
, fontconfig
|
|
, meson
|
|
, ninja
|
|
, pkgconfig
|
|
, icu
|
|
, pango
|
|
, inih
|
|
, withWindowSystem ? "all"
|
|
, xorg
|
|
, libxkbcommon
|
|
, libGLU
|
|
, wayland
|
|
, withBackends ? [ "freeimage" "libtiff" "libjpeg" "libpng" "librsvg" "libnsgif" "libheif" ]
|
|
, freeimage
|
|
, libtiff
|
|
, libjpeg_turbo
|
|
, libpng
|
|
, librsvg
|
|
, netsurf
|
|
, 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.2.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "eXeC64";
|
|
repo = "imv";
|
|
rev = "v${version}";
|
|
sha256 = "07pcpppmfvvj0czfvp1cyq03ha0jdj4whl13lzvw37q3vpxs5qqh";
|
|
};
|
|
|
|
mesonFlags = [
|
|
"-Dwindows=${withWindowSystem}"
|
|
"-Dtest=enabled"
|
|
"-Dman=enabled"
|
|
] ++ backendFlags;
|
|
|
|
nativeBuildInputs = [
|
|
asciidoc
|
|
cmocka
|
|
docbook_xsl
|
|
libxslt
|
|
meson
|
|
ninja
|
|
pkgconfig
|
|
];
|
|
|
|
buildInputs = [
|
|
icu
|
|
libxkbcommon
|
|
pango
|
|
inih
|
|
] ++ windowSystems."${withWindowSystem}"
|
|
++ builtins.map (b: backends."${b}") withBackends;
|
|
|
|
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
|
|
|
|
substituteInPlace "$out/bin/imv" \
|
|
--replace "imv-wayland" "$out/bin/imv-wayland" \
|
|
--replace "imv-x11" "$out/bin/imv-x11"
|
|
'';
|
|
|
|
doCheck = true;
|
|
|
|
meta = with lib; {
|
|
description = "A command line image viewer for tiling window managers";
|
|
homepage = "https://github.com/eXeC64/imv";
|
|
license = licenses.gpl2;
|
|
maintainers = with maintainers; [ rnhmjoj markus1189 ];
|
|
platforms = platforms.all;
|
|
};
|
|
}
|