sane-backends: replace systemd with systemdLibs (#441285)

This commit is contained in:
Guillaume Girol
2025-09-14 15:33:45 +00:00
committed by GitHub
@@ -3,7 +3,6 @@
lib,
fetchFromGitLab,
fetchpatch,
runtimeShell,
buildPackages,
gettext,
pkg-config,
@@ -18,8 +17,8 @@
libv4l,
net-snmp,
curl,
systemd,
withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
systemdLibs,
withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemdLibs,
libxml2,
poppler,
gawk,
@@ -42,14 +41,14 @@
scanSnapDriversPackage ? sane-drivers.epjitsu,
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "sane-backends";
version = "1.4.0";
src = fetchFromGitLab {
owner = "sane-project";
repo = "backends";
rev = "refs/tags/${version}";
tag = finalAttrs.version;
hash = "sha256-e7Wjda+CobYatblvVCGkMAO2aWrdSCp7q+qIEGnGDCY=";
};
@@ -78,10 +77,6 @@ stdenv.mkDerivation rec {
# Fixes for cross compilation
# https://github.com/NixOS/nixpkgs/issues/308283
# related to the compile-sane-desc-for-build
substituteInPlace tools/Makefile.in \
--replace 'cc -I' '$(CC_FOR_BUILD) -I'
# sane-desc will be used in postInstall so compile it for build
# https://github.com/void-linux/void-packages/blob/master/srcpkgs/sane/patches/sane-desc-cross.patch
patch -p1 -i ${./sane-desc-cross.patch}
@@ -123,7 +118,7 @@ stdenv.mkDerivation rec {
net-snmp
]
++ lib.optionals withSystemd [
systemd
systemdLibs
];
enableParallelBuilding = true;
@@ -131,8 +126,8 @@ stdenv.mkDerivation rec {
configureFlags = [
"--with-lockdir=/var/lock/sane"
]
++ lib.optional (avahi != null) "--with-avahi"
++ lib.optional (libusb1 != null) "--with-usb";
++ lib.optionals (avahi != null) [ "--with-avahi" ]
++ lib.optionals (libusb1 != null) [ "--with-usb" ];
# autoconf check for HAVE_MMAP is never set on cross compilation.
# The pieusb backend fails compilation if HAVE_MMAP is not set.
@@ -142,7 +137,6 @@ stdenv.mkDerivation rec {
postInstall =
let
compatFirmware =
extraFirmware
++ lib.optional (gt68xxFirmware != null) {
@@ -160,18 +154,11 @@ stdenv.mkDerivation rec {
mkdir -p $out/share/sane/${f.backend}
ln -sv ${f.src} $out/share/sane/${f.backend}/${f.name}
'';
in
''
mkdir -p $out/etc/udev/rules.d/ $out/etc/udev/hwdb.d
./tools/sane-desc -m udev+hwdb -s doc/descriptions:doc/descriptions-external > $out/etc/udev/rules.d/49-libsane.rules
./tools/sane-desc -m udev+hwdb -s doc/descriptions:doc/descriptions-external -m hwdb > $out/etc/udev/hwdb.d/20-sane.hwdb
# the created 49-libsane references /bin/sh
substituteInPlace $out/etc/udev/rules.d/49-libsane.rules \
--replace "RUN+=\"/bin/sh" "RUN+=\"${runtimeShell}"
substituteInPlace $out/lib/libsane.la \
--replace "-ljpeg" "-L${lib.getLib libjpeg}/lib -ljpeg"
# net.conf conflicts with the file generated by the nixos module
rm $out/etc/sane.d/net.conf
@@ -208,4 +195,4 @@ stdenv.mkDerivation rec {
platforms = lib.platforms.linux ++ lib.platforms.darwin;
maintainers = [ lib.maintainers.symphorien ];
};
}
})