1 { config, lib, pkgs, ... }:
6 cfg = config.hardware.sane.brscan5;
8 netDeviceList = attrValues cfg.netDevices;
10 etcFiles = pkgs.callPackage ./brscan5_etc_files.nix { netDevices = netDeviceList; };
12 netDeviceOpts = { name, ... }: {
19 The friendly name you give to the network device. If undefined,
20 the name of attribute will be used.
29 The model of the network device.
36 type = with types; nullOr str;
39 The ip address of the device. If undefined, you will have to
43 example = "192.168.1.2";
47 type = with types; nullOr str;
50 The node name of the device. If undefined, you will have to
54 example = "BRW0080927AFBCE";
61 { name = mkDefault name;
70 hardware.sane.brscan5.enable =
71 mkEnableOption "the Brother brscan5 sane backend";
73 hardware.sane.brscan5.netDevices = mkOption {
76 { office1 = { model = "MFC-7860DW"; ip = "192.168.1.2"; };
77 office2 = { model = "MFC-7860DW"; nodename = "BRW0080927AFBCE"; };
79 type = with types; attrsOf (submodule netDeviceOpts);
81 The list of network devices that will be registered against the brscan5
87 config = mkIf (config.hardware.sane.enable && cfg.enable) {
89 hardware.sane.extraBackends = [
93 environment.etc."opt/brother/scanner/brscan5" =
94 { source = "${etcFiles}/etc/opt/brother/scanner/brscan5"; };
95 environment.etc."opt/brother/scanner/models" =
96 { source = "${etcFiles}/etc/opt/brother/scanner/brscan5/models"; };
97 environment.etc."sane.d/dll.d/brother5.conf".source = "${pkgs.brscan5}/etc/sane.d/dll.d/brother5.conf";
100 { assertion = all (x: !(null != x.ip && null != x.nodename)) netDeviceList;
102 When describing a network device as part of the attribute list
103 `hardware.sane.brscan5.netDevices`, only one of its `ip` or `nodename`
104 attribute should be specified, not both!