From 1085ca5c51c281592c9c5b02af07c1b31d5feff0 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 26 Jul 2025 14:17:46 +0200 Subject: modules/printing: Make printer config state-full The printer can be offline when starting the system, or it can be otherwise unreachable. --- modules/by-name/pi/printing/module.nix | 54 ---------------------------------- modules/by-name/pr/printing/module.nix | 44 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 54 deletions(-) delete mode 100644 modules/by-name/pi/printing/module.nix create mode 100644 modules/by-name/pr/printing/module.nix (limited to 'modules/by-name') diff --git a/modules/by-name/pi/printing/module.nix b/modules/by-name/pi/printing/module.nix deleted file mode 100644 index cfcd2154..00000000 --- a/modules/by-name/pi/printing/module.nix +++ /dev/null @@ -1,54 +0,0 @@ -# nixos-config - My current NixOS configuration -# -# Copyright (C) 2025 Benedikt Peetz -# SPDX-License-Identifier: GPL-3.0-or-later -# -# This file is part of my nixos-config. -# -# You should have received a copy of the License along with this program. -# If not, see . -{ - config, - lib, - ... -}: let - cfg = config.soispha.services.printing; -in { - options.soispha.services.printing = { - enable = lib.mkEnableOption "default printing configuration"; - }; - - config = lib.mkIf cfg.enable { - services.avahi = { - enable = true; - nssmdns4 = true; - nssmdns6 = true; - openFirewall = true; - }; - - services.printing = { - enable = true; - startWhenNeeded = true; - webInterface = true; - - # deletes `/var/cache/cups`, `/var/lib/cups` and `/var/spool/cups` on cups startup - stateless = true; - - drivers = []; - }; - - hardware = { - printers = { - ensurePrinters = [ - { - name = "Brother"; - description = "Brother DCP-9022CDW"; - model = "everywhere"; - deviceUri = "dnssd://Brother%20DCP-9022CDW._ipp._tcp.local/?uuid=e3248000-80ce-11db-8000-30055c773bcf"; - } - ]; - ensureDefaultPrinter = "Brother"; - }; - }; - }; -} diff --git a/modules/by-name/pr/printing/module.nix b/modules/by-name/pr/printing/module.nix new file mode 100644 index 00000000..c3283cbf --- /dev/null +++ b/modules/by-name/pr/printing/module.nix @@ -0,0 +1,44 @@ +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of my nixos-config. +# +# You should have received a copy of the License along with this program. +# If not, see . +{ + config, + lib, + ... +}: let + cfg = config.soispha.services.printing; +in { + options.soispha.services.printing = { + enable = lib.mkEnableOption "default printing configuration"; + }; + + config = lib.mkIf cfg.enable { + soispha.impermanence.directories = [ + "/var/lib/cups" + ]; + + services.avahi = { + enable = true; + nssmdns4 = true; + nssmdns6 = true; + openFirewall = true; + }; + + services.printing = { + enable = true; + startWhenNeeded = true; + webInterface = true; + + # deletes `/var/cache/cups`, `/var/lib/cups` and `/var/spool/cups` on cups startup + stateless = false; + + drivers = []; + }; + }; +} -- cgit 1.4.1