From c4cf38ceb390cfb2bf2eba316ff3823a224f0c1e Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Mon, 26 Jun 2023 12:04:34 +0200 Subject: [PATCH] [Desktop/Printing] Move printing related config to dedicated file --- desktop/default.nix | 1 + desktop/printing.nix | 74 ++++++++++++++++++++++++++++++++++++++++++++ services.nix | 70 +++-------------------------------------- 3 files changed, 79 insertions(+), 66 deletions(-) create mode 100644 desktop/printing.nix diff --git a/desktop/default.nix b/desktop/default.nix index 387cc7e..6614137 100644 --- a/desktop/default.nix +++ b/desktop/default.nix @@ -9,5 +9,6 @@ with lib; ./games.nix ./browser.nix ./gnome.nix + ./printing.nix ]; } diff --git a/desktop/printing.nix b/desktop/printing.nix new file mode 100644 index 0000000..caaedb8 --- /dev/null +++ b/desktop/printing.nix @@ -0,0 +1,74 @@ +{ config, pkgs, lib, ... }: +with lib; +let + cfg = config.aviallon.desktop; + generalCfg = config.aviallon.general; +in { + config = mkIf (cfg.enable && !generalCfg.minimal) { + services.printing = { + enable = true; + defaultShared = mkDefault true; + browsing = mkDefault true; + listenAddresses = [ "0.0.0.0:631" ]; + drivers = with pkgs; [] + ++ (optionals (!generalCfg.minimal) [ + hplipWithPlugin + gutenprint + splix + brlaser + cups-bjnp + # cups-dymo + # cups-zj-58 + # cups-kyocera + cups-filters + carps-cups + # cups-kyodialog3 + cups-brother-hl1110 + cups-toshiba-estudio + cups-brother-hl1210w + hll2390dw-cups + cups-brother-hl3140cw + cups-brother-hll2340dw + cups-drv-rastertosag-gdi + # cups-kyocera-ecosys-m552x-p502x + canon-cups-ufr2 + ]); + webInterface = mkDefault true; + }; + services.system-config-printer.enable = true; + + hardware.sane = { + enable = true; + netConf = "192.168.0.0/24"; + extraBackends = with pkgs; [ + hplipWithPlugin + ]; + }; + + networking.firewall.allowedTCPPorts = optionals config.services.printing.enable [ 631 139 445 ]; + networking.firewall.allowedUDPPorts = optionals config.services.printing.enable [ 137 ]; + + + aviallon.programs.allowUnfreeList = [ + "hplip" + "hplipWithPlugin" + "cups-bjnp" + "cups-dymo" + "cups-zj-58" + "cups-kyocera" + "cups-filters" + "carps-cups" + "cups-kyodialog3" + "cups-brother-hl1110" + "cups-toshiba-estudio" + "cups-brother-hl1210w" + "cups-brother-hl1210W" + "hll2390dw-cups" + "cups-brother-hl3140cw" + "cups-brother-hll2340dw" + "cups-drv-rastertosag-gdi" + "cups-kyocera-ecosys-m552x-p502x" + "canon-cups-ufr2" + ]; + }; +} diff --git a/services.nix b/services.nix index adcc59e..686bfd4 100644 --- a/services.nix +++ b/services.nix @@ -76,10 +76,10 @@ in { programs.ssh.forwardX11 = mkDefault config.services.xserver.enable; security.pam.services.sudo.forwardXAuth = mkDefault true; # Easier to start GUI programs as root - networking.firewall.allowedTCPPorts = [ 22 ] - ++ optionals config.services.printing.enable [ 631 139 445 ]; - networking.firewall.allowedUDPPorts = [ 22 5353 ] - ++ optionals config.services.printing.enable [ 137 ]; + + + networking.firewall.allowedTCPPorts = [ 22 ]; + networking.firewall.allowedUDPPorts = [ 22 5353 ]; services.rsyncd.enable = !desktopCfg.enable; @@ -89,68 +89,6 @@ in { services.irqbalance.enable = true; - services.printing = mkIf desktopCfg.enable { - enable = true; - defaultShared = mkDefault true; - browsing = mkDefault true; - listenAddresses = [ "0.0.0.0:631" ]; - drivers = with pkgs; [] - ++ (optionals (!generalCfg.minimal) [ - hplipWithPlugin - gutenprint - splix - brlaser - cups-bjnp - # cups-dymo - # cups-zj-58 - # cups-kyocera - cups-filters - carps-cups - # cups-kyodialog3 - cups-brother-hl1110 - cups-toshiba-estudio - cups-brother-hl1210w - hll2390dw-cups - cups-brother-hl3140cw - cups-brother-hll2340dw - cups-drv-rastertosag-gdi - # cups-kyocera-ecosys-m552x-p502x - canon-cups-ufr2 - ]); - webInterface = mkDefault true; - }; - services.system-config-printer.enable = mkIf (desktopCfg.enable && !generalCfg.minimal) true; - - hardware.sane = mkIf desktopCfg.enable { - enable = !generalCfg.minimal; - netConf = "192.168.0.0/24"; - extraBackends = with pkgs; [ - hplipWithPlugin - ]; - }; - - aviallon.programs.allowUnfreeList = [ - "hplip" - "hplipWithPlugin" - "cups-bjnp" - "cups-dymo" - "cups-zj-58" - "cups-kyocera" - "cups-filters" - "carps-cups" - "cups-kyodialog3" - "cups-brother-hl1110" - "cups-toshiba-estudio" - "cups-brother-hl1210w" - "cups-brother-hl1210W" - "hll2390dw-cups" - "cups-brother-hl3140cw" - "cups-brother-hll2340dw" - "cups-drv-rastertosag-gdi" - "cups-kyocera-ecosys-m552x-p502x" - "canon-cups-ufr2" - ]; - services.fwupd.enable = true; services.journald.extraConfig = mkOverride 2 (journaldConfig cfg.journald.extraConfig);