186 lines
4.1 KiB
Nix
186 lines
4.1 KiB
Nix
# 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
|
|
'';
|
|
};
|
|
}
|