From a414e85e51b52e4c44fc398b07d75c8216eb8213 Mon Sep 17 00:00:00 2001 From: Tim Schubert Date: Sat, 12 Jul 2025 09:56:07 +0200 Subject: [PATCH] feat: add driver package for ticket printer --- nixos/gorgon/configuration.nix | 1 + nixos/ninurta/printing.nix | 7 +++- pkgs/citizen-cups.nix | 70 ++++++++++++++++++++++++++++++++++ pkgs/default.nix | 4 +- 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 pkgs/citizen-cups.nix diff --git a/nixos/gorgon/configuration.nix b/nixos/gorgon/configuration.nix index 0f14aa9..d34d0e7 100644 --- a/nixos/gorgon/configuration.nix +++ b/nixos/gorgon/configuration.nix @@ -128,6 +128,7 @@ in enable = true; browsing = true; drivers = with pkgs; [ + config.dadada.pkgs.citizen-cups hplip brlaser brgenml1lpr diff --git a/nixos/ninurta/printing.nix b/nixos/ninurta/printing.nix index e22c989..c1d2aa8 100644 --- a/nixos/ninurta/printing.nix +++ b/nixos/ninurta/printing.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ cfg, pkgs, ... }: { hardware = { printers = { @@ -29,7 +29,10 @@ services.printing = { enable = true; - drivers = [ pkgs.brlaser ]; + drivers = [ + pkgs.brlaser + pkgs.gutenprint + ]; # Remove all state at the start of the service stateless = true; listenAddresses = [ "192.168.101.29:631" ]; diff --git a/pkgs/citizen-cups.nix b/pkgs/citizen-cups.nix new file mode 100644 index 0000000..9a63bdd --- /dev/null +++ b/pkgs/citizen-cups.nix @@ -0,0 +1,70 @@ +{ + cups, + fetchzip, + lib, + stdenv, + rpm, +}: + +let + version = "1.2.8"; +in +stdenv.mkDerivation { + inherit version; + name = "citizen-cups"; + pname = "citizen-cups"; + + src = fetchzip { + url = "https://www.citizen-systems.com/resource/support/POS/Generic_Printer_Files/CUPS_Linux_Driver/CUPS_Linux_Driver.zip"; + hash = "sha256-2ha24/7oS/rINKmYxyVryX66kkc6niCChxhw/2KOPSw="; + }; + + nativeBuildInputs = [ + rpm + ]; + + buildInputs = [ + cups + ]; + + postUnpack = '' + pushd source + ls -la + rpm2archive ctzpos-cups-1.2.8-0.src.rpm + tar xvf ctzpos-cups-1.2.8-0.src.rpm.tgz + tar xvf ctzpos-cups-1.2.8.tar.bz2 + popd + ''; + + buildPhase = '' + runHook preBuild + pushd "ctzpos-cups-${version}"; + gcc -Wl,-rpath,/usr/lib -Wall -fPIC -O2 -o rastertocbm1k rastertocbm1k.c -lcupsimage -lcups + gcc -Wl,-rpath,/usr/lib -Wall -fPIC -O2 -o rastertocds500 rastertocds500.c -lcupsimage -lcups + gcc -Wl,-rpath,/usr/lib -Wall -fPIC -O2 -o rastertocts2kl rastertocts2kl.c -lcupsimage -lcups + popd + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib/cups/filter + install -D -m 755 ./ctzpos-cups-${version}/rastertocbm1k $out/lib/cups/filter/rastertocbm1k + install -D -m 755 ./ctzpos-cups-${version}/rastertocds500 $out/lib/cups/filter/rastertocds500 + install -D -m 755 ./ctzpos-cups-${version}/rastertocts2kl $out/lib/cups/filter/rastertocts2kl + + mkdir -p $out/share/cups/model/citizen + install -D -m 644 ./ctzpos-cups-${version}/*.ppd $out/share/cups/model/citizen + + runHook postInstall + ''; + + meta = with lib; { + description = "Citizen CUPS drivers and filters"; + homepage = "https://www.citizen-systems.com"; + #license = licenses.unfreeRedistributable; + maintainers = with maintainers; [ dadada ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 9fce6e9..9cd9053 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1 +1,3 @@ -{ pkgs }: { } +{ pkgs }: { + citizen-cups = pkgs.callPackage ./citizen-cups.nix {}; +}