nixdots/system/roles/workstation/services/printing.nix
ItsDrike 00016063fe
Use roles properly
Originally, I was including all role configurations for all hosts, and
controlling which get applied in the role configs with a check in each
file. This is a very repetetive and annoying approach. Instead, now the
role directory is included manually from the hosts config for devices
which meet that role, removing the role options.
2024-09-24 11:42:40 +02:00

46 lines
1.1 KiB
Nix

{
pkgs,
lib,
config,
...
}: let
inherit (lib) mkIf optional;
cfg = config.myOptions.workstation.printing;
cfgUser = config.myOptions.system.username;
in {
config = mkIf cfg.enable {
# 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;
};
};
environment.systemPackages = optional cfg.hplip.enable pkgs.hplip;
myOptions.system.impermanence.home.extraDirectories = optional cfg.hplip.enable ".hplip";
# Support for SANE (Scanner Access Now Easy) scanners
hardware.sane = {
enable = true;
extraBackends = optional cfg.hplip.enable pkgs.hplipWithPlugin;
};
users.extraGroups.scanner.members = ["${cfgUser}"];
users.extraGroups.lp.members = ["${cfgUser}"];
};
}