summary refs log tree commit diff
path: root/pkgs/applications/graphics/sane
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/graphics/sane')
-rw-r--r--pkgs/applications/graphics/sane/backends/airscan/default.nix10
-rw-r--r--pkgs/applications/graphics/sane/backends/brscan4/default.nix47
-rw-r--r--pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix8
-rw-r--r--pkgs/applications/graphics/sane/backends/brscan5/default.nix98
-rw-r--r--pkgs/applications/graphics/sane/backends/default.nix109
-rw-r--r--pkgs/applications/graphics/sane/backends/dsseries/default.nix8
-rw-r--r--pkgs/applications/graphics/sane/backends/generic.nix95
-rw-r--r--pkgs/applications/graphics/sane/backends/git.nix10
-rw-r--r--pkgs/applications/graphics/sane/config.nix17
-rw-r--r--pkgs/applications/graphics/sane/frontends.nix8
-rw-r--r--pkgs/applications/graphics/sane/xsane.nix12
11 files changed, 260 insertions, 162 deletions
diff --git a/pkgs/applications/graphics/sane/backends/airscan/default.nix b/pkgs/applications/graphics/sane/backends/airscan/default.nix
index bd4a5ac9ad9..8d0e32e2b4e 100644
--- a/pkgs/applications/graphics/sane/backends/airscan/default.nix
+++ b/pkgs/applications/graphics/sane/backends/airscan/default.nix
@@ -1,17 +1,17 @@
-{ lib, stdenv, fetchFromGitHub, pkg-config, avahi, libsoup, libjpeg, libpng
-, sane-backends, meson, ninja }:
+{ lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, avahi, libjpeg, libpng
+, libxml2, gnutls, sane-backends }:
 stdenv.mkDerivation rec {
   pname = "sane-airscan";
-  version = "0.99.8";
+  version = "0.99.26";
 
   nativeBuildInputs = [ meson ninja pkg-config ];
-  buildInputs = [ avahi libsoup libjpeg libpng sane-backends ];
+  buildInputs = [ avahi gnutls libjpeg libpng libxml2 sane-backends ];
 
   src = fetchFromGitHub {
     owner = "alexpevzner";
     repo = pname;
     rev = version;
-    sha256 = "0sdlnbzhnfn4i5mkqhc8zmjywbbjqkbnsiz2gpqhy6fypshryahz";
+    sha256 = "08snfg5zx9924ryww0kxf1kgl085yw7fg6l4f1kzlhcmqf1958w5";
   };
 
   meta = with lib; {
diff --git a/pkgs/applications/graphics/sane/backends/brscan4/default.nix b/pkgs/applications/graphics/sane/backends/brscan4/default.nix
index 2ada41ac98a..6fcb5830556 100644
--- a/pkgs/applications/graphics/sane/backends/brscan4/default.nix
+++ b/pkgs/applications/graphics/sane/backends/brscan4/default.nix
@@ -1,28 +1,27 @@
-{ stdenv, fetchurl, callPackage, patchelf, makeWrapper, coreutils, libusb-compat-0_1 }:
-
+{ stdenv, lib, fetchurl, callPackage, patchelf, makeWrapper, coreutils, libusb-compat-0_1 }:
 let
-  myPatchElf = file: with stdenv.lib; ''
+  myPatchElf = file: with lib; ''
     patchelf --set-interpreter \
       ${stdenv.glibc}/lib/ld-linux${optionalString stdenv.is64bit "-x86-64"}.so.2 \
       ${file}
   '';
 
-  udevRules = callPackage ./udev_rules_type1.nix {};
+  udevRules = callPackage ./udev_rules_type1.nix { };
 
-in stdenv.mkDerivation rec {
-  name = "brscan4-0.4.8-1";
-  src = 
-    if stdenv.hostPlatform.system == "i686-linux" then
-      fetchurl {
-        url = "http://download.brother.com/welcome/dlf006646/${name}.i386.deb";
-        sha256 = "15hrf1gpm36lniqi6yf47dvdqjinm644xb752c6rcv8n06wb79ag";
-      }
-    else if stdenv.hostPlatform.system == "x86_64-linux" then
-      fetchurl {
-        url = "https://download.brother.com/welcome/dlf006645/${name}.amd64.deb";
-        sha256 = "0pyprjl0capg403yp6pp07gd6msx9kn7bzjcdswdbn28fyxrk5l4";
-      }
-    else throw "${name} is not supported on ${stdenv.hostPlatform.system} (only i686-linux and x86_64 linux are supported)";
+in
+stdenv.mkDerivation rec {
+  pname = "brscan4";
+  version = "0.4.10-1";
+  src = {
+    "i686-linux" = fetchurl {
+      url = "http://download.brother.com/welcome/dlf006646/${pname}-${version}.i386.deb";
+      sha256 = "sha256-ymIAg+rfSYP5uzsAM1hUYZacJ0PXmKEoljNtb0pgGMw=";
+    };
+    "x86_64-linux" = fetchurl {
+      url = "https://download.brother.com/welcome/dlf006645/${pname}-${version}.amd64.deb";
+      sha256 = "sha256-Gpr5456MCNpyam3g2qPo7S3aEZFMaUGR8bu7YmRY8xk=";
+    };
+  }."${stdenv.hostPlatform.system}";
 
   unpackPhase = ''
     ar x $src
@@ -33,7 +32,7 @@ in stdenv.mkDerivation rec {
   buildInputs = [ libusb-compat-0_1 ];
   dontBuild = true;
 
-  patchPhase = ''
+  postPatch = ''
     ${myPatchElf "opt/brother/scanner/brscan4/brsaneconfig4"}
 
     RPATH=${libusb-compat-0_1.out}/lib
@@ -44,7 +43,8 @@ in stdenv.mkDerivation rec {
     done
   '';
 
-  installPhase = with stdenv.lib; ''
+  installPhase = with lib; ''
+    runHook preInstall
     PATH_TO_BRSCAN4="opt/brother/scanner/brscan4"
     mkdir -p $out/$PATH_TO_BRSCAN4
     cp -rp $PATH_TO_BRSCAN4/* $out/$PATH_TO_BRSCAN4
@@ -79,6 +79,7 @@ in stdenv.mkDerivation rec {
     mkdir -p $out/etc/udev/rules.d
     cp -p ${udevRules}/etc/udev/rules.d/*.rules \
       $out/etc/udev/rules.d
+    runHook postInstall
   '';
 
   dontStrip = true;
@@ -87,8 +88,8 @@ in stdenv.mkDerivation rec {
   meta = {
     description = "Brother brscan4 sane backend driver";
     homepage = "http://www.brother.com";
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.unfree;
-    maintainers = with stdenv.lib.maintainers; [ jraygauthier ];
+    platforms = [ "i686-linux" "x86_64-linux" ];
+    license = lib.licenses.unfree;
+    maintainers = with lib.maintainers; [ jraygauthier ];
   };
 }
diff --git a/pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix b/pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix
index 682e401c069..9ca0a702060 100644
--- a/pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix
+++ b/pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libsaneUDevRuleNumber ? "49"}:
+{ lib, stdenv, fetchurl, libsaneUDevRuleNumber ? "49"}:
 
 stdenv.mkDerivation rec {
   name = "brother-udev-rule-type1-1.0.0-1";
@@ -48,8 +48,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Brother type1 scanners udev rules";
     homepage = "http://www.brother.com";
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.unfree;
-    maintainers = with stdenv.lib.maintainers; [ jraygauthier ];
+    platforms = lib.platforms.linux;
+    license = lib.licenses.unfree;
+    maintainers = with lib.maintainers; [ jraygauthier ];
   };
 }
diff --git a/pkgs/applications/graphics/sane/backends/brscan5/default.nix b/pkgs/applications/graphics/sane/backends/brscan5/default.nix
new file mode 100644
index 00000000000..e42c0980a1b
--- /dev/null
+++ b/pkgs/applications/graphics/sane/backends/brscan5/default.nix
@@ -0,0 +1,98 @@
+{ stdenv, lib, fetchurl, callPackage, patchelf, makeWrapper, coreutils, libusb1, avahi-compat, glib, libredirect }:
+let
+  myPatchElf = file: with lib; ''
+    patchelf --set-interpreter \
+      ${stdenv.glibc}/lib/ld-linux${optionalString stdenv.is64bit "-x86-64"}.so.2 \
+      ${file}
+  '';
+
+in
+stdenv.mkDerivation rec {
+  pname = "brscan5";
+  version = "1.2.6-0";
+  src = {
+    "i686-linux" = fetchurl {
+      url = "https://download.brother.com/welcome/dlf104034/${pname}-${version}.i386.deb";
+      sha256 = "102q745pc0168syggd4gym51qf3m3iqld3a4skfnbkm6yky4w4s8";
+    };
+    "x86_64-linux" = fetchurl {
+      url = "https://download.brother.com/welcome/dlf104033/${pname}-${version}.amd64.deb";
+      sha256 = "1pwbzhpg5nzpw2rw936vf2cr334v8iny16y8fbb1zimgzmv427wx";
+    };
+  }."${stdenv.hostPlatform.system}";
+
+  unpackPhase = ''
+    ar x $src
+    tar xfv data.tar.xz
+  '';
+
+  nativeBuildInputs = [ makeWrapper patchelf coreutils ];
+  buildInputs = [ libusb1 avahi-compat stdenv.cc.cc glib ];
+  dontBuild = true;
+
+  postPatch = ''
+    ${myPatchElf "opt/brother/scanner/brscan5/brsaneconfig5"}
+    ${myPatchElf "opt/brother/scanner/brscan5/brscan_cnetconfig"}
+    ${myPatchElf "opt/brother/scanner/brscan5/brscan_gnetconfig"}
+
+    for a in opt/brother/scanner/brscan5/*.so.* opt/brother/scanner/brscan5/brscan_[cg]netconfig; do
+      if ! test -L $a; then
+        patchelf --set-rpath ${lib.makeLibraryPath buildInputs} $a
+      fi
+    done
+
+    # driver is hardcoded to look in /opt/brother/scanner/brscan5/models for model metadata.
+    # patch it to look in /etc/opt/brother/scanner/models instead, so nixos environment.etc can make it available
+    printf '/etc/opt/brother/scanner/models\x00' | dd of=opt/brother/scanner/brscan5/libsane-brother5.so.1.0.7 bs=1 seek=84632 conv=notrunc
+  '';
+
+  installPhase = with lib; ''
+    runHook preInstall
+    PATH_TO_BRSCAN5="opt/brother/scanner/brscan5"
+    mkdir -p $out/$PATH_TO_BRSCAN5
+    cp -rp $PATH_TO_BRSCAN5/* $out/$PATH_TO_BRSCAN5
+
+
+    pushd $out/$PATH_TO_BRSCAN5
+      ln -s libLxBsDeviceAccs.so.1.0.0 libLxBsDeviceAccs.so.1
+      ln -s libLxBsNetDevAccs.so.1.0.0 libLxBsNetDevAccs.so.1
+      ln -s libLxBsScanCoreApi.so.3.0.0 libLxBsScanCoreApi.so.3
+      ln -s libLxBsUsbDevAccs.so.1.0.0 libLxBsUsbDevAccs.so.1
+      ln -s libsane-brother5.so.1.0.7 libsane-brother5.so.1
+    popd
+
+    mkdir -p $out/lib/sane
+    for file in $out/$PATH_TO_BRSCAN5/*.so.* ; do
+      ln -s $file $out/lib/sane/
+    done
+
+    makeWrapper \
+      "$out/$PATH_TO_BRSCAN5/brsaneconfig5" \
+      "$out/bin/brsaneconfig5" \
+      --suffix-each NIX_REDIRECT ":" "/etc/opt/brother/scanner/brscan5=$out/opt/brother/scanner/brscan5 /opt/brother/scanner/brscan5=$out/opt/brother/scanner/brscan5" \
+      --set LD_PRELOAD ${libredirect}/lib/libredirect.so
+
+    mkdir -p $out/etc/sane.d/dll.d
+    echo "brother5" > $out/etc/sane.d/dll.d/brother5.conf
+
+    mkdir -p $out/etc/udev/rules.d
+    cp -p $PATH_TO_BRSCAN5/udev-rules/NN-brother-mfp-brscan5-1.0.2-2.rules \
+      $out/etc/udev/rules.d/49-brother-mfp-brscan5-1.0.2-2.rules
+
+    ETCDIR=$out/etc/opt/brother/scanner/brscan5
+    mkdir -p $ETCDIR
+    cp -rp $PATH_TO_BRSCAN5/{models,brscan5.ini,brsanenetdevice.cfg} $ETCDIR/
+
+    runHook postInstall
+  '';
+
+  dontPatchELF = true;
+
+  meta = {
+    description = "Brother brscan5 sane backend driver";
+    homepage = "https://www.brother.com";
+    platforms = [ "i686-linux" "x86_64-linux" ];
+    license = lib.licenses.unfree;
+    maintainers = with lib.maintainers; [ mattchrist ];
+  };
+}
diff --git a/pkgs/applications/graphics/sane/backends/default.nix b/pkgs/applications/graphics/sane/backends/default.nix
index ad2681d25fe..821a97e3587 100644
--- a/pkgs/applications/graphics/sane/backends/default.nix
+++ b/pkgs/applications/graphics/sane/backends/default.nix
@@ -1,10 +1,107 @@
-{ callPackage, fetchurl, ... } @ args:
+{ stdenv, lib, fetchurl, runtimeShell
+, gettext, pkg-config, python3
+, avahi, libgphoto2, libieee1284, libjpeg, libpng, libtiff, libusb1, libv4l, net-snmp
+, curl, systemd, libxml2, poppler
 
-callPackage ./generic.nix (args // rec {
-  version = "1.0.30";
+# List of { src name backend } attibute sets - see installFirmware below:
+, extraFirmware ? []
+
+# For backwards compatibility with older setups; use extraFirmware instead:
+, gt68xxFirmware ? null, snapscanFirmware ? null
+}:
+
+stdenv.mkDerivation {
+  pname = "sane-backends";
+  version = "1.0.32";
 
   src = fetchurl {
-    url = "https://gitlab.com/sane-project/backends/uploads/c3dd60c9e054b5dee1e7b01a7edc98b0/sane-backends-${version}.tar.gz";
-    sha256 = "18vryaycps3zpjzxh0wjgg8nv2f4pdvcfxxmdfj28qbzqjlrcp9z";
+    # raw checkouts of the repo do not work because, the configure script is
+    # only functional in manually uploaded release tarballs.
+    # https://gitlab.com/sane-project/backends/-/issues/440
+    # unfortunately this make the url unpredictable on update, to find the link
+    # go to https://gitlab.com/sane-project/backends/-/releases and choose
+    # the link with other in the URL.
+    url = "https://gitlab.com/sane-project/backends/uploads/104f09c07d35519cc8e72e604f11643f/sane-backends-1.0.32.tar.gz";
+    sha256 = "055iicihxa6b28iv5fnz13n67frdr5nrydq2c846f9x7q0vw4a1s";
+  };
+
+  outputs = [ "out" "doc" "man" ];
+
+  nativeBuildInputs = [
+    gettext
+    pkg-config
+    python3
+  ];
+
+  buildInputs = [
+    avahi
+    libgphoto2
+    libieee1284
+    libjpeg
+    libpng
+    libtiff
+    libusb1
+    libv4l
+    net-snmp
+    curl
+    systemd
+    libxml2
+    poppler
+  ];
+
+  enableParallelBuilding = true;
+
+  configureFlags =
+    lib.optional (avahi != null)   "--with-avahi"
+    ++ lib.optional (libusb1 != null) "--with-usb"
+  ;
+
+  postInstall = let
+
+    compatFirmware = extraFirmware
+      ++ lib.optional (gt68xxFirmware != null) {
+        src = gt68xxFirmware.fw;
+        inherit (gt68xxFirmware) name;
+        backend = "gt68xx";
+      }
+      ++ 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/
+    ./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
+    # 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
+  '' + lib.concatStrings (builtins.map installFirmware compatFirmware);
+
+  meta = with lib; {
+    description = "SANE (Scanner Access Now Easy) backends";
+    longDescription = ''
+      Collection of open-source SANE backends (device drivers).
+      SANE is a universal scanner interface providing standardized access to
+      any raster image scanner hardware: flatbed scanners, hand-held scanners,
+      video- and still-cameras, frame-grabbers, etc. For a list of supported
+      scanners, see http://www.sane-project.org/sane-backends.html.
+    '';
+    homepage = "http://www.sane-project.org/";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ peti ];
+    platforms = platforms.linux;
   };
-})
+}
diff --git a/pkgs/applications/graphics/sane/backends/dsseries/default.nix b/pkgs/applications/graphics/sane/backends/dsseries/default.nix
index 37ac0298706..8a01f70c6b0 100644
--- a/pkgs/applications/graphics/sane/backends/dsseries/default.nix
+++ b/pkgs/applications/graphics/sane/backends/dsseries/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, rpmextract }:
+{ lib, stdenv, fetchurl, rpmextract }:
 
 stdenv.mkDerivation rec {
   pname = "libsane-dsseries";
@@ -46,8 +46,8 @@ stdenv.mkDerivation rec {
   meta = {
     description = "Brother DSSeries SANE backend driver";
     homepage = "http://www.brother.com";
-    platforms = stdenv.lib.platforms.linux;
-    license = stdenv.lib.licenses.unfree;
-    maintainers = with stdenv.lib.maintainers; [ callahad ];
+    platforms = lib.platforms.linux;
+    license = lib.licenses.unfree;
+    maintainers = with lib.maintainers; [ callahad ];
   };
 }
diff --git a/pkgs/applications/graphics/sane/backends/generic.nix b/pkgs/applications/graphics/sane/backends/generic.nix
deleted file mode 100644
index d3e8b417017..00000000000
--- a/pkgs/applications/graphics/sane/backends/generic.nix
+++ /dev/null
@@ -1,95 +0,0 @@
-{ stdenv
-, gettext, pkgconfig
-, avahi, libgphoto2, libieee1284, libjpeg, libpng, libtiff, libusb1, libv4l, net-snmp
-
-# List of { src name backend } attibute sets - see installFirmware below:
-, extraFirmware ? []
-
-# For backwards compatibility with older setups; use extraFirmware instead:
-, gt68xxFirmware ? null, snapscanFirmware ? null
-
-# Passed from versioned package (e.g. default.nix, git.nix):
-, version, src, ...
-}:
-
-stdenv.mkDerivation {
-  inherit src version;
-
-  name = "sane-backends-${version}";
-
-  outputs = [ "out" "doc" "man" ];
-
-  nativeBuildInputs = [
-    gettext
-    pkgconfig
-  ];
-
-  buildInputs = [
-    avahi
-    libgphoto2
-    libieee1284
-    libjpeg
-    libpng
-    libtiff
-    libusb1
-    libv4l
-    net-snmp
-  ];
-
-  enableParallelBuilding = true;
-
-  configureFlags = []
-    ++ stdenv.lib.optional (avahi != null)   "--enable-avahi"
-    ++ stdenv.lib.optional (libusb1 != null) "--with-usb"
-  ;
-
-  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/
-    ./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
-    # the created 49-libsane references /bin/sh
-    substituteInPlace $out/etc/udev/rules.d/49-libsane.rules \
-      --replace "RUN+=\"/bin/sh" "RUN+=\"${stdenv.shell}"
-
-    substituteInPlace $out/lib/libsane.la \
-      --replace "-ljpeg" "-L${libjpeg.out}/lib -ljpeg"
-
-    # net.conf conflicts with the file generated by the nixos module
-    rm -f $out/etc/sane.d/net.conf
-  '' + stdenv.lib.concatStrings (builtins.map installFirmware compatFirmware);
-
-  meta = with stdenv.lib; {
-    description = "SANE (Scanner Access Now Easy) backends";
-    longDescription = ''
-      Collection of open-source SANE backends (device drivers).
-      SANE is a universal scanner interface providing standardized access to
-      any raster image scanner hardware: flatbed scanners, hand-held scanners,
-      video- and still-cameras, frame-grabbers, etc. For a list of supported
-      scanners, see http://www.sane-project.org/sane-backends.html.
-    '';
-    homepage = "http://www.sane-project.org/";
-    license = licenses.gpl2Plus;
-
-    maintainers = with maintainers; [ peti ];
-    platforms = platforms.linux;
-  };
-}
diff --git a/pkgs/applications/graphics/sane/backends/git.nix b/pkgs/applications/graphics/sane/backends/git.nix
deleted file mode 100644
index 2edd739068d..00000000000
--- a/pkgs/applications/graphics/sane/backends/git.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{ callPackage, fetchgit, ... } @ args:
-
-callPackage ./generic.nix (args // {
-  version = "2017-12-01";
-  src = fetchgit {
-    sha256 = "0qf7d7268kdxnb723c03m6icxhbgx0vw8gqvck2q1w5b948dy9g8";
-    rev = "e895ee55bec8a3320a0e972b32c05d35b47fe226";
-    url = "https://gitlab.com/sane-project/backends.git";
-  };
-})
diff --git a/pkgs/applications/graphics/sane/config.nix b/pkgs/applications/graphics/sane/config.nix
index 2ef1e26f5ac..397e17837bc 100644
--- a/pkgs/applications/graphics/sane/config.nix
+++ b/pkgs/applications/graphics/sane/config.nix
@@ -1,9 +1,10 @@
-{ stdenv }:
+{ lib, stdenv }:
 
-{ paths }:
+{ paths, disabledDefaultBackends ? [] }:
 
-with stdenv.lib;
-let installSanePath = path: ''
+with lib;
+let
+installSanePath = path: ''
       if [ -e "${path}/lib/sane" ]; then
         find "${path}/lib/sane" -maxdepth 1 -not -type d | while read backend; do
           symlink "$backend" "$out/lib/sane/$(basename "$backend")"
@@ -27,6 +28,10 @@ let installSanePath = path: ''
         done
       fi
     '';
+    disableBackend = backend: ''
+      grep -q '${backend}' $out/etc/sane.d/dll.conf || { echo '${backend} is not a default plugin in $SANE_CONFIG_DIR/dll.conf'; exit 1; }
+      substituteInPlace $out/etc/sane.d/dll.conf --replace '${backend}' '# ${backend} disabled in nixos config'
+    '';
 in
 stdenv.mkDerivation {
   name = "sane-config";
@@ -42,5 +47,7 @@ stdenv.mkDerivation {
     }
 
     mkdir -p $out/etc/sane.d $out/etc/sane.d/dll.d $out/lib/sane
-  '' + concatMapStrings installSanePath paths;
+  ''
+  + (concatMapStrings installSanePath paths)
+  + (concatMapStrings disableBackend disabledDefaultBackends);
 }
diff --git a/pkgs/applications/graphics/sane/frontends.nix b/pkgs/applications/graphics/sane/frontends.nix
index 885dff311b8..c0945242096 100644
--- a/pkgs/applications/graphics/sane/frontends.nix
+++ b/pkgs/applications/graphics/sane/frontends.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, sane-backends, libX11, gtk2, pkgconfig, libusb-compat-0_1 ? null }:
+{ lib, stdenv, fetchurl, sane-backends, libX11, gtk2, pkg-config, libusb-compat-0_1 ? null }:
 
 stdenv.mkDerivation rec {
   pname = "sane-frontends";
@@ -14,12 +14,12 @@ stdenv.mkDerivation rec {
   '';
 
   buildInputs = [ sane-backends libX11 gtk2 ]
-    ++ stdenv.lib.optional (libusb-compat-0_1 != null) libusb-compat-0_1;
-  nativeBuildInputs = [ pkgconfig ];
+    ++ lib.optional (libusb-compat-0_1 != null) libusb-compat-0_1;
+  nativeBuildInputs = [ pkg-config ];
 
   enableParallelBuilding = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     description = "Scanner Access Now Easy";
     homepage    = "http://www.sane-project.org/";
     license     = licenses.gpl2Plus;
diff --git a/pkgs/applications/graphics/sane/xsane.nix b/pkgs/applications/graphics/sane/xsane.nix
index 04d19dee8a8..1deaab4dfe5 100644
--- a/pkgs/applications/graphics/sane/xsane.nix
+++ b/pkgs/applications/graphics/sane/xsane.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, sane-backends, sane-frontends, libX11, gtk2, pkgconfig, libpng
+{ lib, stdenv, fetchurl, sane-backends, sane-frontends, libX11, gtk2, pkg-config, libpng
 , libusb-compat-0_1 ? null
 , gimpSupport ? false, gimp ? null
 }:
@@ -18,16 +18,16 @@ stdenv.mkDerivation rec {
     chmod a+rX -R .
   '';
 
-  nativeBuildInputs = [ pkgconfig ];
+  nativeBuildInputs = [ pkg-config ];
   buildInputs = [libpng sane-backends sane-frontends libX11 gtk2 ]
     ++ (if libusb-compat-0_1 != null then [libusb-compat-0_1] else [])
-    ++ stdenv.lib.optional gimpSupport gimp;
+    ++ lib.optional gimpSupport gimp;
 
   meta = {
     homepage = "http://www.sane-project.org/";
     description = "Graphical scanning frontend for sane";
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [peti];
-    platforms = with stdenv.lib.platforms; linux;
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [peti];
+    platforms = with lib.platforms; linux;
   };
 }