nixpkgs/nixos/modules/services/hardware/sane.nix

65 lines
1.4 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
2013-10-30 17:37:45 +01:00
let
pkg = if config.hardware.sane.snapshot
then pkgs.sane-backends-git
else pkgs.sane-backends;
backends = [ pkg ] ++ config.hardware.sane.extraBackends;
saneConfig = pkgs.mkSaneConfig { paths = backends; };
2013-10-30 17:37:45 +01:00
in
{
###### interface
options = {
hardware.sane.enable = mkOption {
2013-10-30 17:37:45 +01:00
type = types.bool;
default = false;
description = "Enable support for SANE scanners.";
};
hardware.sane.snapshot = mkOption {
2013-10-30 17:37:45 +01:00
type = types.bool;
default = false;
description = "Use a development snapshot of SANE scanner drivers.";
};
hardware.sane.extraBackends = mkOption {
type = types.listOf types.path;
default = [];
description = "Packages providing extra SANE backends to enable.";
};
hardware.sane.configDir = mkOption {
type = types.string;
description = "The value of SANE_CONFIG_DIR.";
};
};
###### implementation
2013-10-30 17:37:45 +01:00
config = mkIf config.hardware.sane.enable {
2015-09-24 11:42:32 +02:00
hardware.sane.configDir = mkDefault "${saneConfig}/etc/sane.d";
environment.systemPackages = backends;
environment.sessionVariables = {
SANE_CONFIG_DIR = config.hardware.sane.configDir;
LD_LIBRARY_PATH = [ "${saneConfig}/lib/sane" ];
};
services.udev.packages = backends;
2013-10-30 17:37:45 +01:00
users.extraGroups."scanner".gid = config.ids.gids.scanner;
};
}