summaryrefslogtreecommitdiff
path: root/Que/Site.nix
blob: 6a24d9d848cbd36053616ab6f3e87be0cb8cf171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ options
, lib
, config
, pkgs
, modulesPath
}:

let
  cfg = config.services.que-website;
  static = pkgs.stdenv.mkDerivation {
    src = ./.;
    name = "que-website-static";
    installPhase = ''
      mkdir -p $out
      cp ${./apidocs.md} $out/apidocs.md
      cp ${./index.md} $out/index.md
      cp ${./quescripts.md} $out/quescripts.md
      cp ${./style.css} $out/style.css
      cp ${./tutorial.md} $out/tutorial.md
      cp ${./client.py} $out/client.py
    '';
  };
in
{
  options.services.que-website = {
    enable = lib.mkEnableOption "Enable the que-website service";
    namespace = lib.mkOption {
      type = lib.types.str;
      default = "_";
      description = ''
        The que namespace on which que-website will broadcast.
      '';
    };
    package = lib.mkOption {
      type = lib.types.package;
      description = "que-website package to use";
    };
  };
  config = lib.mkIf cfg.enable {
    systemd.services.que-website = {
      path = [ cfg.package pkgs.pandoc ];
      wantedBy = [ "multi-user.target" ];
      script = ''
        ${cfg.package}/bin/que-website ${static} ${cfg.namespace}
      '';
      description = ''
        Que website server
      '';
      serviceConfig = {
        User = "root";
        Environment = "HOME=/root";
        KillSignal = "INT";
        Type = "simple";
        Restart = "on-abort";
        RestartSec = "1";
      };
    };
  };
}