Merge pull request #290240 from rhoriguchi/nixos/hardware/printers

nixos/hardware/printers: fix empty ppdOptions
This commit is contained in:
Michele Guerini Rocco 2024-02-26 00:08:00 +01:00 committed by GitHub
commit 9fcbb05a2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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}'
'';