2020-07-21 21:20:27 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.molly-brown;
|
2020-09-28 11:28:55 +00:00
|
|
|
settingsFormat = pkgs.formats.toml { };
|
|
|
|
configFile = settingsFormat.generate "molly-brown.toml" cfg.settings;
|
2020-07-21 21:20:27 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
options.services.molly-brown = {
|
|
|
|
|
2022-08-28 19:18:44 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Molly-Brown Gemini server");
|
2020-07-21 21:20:27 +00:00
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
default = 1965;
|
|
|
|
type = types.port;
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-07-21 21:20:27 +00:00
|
|
|
TCP port for molly-brown to bind to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hostName = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = config.networking.hostName;
|
2021-10-03 16:06:03 +00:00
|
|
|
defaultText = literalExpression "config.networking.hostName";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-07-21 21:20:27 +00:00
|
|
|
The hostname to respond to requests for. Requests for URLs with
|
|
|
|
other hosts will result in a status 53 (PROXY REQUEST REFUSED)
|
|
|
|
response.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
certPath = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
example = "/var/lib/acme/example.com/cert.pem";
|
2022-08-30 12:08:50 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-07-21 21:20:27 +00:00
|
|
|
Path to TLS certificate. An ACME certificate and key may be
|
|
|
|
shared with an HTTP server, but only if molly-brown has
|
|
|
|
permissions allowing it to read such keys.
|
|
|
|
|
|
|
|
As an example:
|
2022-08-30 12:08:50 +00:00
|
|
|
```
|
2020-07-21 21:20:27 +00:00
|
|
|
systemd.services.molly-brown.serviceConfig.SupplementaryGroups =
|
|
|
|
[ config.security.acme.certs."example.com".group ];
|
2022-08-30 12:08:50 +00:00
|
|
|
```
|
2020-07-21 21:20:27 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
keyPath = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
example = "/var/lib/acme/example.com/key.pem";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Path to TLS key. See {option}`CertPath`.";
|
2020-07-21 21:20:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
docBase = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
example = "/var/lib/molly-brown";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Base directory for Gemini content.";
|
2020-07-21 21:20:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
2020-09-28 11:28:55 +00:00
|
|
|
inherit (settingsFormat) type;
|
2020-07-21 21:20:27 +00:00
|
|
|
default = { };
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-07-21 21:20:27 +00:00
|
|
|
molly-brown configuration. Refer to
|
2022-07-28 21:19:15 +00:00
|
|
|
<https://tildegit.org/solderpunk/molly-brown/src/branch/master/example.conf>
|
2020-07-21 21:20:27 +00:00
|
|
|
for details on supported values.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
services.molly-brown.settings = let logDir = "/var/log/molly-brown";
|
|
|
|
in {
|
|
|
|
Port = cfg.port;
|
|
|
|
Hostname = cfg.hostName;
|
|
|
|
CertPath = cfg.certPath;
|
|
|
|
KeyPath = cfg.keyPath;
|
|
|
|
DocBase = cfg.docBase;
|
|
|
|
AccessLog = "${logDir}/access.log";
|
|
|
|
ErrorLog = "${logDir}/error.log";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.molly-brown = {
|
|
|
|
description = "Molly Brown gemini server";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
LogsDirectory = "molly-brown";
|
|
|
|
ExecStart = "${pkgs.molly-brown}/bin/molly-brown -c ${configFile}";
|
|
|
|
Restart = "always";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|