2024-07-14 14:50:46 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
2024-06-19 17:22:02 +00:00
|
|
|
inherit (lib) mkIf optional;
|
2024-04-13 19:15:25 +00:00
|
|
|
deviceType = config.myOptions.device.roles.type;
|
|
|
|
acceptedTypes = ["laptop" "desktop"];
|
2024-04-13 18:10:01 +00:00
|
|
|
|
|
|
|
cfg = config.myOptions.workstation.printing;
|
2024-07-14 14:50:46 +00:00
|
|
|
cfgUser = config.myOptions.system.username;
|
2024-04-13 18:10:01 +00:00
|
|
|
in {
|
2024-04-13 19:15:25 +00:00
|
|
|
config = mkIf (builtins.elem deviceType acceptedTypes && cfg.enable) {
|
2024-04-13 18:10:01 +00:00
|
|
|
# enable cups and add some drivers for common printers
|
|
|
|
services = {
|
|
|
|
printing = {
|
|
|
|
enable = true;
|
|
|
|
drivers = with pkgs; [
|
|
|
|
gutenprint
|
|
|
|
hplip
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# required for network discovery of printers
|
|
|
|
avahi = {
|
|
|
|
enable = true;
|
|
|
|
# resolve .local domains for printers
|
|
|
|
nssmdns4 = true;
|
|
|
|
# open the avahi port(s) in the firewall
|
|
|
|
openFirewall = true;
|
|
|
|
};
|
|
|
|
};
|
2024-06-19 17:22:02 +00:00
|
|
|
|
|
|
|
environment.systemPackages = optional cfg.hplip.enable pkgs.hplip;
|
|
|
|
myOptions.system.impermanence.home.extraDirectories = optional cfg.hplip.enable ".hplip";
|
2024-07-14 14:50:46 +00:00
|
|
|
|
|
|
|
# Support for SANE (Scanner Access Now Easy) scanners
|
2024-08-22 00:23:16 +00:00
|
|
|
hardware.sane = {
|
|
|
|
enable = true;
|
|
|
|
extraBackends = optional cfg.hplip.enable pkgs.hplipWithPlugin;
|
|
|
|
};
|
2024-07-14 14:50:46 +00:00
|
|
|
|
|
|
|
users.extraGroups.scanner.members = ["${cfgUser}"];
|
|
|
|
users.extraGroups.lp.members = ["${cfgUser}"];
|
2024-04-13 18:10:01 +00:00
|
|
|
};
|
|
|
|
}
|