diff options
author | Michele Guerini Rocco <rnhmjoj@users.noreply.github.com> | 2024-02-26 00:08:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 00:08:00 +0100 |
commit | 9fcbb05a2c0effc15f9dc2522112293b5007fc95 (patch) | |
tree | 5a4f59a6edb7ad69979e93e8ed75d09899718e5f | |
parent | 9fac9b397e631ef87a16314bedc55e805e29a2fd (diff) | |
parent | a52e27d4f637854e81dfd51da3b29627f7374513 (diff) |
Merge pull request #290240 from rhoriguchi/nixos/hardware/printers
nixos/hardware/printers: fix empty ppdOptions
-rw-r--r-- | nixos/modules/hardware/printers.nix | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/nixos/modules/hardware/printers.nix b/nixos/modules/hardware/printers.nix index 846ff6f3fb4f5..4fb6a192cdd2c 100644 --- a/nixos/modules/hardware/printers.nix +++ b/nixos/modules/hardware/printers.nix @@ -2,18 +2,23 @@ with lib; let cfg = config.hardware.printers; - ppdOptionsString = options: optionalString (options != {}) - (concatStringsSep " " - (mapAttrsToList (name: value: "-o '${name}'='${value}'") options) - ); - ensurePrinter = p: '' - ${pkgs.cups}/bin/lpadmin -p '${p.name}' -E \ - ${optionalString (p.location != null) "-L '${p.location}'"} \ - ${optionalString (p.description != null) "-D '${p.description}'"} \ - -v '${p.deviceUri}' \ - -m '${p.model}' \ - ${ppdOptionsString p.ppdOptions} + + ensurePrinter = p: let + args = cli.toGNUCommandLineShell {} ({ + p = p.name; + v = p.deviceUri; + m = p.model; + } // optionalAttrs (p.location != null) { + L = p.location; + } // optionalAttrs (p.description != null) { + D = p.description; + } // optionalAttrs (p.ppdOptions != {}) { + o = mapAttrsToList (name: value: "'${name}'='${value}'") p.ppdOptions; + }); + in '' + ${pkgs.cups}/bin/lpadmin ${args} -E ''; + ensureDefaultPrinter = name: '' ${pkgs.cups}/bin/lpadmin -d '${name}' ''; |