summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bragi.nix54
1 files changed, 28 insertions, 26 deletions
diff --git a/bragi.nix b/bragi.nix
index c85e0ace..0a7ca26e 100644
--- a/bragi.nix
+++ b/bragi.nix
@@ -275,42 +275,44 @@ in rec {
275 home = "/var/lib/thermoprint"; 275 home = "/var/lib/thermoprint";
276 }; 276 };
277 277
278 environment.etc."thermoprint-server/config.hs" = '' 278 environment.etc."thermoprint-server/config.hs" = {
279 {-# LANGUAGE OverloadedStrings #-} 279 text = ''
280 {-# LANGUAGE ImpredicativeTypes #-} 280 {-# LANGUAGE OverloadedStrings #-}
281 {-# LANGUAGE ImpredicativeTypes #-}
281 282
282 module Main (main) where 283 module Main (main) where
283 284
284 import Thermoprint.Server 285 import Thermoprint.Server
285 286
286 import Thermoprint.Server.Printer.Generic 287 import Thermoprint.Server.Printer.Generic
287 288
288 import Control.Monad.Trans.Resource 289 import Control.Monad.Trans.Resource
289 import Control.Monad.Logger 290 import Control.Monad.Logger
290 import Control.Monad.Reader 291 import Control.Monad.Reader
291 292
292 import Database.Persist.Sqlite 293 import Database.Persist.Sqlite
293 294
294 import qualified Network.Wai.Handler.Warp as Warp 295 import qualified Network.Wai.Handler.Warp as Warp
295 296
296 main :: IO () 297 main :: IO ()
297 main = thermoprintServer True (Nat runSqlite) $ (\c -> c { queueManagers = queueManagers, warpSettings = wSettings }) <$> def `withPrinters` printers 298 main = thermoprintServer True (Nat runSqlite) $ (\c -> c { queueManagers = queueManagers, warpSettings = wSettings }) <$> def `withPrinters` printers
298 where 299 where
299 runSqlite :: ReaderT ConnectionPool (LoggingT IO) a -> IO a 300 runSqlite :: ReaderT ConnectionPool (LoggingT IO) a -> IO a
300 runSqlite = runStderrLoggingT . withSqlitePool "${users.extraUsers."thermoprint".home}/thermoprint.sqlite" 1 . runReaderT 301 runSqlite = runStderrLoggingT . withSqlitePool "${users.extraUsers."thermoprint".home}/thermoprint.sqlite" 1 . runReaderT
301 302
302 printers = [ (pure $ genericPrint "/dev/usb/lp0", def) 303 printers = [ (pure $ genericPrint "/dev/usb/lp0", def)
303 ] 304 ]
304 305
305 queueManagers _ = QMConfig 306 queueManagers _ = QMConfig
306 { manager = union [ limitHistorySize 100 307 { manager = union [ limitHistorySize 100
307 , limitHistoryAge 3600 308 , limitHistoryAge 3600
308 ] 309 ]
309 , collapse = standardCollapse 310 , collapse = standardCollapse
310 } 311 }
311 312
312 wSettings = setHost "*" . Warp.setPort 8080 $ Warp.defaultSettings 313 wSettings = setHost "*" . Warp.setPort 8080 $ Warp.defaultSettings
313 ''; 314 '';
315 };
314 316
315 systemd.services."thermoprint" = { 317 systemd.services."thermoprint" = {
316 environment = { 318 environment = {