flake: pull printing out into global modules

This commit is contained in:
Infinidoge 2025-03-11 14:05:31 -04:00
parent 28c5624eb8
commit e941f94e3c
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A
6 changed files with 58 additions and 89 deletions

View file

@ -0,0 +1,20 @@
{
config,
lib,
pkgs,
...
}:
lib.mkIf config.services.printing.enable {
services.printing.drivers = with pkgs; [
tmx-cups-ppd
];
hardware.printers.ensurePrinters = [
{
name = "EPSON-TM-m30";
deviceUri = "usb://EPSON/TM-m30II-NT?serial=5839394D0032780000";
model = "tm-m30-rastertotmt.ppd.gz";
}
];
}

34
modules/global/purdue.nix Normal file
View file

@ -0,0 +1,34 @@
{
config,
lib,
private,
...
}:
lib.mkIf config.info.loc.purdue {
hardware.printers = {
ensureDefaultPrinter = "printing";
ensurePrinters =
let
itap = name: {
inherit name;
#deviceUri = "lpd://${private.variables.purdue-username}@wpvapppcprt02.itap.purdue.edu:515/itap-${name}";
deviceUri = "lpd://${private.variables.purdue-username}@128.210.210.41:515/itap-${name}";
model = "drv:///sample.drv/generic.ppd";
ppdOptions = {
Duplex = "DuplexNoTumble";
Option1 = "True"; # Duplexer
};
};
in
[
(itap "printing")
(itap "colorprinting")
];
};
services.printing.browsedConf = ''
BrowseRemoteProtocols none
'';
}

View file

@ -1,54 +0,0 @@
{
config,
lib,
private,
...
}:
with lib;
with lib.our;
let
cfg = config.modules.hardware.peripherals.printing;
in
{
options.modules.hardware.peripherals.printing = with types; {
enable = mkBoolOpt false;
drivers = mkOpt (listOf path) [ ];
};
config = mkIf cfg.enable (mkMerge [
{
services.printing = {
enable = true;
inherit (cfg) drivers;
};
}
(mkIf config.info.loc.purdue {
hardware.printers = {
ensureDefaultPrinter = "printing";
ensurePrinters =
let
itap = name: {
inherit name;
#deviceUri = "lpd://${private.variables.purdue-username}@wpvapppcprt02.itap.purdue.edu:515/itap-${name}";
deviceUri = "lpd://${private.variables.purdue-username}@128.210.210.41:515/itap-${name}";
model = "drv:///sample.drv/generic.ppd";
ppdOptions = {
Duplex = "DuplexNoTumble";
Option1 = "True"; # Duplexer
};
};
in
[
(itap "printing")
(itap "colorprinting")
];
};
services.printing.browsedConf = ''
BrowseRemoteProtocols none
'';
})
]);
}