1 { config, lib, pkgs, ... }:
6 cfg = config.hardware.sane.brscan4;
8 netDeviceList = attrValues cfg.netDevices;
10 etcFiles = pkgs.callPackage ./brscan4_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.
32 example = "MFC-7860DW";
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.brscan4.enable =
71 mkEnableOption "Brother's brscan4 scan backend" // {
73 When enabled, will automatically register the "brscan4" sane
74 backend and bring configuration files to their expected location.
78 hardware.sane.brscan4.netDevices = mkOption {
81 { office1 = { model = "MFC-7860DW"; ip = "192.168.1.2"; };
82 office2 = { model = "MFC-7860DW"; nodename = "BRW0080927AFBCE"; };
84 type = with types; attrsOf (submodule netDeviceOpts);
86 The list of network devices that will be registered against the brscan4
92 config = mkIf (config.hardware.sane.enable && cfg.enable) {
94 hardware.sane.extraBackends = [
98 environment.etc."opt/brother/scanner/brscan4" =
99 { source = "${etcFiles}/etc/opt/brother/scanner/brscan4"; };
102 { assertion = all (x: !(null != x.ip && null != x.nodename)) netDeviceList;
104 When describing a network device as part of the attribute list
105 `hardware.sane.brscan4.netDevices`, only one of its `ip` or `nodename`
106 attribute should be specified, not both!