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.
149 lines
4.0 KiB
Nix
149 lines
4.0 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.agate;
|
|
in
|
|
{
|
|
options = {
|
|
services.agate = {
|
|
enable = mkEnableOption "Agate Server";
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.agate;
|
|
defaultText = literalExpression "pkgs.agate";
|
|
description = lib.mdDoc "The package to use";
|
|
};
|
|
|
|
addresses = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ "0.0.0.0:1965" ];
|
|
description = lib.mdDoc ''
|
|
Addresses to listen on, IP:PORT, if you haven't disabled forwarding
|
|
only set IPv4.
|
|
'';
|
|
};
|
|
|
|
contentDir = mkOption {
|
|
default = "/var/lib/agate/content";
|
|
type = types.path;
|
|
description = lib.mdDoc "Root of the content directory.";
|
|
};
|
|
|
|
certificatesDir = mkOption {
|
|
default = "/var/lib/agate/certificates";
|
|
type = types.path;
|
|
description = lib.mdDoc "Root of the certificate directory.";
|
|
};
|
|
|
|
hostnames = mkOption {
|
|
default = [ ];
|
|
type = types.listOf types.str;
|
|
description = lib.mdDoc ''
|
|
Domain name of this Gemini server, enables checking hostname and port
|
|
in requests. (multiple occurences means basic vhosts)
|
|
'';
|
|
};
|
|
|
|
language = mkOption {
|
|
default = null;
|
|
type = types.nullOr types.str;
|
|
description = lib.mdDoc "RFC 4646 Language code for text/gemini documents.";
|
|
};
|
|
|
|
onlyTls_1_3 = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc "Only use TLSv1.3 (default also allows TLSv1.2).";
|
|
};
|
|
|
|
extraArgs = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ "" ];
|
|
example = [ "--log-ip" ];
|
|
description = lib.mdDoc "Extra arguments to use running agate.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
# available for generating certs by hand
|
|
# it can be a bit arduous with openssl
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
systemd.services.agate = {
|
|
description = "Agate";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" "network-online.target" ];
|
|
|
|
script =
|
|
let
|
|
prefixKeyList = key: list: concatMap (v: [ key v ]) list;
|
|
addresses = prefixKeyList "--addr" cfg.addresses;
|
|
hostnames = prefixKeyList "--hostname" cfg.hostnames;
|
|
in
|
|
''
|
|
exec ${cfg.package}/bin/agate ${
|
|
escapeShellArgs (
|
|
[
|
|
"--content" "${cfg.contentDir}"
|
|
"--certs" "${cfg.certificatesDir}"
|
|
] ++
|
|
addresses ++
|
|
(optionals (cfg.hostnames != []) hostnames) ++
|
|
(optionals (cfg.language != null) [ "--lang" cfg.language ]) ++
|
|
(optionals cfg.onlyTls_1_3 [ "--only-tls13" ]) ++
|
|
(optionals (cfg.extraArgs != []) cfg.extraArgs)
|
|
)
|
|
}
|
|
'';
|
|
|
|
serviceConfig = {
|
|
Restart = "always";
|
|
RestartSec = "5s";
|
|
DynamicUser = true;
|
|
StateDirectory = "agate";
|
|
|
|
# Security options:
|
|
AmbientCapabilities = "";
|
|
CapabilityBoundingSet = "";
|
|
|
|
# ProtectClock= adds DeviceAllow=char-rtc r
|
|
DeviceAllow = "";
|
|
|
|
LockPersonality = true;
|
|
|
|
PrivateTmp = true;
|
|
PrivateDevices = true;
|
|
PrivateUsers = true;
|
|
|
|
ProtectClock = true;
|
|
ProtectControlGroups = true;
|
|
ProtectHostname = true;
|
|
ProtectKernelLogs = true;
|
|
ProtectKernelModules = true;
|
|
ProtectKernelTunables = true;
|
|
|
|
RestrictNamespaces = true;
|
|
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
|
RestrictRealtime = true;
|
|
|
|
SystemCallArchitectures = "native";
|
|
SystemCallErrorNumber = "EPERM";
|
|
SystemCallFilter = [
|
|
"@system-service"
|
|
"~@cpu-emulation"
|
|
"~@debug"
|
|
"~@keyring"
|
|
"~@memlock"
|
|
"~@obsolete"
|
|
"~@privileged"
|
|
"~@setuid"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|