-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.nix
56 lines (48 loc) · 1.52 KB
/
module.nix
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
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.jekyll-comments;
in {
options.services.jekyll-comments = {
enable = mkEnableOption "jekyll-comments";
port = mkOption {
type = types.port;
default = 10113;
example = 46264;
description = "The port to listen on";
};
openFirewall = mkOption {
type = types.bool;
default = true;
example = false;
description = "Whether to automatically open the port the server runs on";
};
};
config = mkIf cfg.enable {
systemd.services.jekyll-comments = {
description = "Jekyll Comments Server";
# TODO: should have package option or put it in pkgs or something idr too sleepy
script = let package = pkgs.callPackage ./. {}; in ''
cd $STATE_DIRECTORY
${package}/bin/jekyll-comments --port ${toString cfg.port}
'';
serviceConfig = {
DynamicUser = true;
EnvironmentFile = "/etc/jekyll-comments-env";
StateDirectory = "jekyll-comments";
PrivateDevices = true;
PrivateMounts = true;
PrivateUsers = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
};
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
};
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
};
}