summaryrefslogtreecommitdiffstats
path: root/configs/br.nix
blob: b9bc70b26c3366f51c49cac6035c708c007f40df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ config, lib, modulesPath, mylib, pkgs, ... }: {

  imports = [
    (modulesPath + "/services/hardware/sane_extra_backends/brscan4.nix")
  ];

  krebs.nixpkgs.allowUnfreePredicate =
    pkg: lib.any (mylib.eq (mylib.packageName pkg)) [
      "brother-udev-rule-type1"
      "brscan4"
      "brscan4-etc-files"
      "mfcl2700dnlpr"
    ];

  hardware.sane = {
    enable = true;
    brscan4 = {
      enable = true;
      netDevices = {
        bra = {
          model = "MFCL2700DN";
          ip = "10.23.1.214";
        };
      };
    };
  };

  services.saned.enable = true;

  # usage: scanimage -d "$(find-scanner bra)" --batch --format=tiff --resolution 150  -x 211 -y 298
  environment.systemPackages = [
    (pkgs.writeDashBin "find-scanner" ''
      set -efu
      name=$1
      ${pkgs.sane-backends}/bin/scanimage -f '%m %d
      ' \
      | ${pkgs.gawk}/bin/awk -v dev="*$name" '$1 == dev { print $2; exit }' \
      | ${pkgs.gnugrep}/bin/grep .
    '')
  ];

  services.printing = {
    enable = true;
    drivers = [
      pkgs.mfcl2700dncupswrapper
    ];
  };

}