Skip to content
Permalink
Browse files

packet: add app to deploy

  • Loading branch information...
vaibhavsagar committed Aug 20, 2019
1 parent 5126d9d commit 466e0e1867e47346ed8cc706b812a8cb21c76c19
Showing with 49 additions and 0 deletions.
  1. +11 −0 packet/deploy/app/Main.hs
  2. +11 −0 packet/deploy/app/blank-me-up.cabal
  3. +27 −0 packet/deploy/nix/service.nix
@@ -0,0 +1,11 @@
{-# LANGUAGE OverloadedStrings #-}

import Web.Scotty
import System.Environment (getArgs)

import Data.Monoid (mconcat)

main = getArgs >>= \(port:_) -> scotty (read port) $ do
get "/:word" $ do
beam <- param "word"
html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]
@@ -0,0 +1,11 @@
name: blank-me-up
version: 0.1.0.0
license: BSD3
build-type: Simple
cabal-version: >=1.10

executable blank-me-up
main-is: Main.hs
build-depends: base >=4.9 && <5
, scotty
default-language: Haskell2010
@@ -0,0 +1,27 @@
{ config, lib, pkgs, ... }:

let
blank-me-up = pkgs.haskellPackages.callCabal2nix "blank-me-up" ../app {};
cfg = config.services.blank-me-up;
in {
options.services.blank-me-up.enable = lib.mkEnableOption "Blank Me Up";
options.services.blank-me-up.port = lib.mkOption {
default = 3000;
type = lib.types.int;
};

config = lib.mkIf cfg.enable {
networking.firewall.allowedTCPPorts = [ cfg.port ];

systemd.services.blank-me-up = {
description = "Blank Me Up";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${blank-me-up}/bin/blank-me-up ${toString cfg.port}";
Restart = "always";
KillMode = "process";
};
};
};
}

0 comments on commit 466e0e1

Please sign in to comment.
You can’t perform that action at this time.