mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
130 lines
2.9 KiB
Nix
130 lines
2.9 KiB
Nix
{ stdenv
|
|
, lib
|
|
, fetchFromSourcehut
|
|
, asciidoc
|
|
, cmocka
|
|
, docbook_xsl
|
|
, libxslt
|
|
, meson
|
|
, ninja
|
|
, pkg-config
|
|
, icu
|
|
, pango
|
|
, inih
|
|
, withWindowSystem ? null
|
|
, xorg
|
|
, libxkbcommon
|
|
, libGLU
|
|
, wayland
|
|
# "libnsgif" is disabled until https://todo.sr.ht/~exec64/imv/55 is solved
|
|
, withBackends ? [ "libjxl" "libtiff" "libjpeg" "libpng" "librsvg" "libheif" ]
|
|
, freeimage
|
|
, libtiff
|
|
, libjpeg_turbo
|
|
, libjxl
|
|
, libpng
|
|
, librsvg
|
|
, netsurf
|
|
, libheif
|
|
}:
|
|
|
|
let
|
|
# default value of withWindowSystem
|
|
withWindowSystem' =
|
|
if withWindowSystem != null then withWindowSystem
|
|
else if stdenv.hostPlatform.isLinux then "all"
|
|
else "x11";
|
|
|
|
windowSystems = {
|
|
all = windowSystems.x11 ++ windowSystems.wayland;
|
|
x11 = [ libGLU xorg.libxcb xorg.libX11 ];
|
|
wayland = [ wayland ];
|
|
};
|
|
|
|
backends = {
|
|
inherit freeimage libtiff libpng librsvg libheif libjxl;
|
|
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.5.0";
|
|
outputs = [ "out" "man" ];
|
|
|
|
src = fetchFromSourcehut {
|
|
owner = "~exec64";
|
|
repo = "imv";
|
|
rev = "v${version}";
|
|
sha256 = "sha256-aJ2EXgsS0WUTxMqC1Q+uOWLG8BeuwAyXPmJB/9/NCCU=";
|
|
};
|
|
|
|
mesonFlags = [
|
|
"-Dwindows=${withWindowSystem'}"
|
|
"-Dtest=enabled"
|
|
"-Dman=enabled"
|
|
] ++ backendFlags;
|
|
|
|
strictDeps = true;
|
|
|
|
nativeBuildInputs = [
|
|
asciidoc
|
|
docbook_xsl
|
|
libxslt
|
|
meson
|
|
ninja
|
|
pkg-config
|
|
];
|
|
|
|
buildInputs = [
|
|
cmocka
|
|
icu
|
|
libxkbcommon
|
|
pango
|
|
inih
|
|
] ++ windowSystems."${withWindowSystem'}"
|
|
++ builtins.map (b: backends."${b}") withBackends;
|
|
|
|
postInstall = ''
|
|
# fix the executable path and install the desktop item
|
|
substituteInPlace ../files/imv.desktop --replace "imv %F" "$out/bin/imv %F"
|
|
install -Dm644 ../files/imv.desktop $out/share/applications/
|
|
'';
|
|
|
|
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 = "Command line image viewer for tiling window managers";
|
|
homepage = "https://sr.ht/~exec64/imv/";
|
|
license = licenses.mit;
|
|
maintainers = with maintainers; [ rnhmjoj markus1189 ];
|
|
platforms = platforms.all;
|
|
badPlatforms = platforms.darwin;
|
|
mainProgram = "imv";
|
|
};
|
|
}
|