2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-12-05 17:32:45 +00:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2011-12-05 17:32:45 +00:00
|
|
|
|
2013-10-30 16:37:45 +00:00
|
|
|
let
|
|
|
|
|
2016-01-03 02:31:38 +00:00
|
|
|
pkg = if config.hardware.sane.snapshot
|
|
|
|
then pkgs.sane-backends-git
|
|
|
|
else pkgs.sane-backends;
|
2014-05-11 19:31:21 +01:00
|
|
|
backends = [ pkg ] ++ config.hardware.sane.extraBackends;
|
|
|
|
saneConfig = pkgs.mkSaneConfig { paths = backends; };
|
2013-10-30 16:37:45 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
|
2011-12-05 17:32:45 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
hardware.sane.enable = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.bool;
|
2011-12-05 17:32:45 +00:00
|
|
|
default = false;
|
2016-02-21 19:55:39 +00:00
|
|
|
description = ''
|
|
|
|
Enable support for SANE scanners.
|
|
|
|
|
|
|
|
<note><para>
|
|
|
|
Users in the "scanner" group will gain access to the scanner.
|
|
|
|
</para></note>
|
|
|
|
'';
|
2011-12-05 17:32:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
hardware.sane.snapshot = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.bool;
|
2011-12-05 17:32:45 +00:00
|
|
|
default = false;
|
|
|
|
description = "Use a development snapshot of SANE scanner drivers.";
|
|
|
|
};
|
|
|
|
|
2014-05-11 19:31:21 +01:00
|
|
|
hardware.sane.extraBackends = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
default = [];
|
2016-02-21 19:55:39 +00:00
|
|
|
description = ''
|
|
|
|
Packages providing extra SANE backends to enable.
|
|
|
|
|
|
|
|
<note><para>
|
|
|
|
The example contains the package for HP scanners.
|
|
|
|
</para></note>
|
|
|
|
'';
|
|
|
|
example = literalExample "[ pkgs.hplipWithPlugin ]";
|
2014-05-11 19:31:21 +01:00
|
|
|
};
|
|
|
|
|
2014-06-24 09:52:12 +01:00
|
|
|
hardware.sane.configDir = mkOption {
|
|
|
|
type = types.string;
|
|
|
|
description = "The value of SANE_CONFIG_DIR.";
|
|
|
|
};
|
|
|
|
|
2011-12-05 17:32:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2013-10-30 16:37:45 +00:00
|
|
|
config = mkIf config.hardware.sane.enable {
|
|
|
|
|
2015-09-24 10:42:32 +01:00
|
|
|
hardware.sane.configDir = mkDefault "${saneConfig}/etc/sane.d";
|
|
|
|
|
2014-05-11 19:31:21 +01:00
|
|
|
environment.systemPackages = backends;
|
2014-06-22 13:38:45 +01:00
|
|
|
environment.sessionVariables = {
|
2014-06-24 09:52:12 +01:00
|
|
|
SANE_CONFIG_DIR = config.hardware.sane.configDir;
|
2014-05-11 19:31:21 +01:00
|
|
|
LD_LIBRARY_PATH = [ "${saneConfig}/lib/sane" ];
|
|
|
|
};
|
|
|
|
services.udev.packages = backends;
|
2013-10-30 16:37:45 +00:00
|
|
|
|
|
|
|
users.extraGroups."scanner".gid = config.ids.gids.scanner;
|
|
|
|
|
|
|
|
};
|
2011-12-05 17:32:45 +00:00
|
|
|
|
|
|
|
}
|