From 382763e37e4eda0e88af73d6c258e721c4ae90e2 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 17 Jul 2016 19:24:28 +0200 Subject: thermoprint on bragi --- bragi.nix | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++- custom/thermoprint | 2 +- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/bragi.nix b/bragi.nix index 42fccd75..5a73c3b6 100644 --- a/bragi.nix +++ b/bragi.nix @@ -80,6 +80,8 @@ in rec { --run "umask 0" ''; }); + + inherit (pkgs.callPackage ./custom/thermoprint {}) thermoprint-server thermoprint-webgui tprint; }; environment.systemPackages = with pkgs; [ @@ -91,6 +93,7 @@ in rec { jack2Full trivmix zsh + tprint ]; # List services that you want to enable: @@ -272,10 +275,60 @@ in rec { home = "/var/lib/thermoprint"; }; + environment.etc."thermoprint-server/config.hs" = '' + {-# LANGUAGE OverloadedStrings #-} + {-# LANGUAGE ImpredicativeTypes #-} + + module Main (main) where + + import Thermoprint.Server + + import Thermoprint.Server.Printer.Generic + + import Control.Monad.Trans.Resource + import Control.Monad.Logger + import Control.Monad.Reader + + import Database.Persist.Sqlite + + import qualified Network.Wai.Handler.Warp as Warp + + main :: IO () + main = thermoprintServer True (Nat runSqlite) $ (\c -> c { queueManagers = queueManagers, warpSettings = wSettings }) <$> def `withPrinters` printers + where + runSqlite :: ReaderT ConnectionPool (LoggingT IO) a -> IO a + runSqlite = runStderrLoggingT . withSqlitePool "${users.extraUsers."thermoprint".home}/thermoprint.sqlite" 1 . runReaderT + + printers = [ (pure $ genericPrint "/dev/usb/lp0", def) + ] + + queueManagers _ = QMConfig + { manager = union [ limitHistorySize 100 + , limitHistoryAge 3600 + ] + , collapse = standardCollapse + } + + wSettings = setHost "*" . Warp.setPort 8080 $ Warp.defaultSettings + ''; + systemd.services."thermoprint" = { + environment = { + THERMOPRINT_CONFIG = "/etc/thermoprint-server"; + THERMOPRINT_CACHE = ${users.extraUsers."thermoprint".home}"/dyre"; + }; + serviceConfig = { + Type = "simple"; + ExecStart = ''${pkgs.thermoprint-server}/bin/thermoprint-server''; + User = users.extraUsers."thermoprint".name; + Group = users.extraUsers."thermoprint".group; + }; + }; + + systemd.services."thermoprint-webgui" = { serviceConfig = { Type = "simple"; - ExecStart = ''${thermoprint-servant}/bin/thermoprint --database ${users.extraUsers."thermoprint".home}/database.sqlite /dev/usb/lp0''; + ExecStart = '''${pkgs.thermoprint-webgui}/bin/thermoprint-webgui -P 8080 -A localhost -a "*" -p 8081'; User = users.extraUsers."thermoprint".name; Group = users.extraUsers."thermoprint".group; }; diff --git a/custom/thermoprint b/custom/thermoprint index 7f841920..2b9ceaea 160000 --- a/custom/thermoprint +++ b/custom/thermoprint @@ -1 +1 @@ -Subproject commit 7f84192054e2f3c2e379588b15cf73aaecfbad0b +Subproject commit 2b9ceaead3f3cd80e973cccecb9a3eebc51154f7 -- cgit v1.2.3