diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-14 17:28:37 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-14 17:28:37 +0100 |
commit | e100119827474928636c2ed9a9772f3c5107663b (patch) | |
tree | 80833a41f9f067125fea734b134b0a9424fd7159 /bragi | |
parent | 000d46fbd462dc59aa143261b894f9c470e54040 (diff) | |
parent | f655f88cbbc334ad56a79c2287f18defa5aa98ba (diff) | |
download | nixos-e100119827474928636c2ed9a9772f3c5107663b.tar nixos-e100119827474928636c2ed9a9772f3c5107663b.tar.gz nixos-e100119827474928636c2ed9a9772f3c5107663b.tar.bz2 nixos-e100119827474928636c2ed9a9772f3c5107663b.tar.xz nixos-e100119827474928636c2ed9a9772f3c5107663b.zip |
Merge branch 'master' of git:nixos
Diffstat (limited to 'bragi')
-rw-r--r-- | bragi/bar/default.nix | 33 | ||||
-rw-r--r-- | bragi/bar/generated.nix | 34 | ||||
-rw-r--r-- | bragi/bar/generated.nix.gup | 5 | ||||
-rw-r--r-- | bragi/thermoprint-server/thermoprint-server.hs | 45 |
4 files changed, 117 insertions, 0 deletions
diff --git a/bragi/bar/default.nix b/bragi/bar/default.nix new file mode 100644 index 00000000..bbfa170c --- /dev/null +++ b/bragi/bar/default.nix | |||
@@ -0,0 +1,33 @@ | |||
1 | { haskellPackages | ||
2 | , stdenv | ||
3 | , fetchFromGitHub | ||
4 | , jquery | ||
5 | }: | ||
6 | |||
7 | let | ||
8 | pkg = haskellPackages.callPackage ./generated.nix {}; | ||
9 | webshim = stdenv.mkDerivation rec { | ||
10 | name = "webshim-${version}"; | ||
11 | version = "1.16.0"; | ||
12 | src = fetchFromGitHub { | ||
13 | owner = "aFarkas"; | ||
14 | repo = "webshim"; | ||
15 | rev = "1.16.0"; | ||
16 | sha256 = "14pk7hljqipzp0n7vpgcfxr3w4bla57cwyd7bmwmmxrm2zn62cyh"; | ||
17 | }; | ||
18 | |||
19 | installPhase = '' | ||
20 | mkdir -p $out/js | ||
21 | cp -r $src/js-webshim/dev/* $out/js/ | ||
22 | ''; | ||
23 | }; | ||
24 | in stdenv.lib.overrideDerivation pkg (drv: { | ||
25 | postUnpack = '' | ||
26 | ( | ||
27 | cd bar-*/static | ||
28 | rm -rf jquery.js webshim | ||
29 | ln -vs ${jquery}/js/jquery.js . | ||
30 | ln -vs ${webshim}/js webshim | ||
31 | ) | ||
32 | ''; | ||
33 | }) | ||
diff --git a/bragi/bar/generated.nix b/bragi/bar/generated.nix new file mode 100644 index 00000000..4243ad4d --- /dev/null +++ b/bragi/bar/generated.nix | |||
@@ -0,0 +1,34 @@ | |||
1 | { mkDerivation, aeson, base, bytestring, case-insensitive | ||
2 | , classy-prelude, classy-prelude-conduit, classy-prelude-yesod | ||
3 | , conduit, containers, data-default, directory, fast-logger | ||
4 | , fetchgit, file-embed, hjsmin, http-conduit, lens, monad-control | ||
5 | , monad-logger, mtl, persistent, persistent-postgresql | ||
6 | , persistent-template, safe, shakespeare, stdenv, template-haskell | ||
7 | , text, time, unordered-containers, vector, wai, wai-extra | ||
8 | , wai-logger, warp, yaml, yesod, yesod-auth, yesod-core, yesod-form | ||
9 | , yesod-static | ||
10 | }: | ||
11 | mkDerivation { | ||
12 | pname = "bar"; | ||
13 | version = "0.0.0"; | ||
14 | src = fetchgit { | ||
15 | url = "git://git.yggdrasil.li/gkleen/pub/bar"; | ||
16 | sha256 = "13h5hxwx4y79jr19l894zq4ynvkmhfds52xm8dlsdl5j69gg7laa"; | ||
17 | rev = "53fcf55c02f9335518c28d26429913258fc28f87"; | ||
18 | }; | ||
19 | isLibrary = true; | ||
20 | isExecutable = true; | ||
21 | libraryHaskellDepends = [ | ||
22 | aeson base bytestring case-insensitive classy-prelude | ||
23 | classy-prelude-conduit classy-prelude-yesod conduit containers | ||
24 | data-default directory fast-logger file-embed hjsmin http-conduit | ||
25 | lens monad-control monad-logger mtl persistent | ||
26 | persistent-postgresql persistent-template safe shakespeare | ||
27 | template-haskell text time unordered-containers vector wai | ||
28 | wai-extra wai-logger warp yaml yesod yesod-auth yesod-core | ||
29 | yesod-form yesod-static | ||
30 | ]; | ||
31 | executableHaskellDepends = [ base ]; | ||
32 | doHaddock = false; | ||
33 | license = stdenv.lib.licenses.unfree; | ||
34 | } | ||
diff --git a/bragi/bar/generated.nix.gup b/bragi/bar/generated.nix.gup new file mode 100644 index 00000000..eeb13ad2 --- /dev/null +++ b/bragi/bar/generated.nix.gup | |||
@@ -0,0 +1,5 @@ | |||
1 | #!/usr/bin/env zsh | ||
2 | |||
3 | gup -u ${2:r}.cabal | ||
4 | cd ${2:h} | ||
5 | cabal2nix --no-haddock "git://git.yggdrasil.li/gkleen/pub/bar" >! ${1} | ||
diff --git a/bragi/thermoprint-server/thermoprint-server.hs b/bragi/thermoprint-server/thermoprint-server.hs new file mode 100644 index 00000000..4635dd0a --- /dev/null +++ b/bragi/thermoprint-server/thermoprint-server.hs | |||
@@ -0,0 +1,45 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | {-# LANGUAGE ImpredicativeTypes #-} | ||
3 | |||
4 | module Main (main) where | ||
5 | |||
6 | import Thermoprint.Server | ||
7 | |||
8 | import Thermoprint.Server.Printer.Generic | ||
9 | |||
10 | import Control.Monad.Trans.Resource | ||
11 | import Control.Monad.Logger | ||
12 | import Control.Monad.Reader | ||
13 | |||
14 | import Data.Function ((&)) | ||
15 | |||
16 | import Database.Persist.Postgresql | ||
17 | |||
18 | import qualified Network.Wai.Handler.Warp as Warp | ||
19 | |||
20 | type ServerM = ReaderT ConnectionPool (LoggingT IO) | ||
21 | |||
22 | main :: IO () | ||
23 | main = thermoprintServer True (Nat runDb) $ configure <$> def `withPrinters` printers' | ||
24 | where | ||
25 | runDb :: ServerM a -> IO a | ||
26 | runDb = runStderrLoggingT . withPostgresqlPool "" 5 . runReaderT | ||
27 | |||
28 | printers' = [ (pure $ genericPrint "/dev/usb/lp0", def :: QMConfig (ResourceT ServerM)) | ||
29 | ] | ||
30 | |||
31 | configure c = c | ||
32 | { queueManagers = queueManagers | ||
33 | , warpSettings = warpSettings | ||
34 | } | ||
35 | |||
36 | queueManagers _ = QMConfig | ||
37 | { manager = union [ limitHistorySize 100 | ||
38 | , limitHistoryAge 3600 | ||
39 | ] | ||
40 | , collapse = standardCollapse | ||
41 | } | ||
42 | |||
43 | warpSettings = Warp.defaultSettings | ||
44 | & Warp.setHost "::1" | ||
45 | & Warp.setPort 8080 | ||