summaryrefslogtreecommitdiff
path: root/nix/module.nix
blob: 7718ee8b402527a8e7d60f3b821c509582863290 (plain) (blame)
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
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.services.technical-renaissance;
in
{
  options.services.technical-renaissance = {
    enable = lib.mkEnableOption "the Technical Renaissance webring";

    package = lib.mkOption {
      type = lib.types.package;
      default = pkgs.callPackage ./package.nix { };
      description = "The technical-renaissance package to run.";
    };

    host = lib.mkOption {
      type = lib.types.str;
      default = "127.0.0.1";
      description = "Address the webring listens on.";
    };

    port = lib.mkOption {
      type = lib.types.port;
      default = 8080;
      description = "Port the webring listens on.";
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.technical-renaissance = {
      description = "Technical Renaissance webring";
      wantedBy = [ "multi-user.target" ];
      after = [ "network.target" ];

      environment = {
        HOST = cfg.host;
        PORT = toString cfg.port;
      };

      serviceConfig = {
        ExecStart = lib.getExe cfg.package;
        DynamicUser = true;
        Restart = "on-failure";
      };
    };
  };
}