2022-12-16 12:13:36 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
2023-11-11 18:56:56 +01:00
|
|
|
cfg = config.my.system.printing;
|
2022-12-16 12:13:36 +01:00
|
|
|
in
|
|
|
|
{
|
2023-11-11 18:56:56 +01:00
|
|
|
options.my.system.printing = with lib; {
|
|
|
|
enable = mkEnableOption "printing configuration";
|
2022-12-16 12:13:36 +01:00
|
|
|
|
2022-12-16 12:34:01 +01:00
|
|
|
papersize = mkOption {
|
|
|
|
type = with types; either str (enum [
|
|
|
|
"a3"
|
|
|
|
"a4"
|
|
|
|
"a5"
|
|
|
|
"b5"
|
|
|
|
"letter"
|
|
|
|
"legal"
|
|
|
|
"executive"
|
|
|
|
"note"
|
|
|
|
"11x17"
|
|
|
|
]);
|
|
|
|
default = "a4";
|
|
|
|
example = "paper";
|
|
|
|
description = "preferred paper size";
|
|
|
|
};
|
|
|
|
|
2022-12-16 12:13:36 +01:00
|
|
|
usb = {
|
|
|
|
enable = my.mkDisableOption "USB printers";
|
|
|
|
};
|
|
|
|
|
|
|
|
network = {
|
|
|
|
enable = my.mkDisableOption "network printers";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
# Setup CUPS
|
|
|
|
services.printing = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# Drivers are deprecated, but just in case
|
|
|
|
drivers = with pkgs; [
|
|
|
|
gutenprint # Base set of drivers
|
|
|
|
brlaser # Brother drivers
|
|
|
|
|
|
|
|
# Brother MFC-L3770CDW
|
|
|
|
mfcl3770cdwlpr
|
|
|
|
mfcl3770cdwcupswrapper
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2022-12-16 12:34:01 +01:00
|
|
|
# Setup paper size
|
|
|
|
systemd.services.cups.serviceConfig.Environment = [
|
|
|
|
"PAPERSIZE=${cfg.papersize}"
|
|
|
|
];
|
|
|
|
|
2022-12-16 12:13:36 +01:00
|
|
|
# Allow using USB printers
|
|
|
|
services.ipp-usb = lib.mkIf cfg.usb.enable {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Allow using WiFi printers
|
|
|
|
services.avahi = lib.mkIf cfg.network.enable {
|
|
|
|
enable = true;
|
|
|
|
openFirewall = true;
|
|
|
|
# Allow resolution of '.local' addresses
|
2023-12-14 14:55:45 +01:00
|
|
|
nssmdns4 = true;
|
2022-12-16 12:13:36 +01:00
|
|
|
};
|
2021-11-03 14:43:16 +01:00
|
|
|
|
|
|
|
# FIXME: persistence?
|
2022-12-16 12:13:36 +01:00
|
|
|
};
|
|
|
|
}
|