diff options
author | matthewcroughan <matt@croughan.sh> | 2022-10-17 22:59:24 +0100 |
---|---|---|
committer | matthewcroughan <matt@croughan.sh> | 2022-10-17 22:59:24 +0100 |
commit | a99ab1fbc16dfdbe4922aa30357886fd5e09e7a0 (patch) | |
tree | 2c15ef6284ae01f6470fef6f2799c3a20ed5fd4d /nixos/modules/services/printing | |
parent | 3bcc8e1ac7ec6040219acc8da4cda6df394cddb1 (diff) | |
download | nixlib-a99ab1fbc16dfdbe4922aa30357886fd5e09e7a0.tar nixlib-a99ab1fbc16dfdbe4922aa30357886fd5e09e7a0.tar.gz nixlib-a99ab1fbc16dfdbe4922aa30357886fd5e09e7a0.tar.bz2 nixlib-a99ab1fbc16dfdbe4922aa30357886fd5e09e7a0.tar.lz nixlib-a99ab1fbc16dfdbe4922aa30357886fd5e09e7a0.tar.xz nixlib-a99ab1fbc16dfdbe4922aa30357886fd5e09e7a0.tar.zst nixlib-a99ab1fbc16dfdbe4922aa30357886fd5e09e7a0.zip |
nixos/printing: add services.printing.stateless option
This will remove all state directories related to CUPS on startup, which is particularly useful for guaranteeing that printer discovery works more reliably on some networks, since CUPS will no longer be able to store state that effects the next run of the service, such as old printer names and mDNS information. Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'nixos/modules/services/printing')
-rw-r--r-- | nixos/modules/services/printing/cupsd.nix | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index fea7ffb673ca..ae59dcc226de 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -134,6 +134,15 @@ in ''; }; + stateless = mkOption { + type = types.bool; + default = false; + description = lib.mdDoc '' + If set, all state directories relating to CUPS will be removed on + startup of the service. + ''; + }; + startWhenNeeded = mkOption { type = types.bool; default = true; @@ -343,8 +352,9 @@ in path = [ cups.out ]; - preStart = - '' + preStart = lib.optionalString cfg.stateless '' + rm -rf /var/cache/cups /var/lib/cups /var/spool/cups + '' + '' mkdir -m 0700 -p /var/cache/cups mkdir -m 0700 -p /var/spool/cups mkdir -m 0755 -p ${cfg.tempDir} |