Merge pull request #290240 from rhoriguchi/nixos/hardware/printers
nixos/hardware/printers: fix empty ppdOptions
This commit is contained in:
commit
9fcbb05a2c
1 changed files with 16 additions and 11 deletions
|
@ -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}'
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue