summary refs log tree commit diff
path: root/pkgs/applications/graphics/sane/config.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/graphics/sane/config.nix')
-rw-r--r--pkgs/applications/graphics/sane/config.nix13
1 files changed, 10 insertions, 3 deletions
diff --git a/pkgs/applications/graphics/sane/config.nix b/pkgs/applications/graphics/sane/config.nix
index 304df652f15..397e17837bc 100644
--- a/pkgs/applications/graphics/sane/config.nix
+++ b/pkgs/applications/graphics/sane/config.nix
@@ -1,9 +1,10 @@
 { lib, stdenv }:
 
-{ paths }:
+{ paths, disabledDefaultBackends ? [] }:
 
 with lib;
-let installSanePath = path: ''
+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);
 }