nixpkgs/pkgs/by-name/ds/dsseries/package.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

60 lines
1.6 KiB
Nix

{
lib,
stdenv,
fetchurl,
rpmextract,
}:
stdenv.mkDerivation rec {
pname = "libsane-dsseries";
version = "1.0.5-1";
src = fetchurl {
url = "https://download.brother.com/welcome/dlf100974/${pname}-${version}.x86_64.rpm";
sha256 = "1wfdbfbf51cc7njzikdg48kwpnpc0pg5s6p0s0y3z0q7y59x2wbq";
};
nativeBuildInputs = [ rpmextract ];
unpackCmd = ''
mkdir ${pname}-${version} && pushd ${pname}-${version}
rpmextract $curSrc
popd
'';
patchPhase = ''
substituteInPlace etc/udev/rules.d/50-Brother_DSScanner.rules \
--replace 'GROUP="users"' 'GROUP="scanner", ENV{libsane_matched}="yes"'
mkdir -p etc/sane.d/dll.d
echo "dsseries" > etc/sane.d/dll.d/dsseries.conf
'';
installPhase = ''
mkdir -p $out
cp -dr etc $out
cp -dr usr/lib64 $out/lib
'';
preFixup = ''
for f in `find $out/lib/sane/ -type f`; do
# Make it possible to find libstdc++.so.6
patchelf --set-rpath ${lib.getLib stdenv.cc.cc}/lib:$out/lib/sane $f
# Horrible kludge: The driver hardcodes /usr/lib/sane/ as a dlopen path.
# We can directly modify the binary to force a relative lookup instead.
# The new path is NULL-padded to the same length as the original path.
sed -i "s|/usr/lib/sane/%s|%s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|g" $f
done
'';
meta = {
description = "Brother DSSeries SANE backend driver";
homepage = "http://www.brother.com";
platforms = lib.platforms.linux;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [ callahad ];
};
}