Skip to content

Commit 466e0e1

Browse files
committed
packet: add app to deploy
1 parent 5126d9d commit 466e0e1

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

packet/deploy/app/Main.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
3+
import Web.Scotty
4+
import System.Environment (getArgs)
5+
6+
import Data.Monoid (mconcat)
7+
8+
main = getArgs >>= \(port:_) -> scotty (read port) $ do
9+
get "/:word" $ do
10+
beam <- param "word"
11+
html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: blank-me-up
2+
version: 0.1.0.0
3+
license: BSD3
4+
build-type: Simple
5+
cabal-version: >=1.10
6+
7+
executable blank-me-up
8+
main-is: Main.hs
9+
build-depends: base >=4.9 && <5
10+
, scotty
11+
default-language: Haskell2010

packet/deploy/nix/service.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{ config, lib, pkgs, ... }:
2+
3+
let
4+
blank-me-up = pkgs.haskellPackages.callCabal2nix "blank-me-up" ../app {};
5+
cfg = config.services.blank-me-up;
6+
in {
7+
options.services.blank-me-up.enable = lib.mkEnableOption "Blank Me Up";
8+
options.services.blank-me-up.port = lib.mkOption {
9+
default = 3000;
10+
type = lib.types.int;
11+
};
12+
13+
config = lib.mkIf cfg.enable {
14+
networking.firewall.allowedTCPPorts = [ cfg.port ];
15+
16+
systemd.services.blank-me-up = {
17+
description = "Blank Me Up";
18+
after = [ "network.target" ];
19+
wantedBy = [ "multi-user.target" ];
20+
serviceConfig = {
21+
ExecStart = "${blank-me-up}/bin/blank-me-up ${toString cfg.port}";
22+
Restart = "always";
23+
KillMode = "process";
24+
};
25+
};
26+
};
27+
}

0 commit comments

Comments
 (0)