Enable printing in system

This commit is contained in:
2026-05-23 13:10:51 +02:00
parent b5b05ac620
commit fc32cf76ea
2 changed files with 218 additions and 31 deletions

View File

@@ -8,9 +8,12 @@ in
./file-system.nix
./media.nix
./security/keyring.nix
./printer.nix
];
environment.systemPackages = with pkgs; [
environment.systemPackages =
with pkgs;
[
gnumake
python3
]
@@ -42,5 +45,4 @@ in
environment.variables = {
};
}

View File

@@ -0,0 +1,185 @@
# Optional stuff to add to profile:
# add your user to scanner/lp groups if needed:
# users.users.<name>.extraGroups = [ "scanner" "lp" ];
{
config,
pkgs,
lib,
...
}:
{
##########################################################################
# Printing
##########################################################################
services.printing = {
enable = true;
# Driver collection
drivers = with pkgs; [
gutenprint
hplip
brlaser
# Canon inkjet support
cnijfilter2
# Generic IPP/AirPrint support
cups-filters
];
# Network printer discovery
browsing = true;
defaultShared = false;
listenAddresses = [ "*:631" ];
allowFrom = [ "all" ];
};
# Avahi/mDNS for automatic printer discovery
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
publish = {
enable = true;
userServices = true;
};
};
# Scanner discovery over network
hardware.sane = {
enable = true;
extraBackends = with pkgs; [
sane-airscan
brscan4
epson-escpr
];
};
# Enable sane daemon
services.saned.enable = true;
# Some Brother scanners need this
environment.etc."sane.d/dll.d/brother".text = ''
brother4
'';
##########################################################################
# OCR / PDF / Document Processing
##########################################################################
environment.systemPackages = with pkgs; [
######################################################################
# Printing / scanning GUI tools
######################################################################
system-config-printer
simple-scan
xsane
sane-airscan
######################################################################
# OCR
######################################################################
tesseract
tesseract4
ocrmypdf
######################################################################
# PDF tools
######################################################################
poppler-utils
pdftk
qpdf
pdfcpu
mupdf
######################################################################
# Image processing
######################################################################
graphicsmagick
######################################################################
# EPUB / HTML / Markdown / TeX conversions
######################################################################
pandoc
######################################################################
# Extra document tooling
######################################################################
ghostscript
djvulibre
unoconv
######################################################################
# CLI helpers
######################################################################
file
ripgrep
fd
jq
];
##########################################################################
# Firewall
##########################################################################
networking.firewall.allowedTCPPorts = [
631 # CUPS / IPP
];
networking.firewall.allowedUDPPorts = [
5353 # mDNS / Avahi
];
##########################################################################
# Helpful shell aliases
##########################################################################
environment.shellAliases = {
# Find printers/scanners
printers = "lpstat -e";
scanner-find = "scanimage -L";
# OCR examples
ocr-pdf = "ocrmypdf";
ocr-img = "tesseract";
# Convert markdown -> pdf
md2pdf = "pandoc -o output.pdf";
# Convert epub -> pdf
epub2pdf = "ebook-convert";
# Convert pdf -> text
pdf2txt = "pdftotext";
# Scan one page
scan-one = ''
scanimage --format=png > scan.png
'';
# Continuous scans until CTRL+C
scan-loop = ''
while true; do
TS=$(date +%s)
scanimage --format=png > scan-$TS.png
echo "scanned: scan-$TS.png"
sleep 1
done
'';
};
}