saneBackends: add generic extraFirmware support
This usurps the model-specific gt68xxFirmware and snapscanFirmware, which are still supported for backwards compatibility – hopefully not forever.
This commit is contained in:
parent
c05165ba5c
commit
8b4273a65d
|
@ -1,7 +1,14 @@
|
||||||
{ stdenv, fetchurl
|
{ stdenv, fetchurl
|
||||||
, avahi, libusb1, libv4l, net_snmp
|
, avahi, libusb1, libv4l, net_snmp
|
||||||
, gettext, pkgconfig
|
, gettext, pkgconfig
|
||||||
|
|
||||||
|
# List of { src name backend } attibute sets - see installFirmware below:
|
||||||
|
, extraFirmware ? []
|
||||||
|
|
||||||
|
# For backwards compatibility with older setups; use extraFirmware instead:
|
||||||
, gt68xxFirmware ? null, snapscanFirmware ? null
|
, gt68xxFirmware ? null, snapscanFirmware ? null
|
||||||
|
|
||||||
|
# Passed from versioned package (e.g. default.nix, git.nix):
|
||||||
, version, src, ...
|
, version, src, ...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -20,20 +27,30 @@ stdenv.mkDerivation {
|
||||||
buildInputs = [ avahi libusb1 libv4l net_snmp ];
|
buildInputs = [ avahi libusb1 libv4l net_snmp ];
|
||||||
nativeBuildInputs = [ gettext pkgconfig ];
|
nativeBuildInputs = [ gettext pkgconfig ];
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = let
|
||||||
|
|
||||||
|
compatFirmware = extraFirmware
|
||||||
|
++ stdenv.lib.optional (gt68xxFirmware != null) {
|
||||||
|
src = gt68xxFirmware.fw;
|
||||||
|
inherit (gt68xxFirmware) name;
|
||||||
|
backend = "gt68xx";
|
||||||
|
}
|
||||||
|
++ stdenv.lib.optional (snapscanFirmware != null) {
|
||||||
|
src = snapscanFirmware;
|
||||||
|
name = "your-firmwarefile.bin";
|
||||||
|
backend = "snapscan";
|
||||||
|
};
|
||||||
|
|
||||||
|
installFirmware = f: ''
|
||||||
|
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/
|
mkdir -p $out/etc/udev/rules.d/
|
||||||
./tools/sane-desc -m udev > $out/etc/udev/rules.d/49-libsane.rules || \
|
./tools/sane-desc -m udev > $out/etc/udev/rules.d/49-libsane.rules || \
|
||||||
cp tools/udev/libsane.rules $out/etc/udev/rules.d/49-libsane.rules
|
cp tools/udev/libsane.rules $out/etc/udev/rules.d/49-libsane.rules
|
||||||
'';
|
'' + stdenv.lib.concatStrings (builtins.map installFirmware compatFirmware);
|
||||||
|
|
||||||
preInstall =
|
|
||||||
if gt68xxFirmware != null then
|
|
||||||
"mkdir -p \${out}/share/sane/gt68xx ; ln -s " + gt68xxFirmware.fw +
|
|
||||||
" \${out}/share/sane/gt68xx/" + gt68xxFirmware.name
|
|
||||||
else if snapscanFirmware != null then
|
|
||||||
"mkdir -p \${out}/share/sane/snapscan ; ln -s " + snapscanFirmware +
|
|
||||||
" \${out}/share/sane/snapscan/your-firmwarefile.bin"
|
|
||||||
else "";
|
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
Loading…
Reference in New Issue