This commit is contained in:
Peder Bergebakken Sundt 2024-11-02 18:42:16 +01:00
parent 1cc5901241
commit 9dec14bc80
4 changed files with 77 additions and 2 deletions

View File

@ -0,0 +1,56 @@
{ lib, pkgs, ... }:
{
# airprint
# https://wiki.nixos.org/wiki/Printing#Printer_sharing
services.avahi = {
enable = lib.mkDefault true;
nssmdns = true;
openFirewall = true; # opens port 5353
publish.enable = true;
publish.userServices = true;
};
services.printing = {
defaultShared = true;
browsing = true;
# allows anonymous access to printer
listenAddresses = [ "*:631" ];
allowFrom = [ "all" ];
openFirewall = true;
};
# samba
# https://wiki.nixos.org/wiki/Samba#Printer_sharing
/** /
services.samba = {
enable = lib.mkDefault true;
package = pkgs.sambaFull; # compiled with CUPS
openFirewall = true;
settings = {
"global" = {
"load printers" = "yes";
"printing" = "cups";
"printcap name" = "cups";
};
"printers" = {
"comment" = "All Printers";
"path" = "/var/spool/samba";
"public" = "yes";
"browseable" = "yes";
# allow user 'guest account' to print.
"guest ok" = "yes";
"writable" = "no";
"printable" = "yes";
"create mode" = 0700;
};
};
systemd.tmpfiles.rules = [
"d /var/spool/samba 1777 root root -"
];
/**/
}

View File

@ -1,5 +1,9 @@
{ lib, pkgs, ... }: { lib, pkgs, ... }:
{ {
imports = [
./common-share.nix
];
# https://nixos.wiki/wiki/Printing # https://nixos.wiki/wiki/Printing
services.printing.enable = true; services.printing.enable = true;
#services.printing.drivers = with pkgs; [ foo2zjs foomatic-filters cups-filters ]; #services.printing.drivers = with pkgs; [ foo2zjs foomatic-filters cups-filters ];

View File

@ -35,6 +35,8 @@
../../../profiles/desktop/flatpak.nix ../../../profiles/desktop/flatpak.nix
../../../profiles/desktop/waydroid.nix ../../../profiles/desktop/waydroid.nix
../../../profiles/printing.nix
../../../profiles/known-hosts.nix ../../../profiles/known-hosts.nix
]; ];
@ -52,8 +54,6 @@
#networking.useDHCP = true; #networking.useDHCP = true;
#TODO: avahi? resolved? https://git.pvv.ntnu.no/Drift/pvv-nixos-config/src/main/base.nix#L15-L18 #TODO: avahi? resolved? https://git.pvv.ntnu.no/Drift/pvv-nixos-config/src/main/base.nix#L15-L18
services.printing.enable = true;
# TODO: remove? Move? # TODO: remove? Move?
programs.dconf.enable = true; programs.dconf.enable = true;
} }

15
profiles/printing.nix Normal file
View File

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
# https://wiki.nixos.org/wiki/Printing
services.printing.enable = true;
# Enable autodiscovery of network IPP printers
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true; # opens port 5353
};
}