mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-17 12:50:04 +00:00
nixos/printers: assert that each class contains at least one printer or class (#564028)
This commit is contained in:
@@ -78,11 +78,6 @@ in
|
||||
config.hardware.printers.ensurePrinters. Specifying a symblic
|
||||
name here that does not match any of those printers is
|
||||
considered a hard error.
|
||||
|
||||
::: {.warning}
|
||||
Print jobs to this class will quietly fail if there are no
|
||||
printers in this class. CUPS reports them as pending
|
||||
:::
|
||||
'';
|
||||
};
|
||||
classes = mkOption {
|
||||
@@ -267,7 +262,14 @@ in
|
||||
'';
|
||||
}
|
||||
)
|
||||
];
|
||||
]
|
||||
++ map (class: {
|
||||
assertion = cfg.ensureClasses.${class}.printers != [ ] || cfg.ensureClasses.${class}.classes != [ ];
|
||||
message = ''
|
||||
At least one of the lists `config.hardware.printers.ensureClasses.${class}.printers`
|
||||
and `config.hardware.printers.ensureClasses.${class}.classes` has to be non-empty.
|
||||
'';
|
||||
}) (builtins.attrNames cfg.ensureClasses);
|
||||
|
||||
systemd.services.cups = {
|
||||
postStart =
|
||||
@@ -333,17 +335,6 @@ in
|
||||
d = cfg.ensureDefaultPrinter;
|
||||
})}
|
||||
|
||||
#### CLASS DEFINITIONS ####
|
||||
lpadmin -p _tmp -v file:/dev/null
|
||||
${lib.concatMapStringsSep "\n" (
|
||||
className:
|
||||
lpadmin {
|
||||
p = "_tmp";
|
||||
c = className;
|
||||
}
|
||||
) classNames}
|
||||
lpadmin -x _tmp
|
||||
|
||||
#### ADDING PRINTERS TO CLASSES ####
|
||||
${lib.concatMapStringsSep "\n" (
|
||||
className:
|
||||
|
||||
Reference in New Issue
Block a user