at 15.09-beta 1.4 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 pkg = if config.hardware.sane.snapshot then pkgs.saneBackendsGit else pkgs.saneBackends; 8 backends = [ pkg ] ++ config.hardware.sane.extraBackends; 9 saneConfig = pkgs.mkSaneConfig { paths = backends; }; 10 11in 12 13{ 14 15 ###### interface 16 17 options = { 18 19 hardware.sane.enable = mkOption { 20 type = types.bool; 21 default = false; 22 description = "Enable support for SANE scanners."; 23 }; 24 25 hardware.sane.snapshot = mkOption { 26 type = types.bool; 27 default = false; 28 description = "Use a development snapshot of SANE scanner drivers."; 29 }; 30 31 hardware.sane.extraBackends = mkOption { 32 type = types.listOf types.path; 33 default = []; 34 description = "Packages providing extra SANE backends to enable."; 35 }; 36 37 hardware.sane.configDir = mkOption { 38 type = types.string; 39 default = "${saneConfig}/etc/sane.d"; 40 description = "The value of SANE_CONFIG_DIR."; 41 }; 42 43 }; 44 45 46 ###### implementation 47 48 config = mkIf config.hardware.sane.enable { 49 50 environment.systemPackages = backends; 51 environment.sessionVariables = { 52 SANE_CONFIG_DIR = config.hardware.sane.configDir; 53 LD_LIBRARY_PATH = [ "${saneConfig}/lib/sane" ]; 54 }; 55 services.udev.packages = backends; 56 57 users.extraGroups."scanner".gid = config.ids.gids.scanner; 58 59 }; 60 61}