summaryrefslogtreecommitdiff
path: root/sys/hardware/printing.nix
blob: 8280da9754a893c70761cdb5d2c85d213206f1b6 (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
{ config, lib, ... }:
with lib; let
  cfg = config.local.hardware.printing;
in
{
  options.local.hardware.printing = {
    enable = mkEnableOption "print and scan services";

    users = mkOption {
      type = with types; listOf str;
      default = [ ];
    };
  };

  config = mkIf cfg.enable {
    services.avahi = {
      enable = true;
      nssmdns4 = true;
      openFirewall = true;
    };

    hardware.sane.enable = true;
    services.printing.enable = true;

    users.users = listToAttrs (map
      (user: {
        name = user;
        value.extraGroups = [ "scanner" "lp" ];
      })
      cfg.users);
  };
}