diff --git a/nixos/modules/services/hardware/sane.nix b/nixos/modules/services/hardware/sane.nix index e69209c560b5..8ddb9ef9c53b 100644 --- a/nixos/modules/services/hardware/sane.nix +++ b/nixos/modules/services/hardware/sane.nix @@ -17,12 +17,21 @@ let ''; }; + netConf = pkgs.writeTextFile { + name = "net.conf"; + destination = "/etc/sane.d/net.conf"; + text = '' + ${lib.optionalString config.services.saned.enable "localhost"} + ${config.hardware.sane.netConf} + ''; + }; + env = { SANE_CONFIG_DIR = config.hardware.sane.configDir; LD_LIBRARY_PATH = [ "${saneConfig}/lib/sane" ]; }; - backends = [ pkg ] ++ optional config.services.saned.enable sanedConf ++ config.hardware.sane.extraBackends; + backends = [ pkg netConf ] ++ optional config.services.saned.enable sanedConf ++ config.hardware.sane.extraBackends; saneConfig = pkgs.mkSaneConfig { paths = backends; }; enabled = config.hardware.sane.enable || config.services.saned.enable; @@ -72,6 +81,15 @@ in description = "The value of SANE_CONFIG_DIR."; }; + hardware.sane.netConf = mkOption { + type = types.lines; + default = ""; + example = "192.168.0.16"; + description = '' + Network hosts that should be probed for remote scanners. + ''; + }; + services.saned.enable = mkOption { type = types.bool; default = false; diff --git a/pkgs/applications/graphics/sane/config.nix b/pkgs/applications/graphics/sane/config.nix index fb4e56eb6cea..c0a0206ddd1f 100644 --- a/pkgs/applications/graphics/sane/config.nix +++ b/pkgs/applications/graphics/sane/config.nix @@ -13,7 +13,7 @@ let installSanePath = path: '' if [ -e "${path}/etc/sane.d" ]; then find "${path}/etc/sane.d" -maxdepth 1 -not -type d | while read conf; do name="$(basename $conf)" - if [ "$name" = "dll.conf" ] || [ "$name" = "saned.conf" ]; then + if [ "$name" = "dll.conf" ] || [ "$name" = "saned.conf" ] || [ "$name" = "net.conf" ]; then cat "$conf" >> "$out/etc/sane.d/$name" else ln -s "$conf" "$out/etc/sane.d/$name"