summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <pngwjpgh@users.noreply.github.com>2016-07-17 19:24:28 +0200
committerGregor Kleen <pngwjpgh@users.noreply.github.com>2016-07-17 19:24:28 +0200
commit382763e37e4eda0e88af73d6c258e721c4ae90e2 (patch)
tree8abe95ca77732dcf342035537fbe121af52636e5
parent83031effa3cdf80fbbf613390fee340efbf93fee (diff)
downloadnixos-382763e37e4eda0e88af73d6c258e721c4ae90e2.tar
nixos-382763e37e4eda0e88af73d6c258e721c4ae90e2.tar.gz
nixos-382763e37e4eda0e88af73d6c258e721c4ae90e2.tar.bz2
nixos-382763e37e4eda0e88af73d6c258e721c4ae90e2.tar.xz
nixos-382763e37e4eda0e88af73d6c258e721c4ae90e2.zip
thermoprint on bragi
-rw-r--r--bragi.nix55
m---------custom/thermoprint0
2 files changed, 54 insertions, 1 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 {
80 --run "umask 0" 80 --run "umask 0"
81 ''; 81 '';
82 }); 82 });
83
84 inherit (pkgs.callPackage ./custom/thermoprint {}) thermoprint-server thermoprint-webgui tprint;
83 }; 85 };
84 86
85 environment.systemPackages = with pkgs; [ 87 environment.systemPackages = with pkgs; [
@@ -91,6 +93,7 @@ in rec {
91 jack2Full 93 jack2Full
92 trivmix 94 trivmix
93 zsh 95 zsh
96 tprint
94 ]; 97 ];
95 98
96 # List services that you want to enable: 99 # List services that you want to enable:
@@ -272,10 +275,60 @@ in rec {
272 home = "/var/lib/thermoprint"; 275 home = "/var/lib/thermoprint";
273 }; 276 };
274 277
278 environment.etc."thermoprint-server/config.hs" = ''
279 {-# LANGUAGE OverloadedStrings #-}
280 {-# LANGUAGE ImpredicativeTypes #-}
281
282 module Main (main) where
283
284 import Thermoprint.Server
285
286 import Thermoprint.Server.Printer.Generic
287
288 import Control.Monad.Trans.Resource
289 import Control.Monad.Logger
290 import Control.Monad.Reader
291
292 import Database.Persist.Sqlite
293
294 import qualified Network.Wai.Handler.Warp as Warp
295
296 main :: IO ()
297 main = thermoprintServer True (Nat runSqlite) $ (\c -> c { queueManagers = queueManagers, warpSettings = wSettings }) <$> def `withPrinters` printers
298 where
299 runSqlite :: ReaderT ConnectionPool (LoggingT IO) a -> IO a
300 runSqlite = runStderrLoggingT . withSqlitePool "${users.extraUsers."thermoprint".home}/thermoprint.sqlite" 1 . runReaderT
301
302 printers = [ (pure $ genericPrint "/dev/usb/lp0", def)
303 ]
304
305 queueManagers _ = QMConfig
306 { manager = union [ limitHistorySize 100
307 , limitHistoryAge 3600
308 ]
309 , collapse = standardCollapse
310 }
311
312 wSettings = setHost "*" . Warp.setPort 8080 $ Warp.defaultSettings
313 '';
314
275 systemd.services."thermoprint" = { 315 systemd.services."thermoprint" = {
316 environment = {
317 THERMOPRINT_CONFIG = "/etc/thermoprint-server";
318 THERMOPRINT_CACHE = ${users.extraUsers."thermoprint".home}"/dyre";
319 };
320 serviceConfig = {
321 Type = "simple";
322 ExecStart = ''${pkgs.thermoprint-server}/bin/thermoprint-server'';
323 User = users.extraUsers."thermoprint".name;
324 Group = users.extraUsers."thermoprint".group;
325 };
326 };
327
328 systemd.services."thermoprint-webgui" = {
276 serviceConfig = { 329 serviceConfig = {
277 Type = "simple"; 330 Type = "simple";
278 ExecStart = ''${thermoprint-servant}/bin/thermoprint --database ${users.extraUsers."thermoprint".home}/database.sqlite /dev/usb/lp0''; 331 ExecStart = '''${pkgs.thermoprint-webgui}/bin/thermoprint-webgui -P 8080 -A localhost -a "*" -p 8081';
279 User = users.extraUsers."thermoprint".name; 332 User = users.extraUsers."thermoprint".name;
280 Group = users.extraUsers."thermoprint".group; 333 Group = users.extraUsers."thermoprint".group;
281 }; 334 };
diff --git a/custom/thermoprint b/custom/thermoprint
Subproject 7f84192054e2f3c2e379588b15cf73aaecfbad0 Subproject 2b9ceaead3f3cd80e973cccecb9a3eebc51154f