1{ config, lib, pkgs, ... }:
2
3let
4 inherit (lib) mkEnableOption mkIf mkOption types literalExpression;
5
6 cfg = config.services.isso;
7
8 settingsFormat = pkgs.formats.ini { };
9 configFile = settingsFormat.generate "isso.conf" cfg.settings;
10in {
11
12 options = {
13 services.isso = {
14 enable = mkEnableOption ''
15 A commenting server similar to Disqus.
16
17 Note: The application's author suppose to run isso behind a reverse proxy.
18 The embedded solution offered by NixOS is also only suitable for small installations
19 below 20 requests per second.
20 '';
21
22 settings = mkOption {
23 description = ''
24 Configuration for <package>isso</package>.
25
26 See <link xlink:href="https://posativ.org/isso/docs/configuration/server/">Isso Server Configuration</link>
27 for supported values.
28 '';
29
30 type = types.submodule {
31 freeformType = settingsFormat.type;
32 };
33
34 example = literalExpression ''
35 {
36 general = {
37 host = "http://localhost";
38 };
39 }
40 '';
41 };
42 };
43 };
44
45 config = mkIf cfg.enable {
46 services.isso.settings.general.dbpath = lib.mkDefault "/var/lib/isso/comments.db";
47
48 systemd.services.isso = {
49 description = "isso, a commenting server similar to Disqus";
50 wantedBy = [ "multi-user.target" ];
51
52 serviceConfig = {
53 User = "isso";
54 Group = "isso";
55
56 DynamicUser = true;
57
58 StateDirectory = "isso";
59
60 ExecStart = ''
61 ${pkgs.isso}/bin/isso -c ${configFile}
62 '';
63
64 Restart = "on-failure";
65 RestartSec = 1;
66 };
67 };
68 };
69}