mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-04 04:46:43 +00:00
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
102 lines
2.7 KiB
Nix
102 lines
2.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.molly-brown;
|
|
settingsFormat = pkgs.formats.toml { };
|
|
configFile = settingsFormat.generate "molly-brown.toml" cfg.settings;
|
|
in {
|
|
|
|
options.services.molly-brown = {
|
|
|
|
enable = mkEnableOption "Molly-Brown Gemini server";
|
|
|
|
port = mkOption {
|
|
default = 1965;
|
|
type = types.port;
|
|
description = lib.mdDoc ''
|
|
TCP port for molly-brown to bind to.
|
|
'';
|
|
};
|
|
|
|
hostName = mkOption {
|
|
type = types.str;
|
|
default = config.networking.hostName;
|
|
defaultText = literalExpression "config.networking.hostName";
|
|
description = lib.mdDoc ''
|
|
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";
|
|
description = ''
|
|
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:
|
|
<programlisting>
|
|
systemd.services.molly-brown.serviceConfig.SupplementaryGroups =
|
|
[ config.security.acme.certs."example.com".group ];
|
|
</programlisting>
|
|
'';
|
|
};
|
|
|
|
keyPath = mkOption {
|
|
type = types.path;
|
|
example = "/var/lib/acme/example.com/key.pem";
|
|
description = lib.mdDoc "Path to TLS key. See {option}`CertPath`.";
|
|
};
|
|
|
|
docBase = mkOption {
|
|
type = types.path;
|
|
example = "/var/lib/molly-brown";
|
|
description = lib.mdDoc "Base directory for Gemini content.";
|
|
};
|
|
|
|
settings = mkOption {
|
|
inherit (settingsFormat) type;
|
|
default = { };
|
|
description = lib.mdDoc ''
|
|
molly-brown configuration. Refer to
|
|
<https://tildegit.org/solderpunk/molly-brown/src/branch/master/example.conf>
|
|
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";
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
}
|