Files
nixos/roles/printserver.nix

66 lines
1.3 KiB
Nix

# Module: roles/printserver
# Enables a CUPS print server for sharing connected printers on the network
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.printserver;
in
{
options.printserver = {
enable = mkEnableOption "Enables printserver role";
ippAddresses = mkOption {
type = types.listOf types.str;
default = [ "*:631" ];
description = "Refer to services.printing.listenAddresses";
example = [ "*:631" ];
};
allowFromAddresses = mkOption {
type = types.listOf types.str;
default = [ "all" ];
description = "Refer to services.printing.allowFrom";
example = [ "all" ];
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
cups
gutenprint
];
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
publish = {
enable = true;
userServices = true;
addresses = true;
workstation = true;
hinfo = true;
domain = true;
};
};
services.printing = {
enable = true;
listenAddresses = cfg.ippAddresses;
allowFrom = cfg.allowFromAddresses;
browsing = true;
defaultShared = true;
openFirewall = true;
webInterface = true;
drivers = [ pkgs.gutenprint ];
};
};
}