Skip to content

Commit bf25eae

Browse files
authored
nixos/routinator: init module (#380046)
2 parents 6233f69 + c468f4e commit bf25eae

File tree

6 files changed

+236
-0
lines changed

6 files changed

+236
-0
lines changed

nixos/doc/manual/release-notes/rl-2505.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383

8484
- [networking.modemmanager](options.html#opt-networking.modemmanager) has been split out of [networking.networkmanager](options.html#opt-networking.networkmanager). NetworkManager still enables ModemManager by default, but options exist now to run NetworkManager without ModemManager.
8585

86+
- [Routinator 3000](https://nlnetlabs.nl/projects/routing/routinator/), a full-featured RPKI Relying Party software package that runs as a service which periodically downloads and verifies RPKI data.
87+
8688
- [doh-server](https://github.com/m13253/dns-over-https), a high performance DNS over HTTPS server. Available as [services.doh-server](options.html#opt-services.doh-server.enable).
8789

8890
- [ncps](https://github.com/kalbasit/ncps), a Nix binary cache proxy service implemented in Go using [go-nix](https://github.com/nix-community/go-nix). Available as [services.ncps](options.html#opt-services.ncps.enable).

nixos/modules/module-list.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@
12471247
./services/networking/robustirc-bridge.nix
12481248
./services/networking/rosenpass.nix
12491249
./services/networking/routedns.nix
1250+
./services/networking/routinator.nix
12501251
./services/networking/rpcbind.nix
12511252
./services/networking/rxe.nix
12521253
./services/networking/sabnzbd.nix
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
utils,
6+
...
7+
}:
8+
let
9+
inherit (lib)
10+
filterAttrsRecursive
11+
getExe
12+
maintainers
13+
mkEnableOption
14+
mkPackageOption
15+
mkOption
16+
types
17+
;
18+
inherit (utils) escapeSystemdExecArgs;
19+
cfg = config.services.routinator;
20+
settingsFormat = pkgs.formats.toml { };
21+
in
22+
{
23+
options.services.routinator = {
24+
enable = mkEnableOption "Routinator 3000";
25+
26+
package = mkPackageOption pkgs "routinator" { };
27+
28+
extraArgs = mkOption {
29+
description = ''
30+
Extra arguments passed to routinator, see <https://routinator.docs.nlnetlabs.nl/en/stable/manual-page.html#options> for options.";
31+
'';
32+
type = types.listOf types.str;
33+
default = [ ];
34+
example = [ "--no-rir-tals" ];
35+
};
36+
37+
extraServerArgs = mkOption {
38+
description = ''
39+
Extra arguments passed to the server subcommand, see <https://routinator.docs.nlnetlabs.nl/en/stable/manual-page.html#subcmd-server> for options.";
40+
'';
41+
type = types.listOf types.str;
42+
default = [ ];
43+
example = [ "--rtr-client-metrics" ];
44+
};
45+
46+
settings = mkOption {
47+
type = types.submodule {
48+
freeformType = settingsFormat.type;
49+
options = {
50+
repository-dir = mkOption {
51+
type = types.path;
52+
description = ''
53+
The path where the collected RPKI data is stored.
54+
'';
55+
default = "/var/lib/routinator/rpki-cache";
56+
};
57+
log-level = mkOption {
58+
type = types.nullOr (
59+
types.enum [
60+
"error"
61+
"warn"
62+
"info"
63+
"debug"
64+
]
65+
);
66+
description = ''
67+
A string value specifying the maximum log level for which log messages should be emitted.
68+
See, <https://routinator.docs.nlnetlabs.nl/en/stable/manual-page.html#logging>
69+
'';
70+
default = "warn";
71+
};
72+
log = mkOption {
73+
type = types.nullOr (
74+
types.enum [
75+
"default"
76+
"stderr"
77+
"syslog"
78+
"file"
79+
]
80+
);
81+
description = ''
82+
A string specifying where to send log messages to.
83+
See, <https://routinator.docs.nlnetlabs.nl/en/stable/manual-page.html#term-log>
84+
'';
85+
default = "default";
86+
};
87+
log-file = mkOption {
88+
type = types.nullOr types.path;
89+
description = ''
90+
A string value containing the path to a file to which log messages will be appended if the log configuration value is set to file. In this case, the value is mandatory.
91+
'';
92+
default = null;
93+
};
94+
http-listen = mkOption {
95+
type = types.nullOr (types.listOf types.str);
96+
description = ''
97+
An array of string values each providing an address and port on which the HTTP server should listen. Address and port should be separated by a colon. IPv6 address should be enclosed in square brackets.
98+
'';
99+
default = null;
100+
};
101+
rtr-listen = mkOption {
102+
type = types.nullOr (types.listOf types.str);
103+
description = ''
104+
An array of string values each providing an address and port on which the RTR server should listen in TCP mode. Address and port should be separated by a colon. IPv6 address should be enclosed in square brackets.
105+
'';
106+
default = null;
107+
};
108+
refresh = mkOption {
109+
type = types.nullOr types.int;
110+
description = ''
111+
An integer value specifying the number of seconds Routinator should wait between consecutive validation runs in server mode. The next validation run will happen earlier, if objects expire earlier.
112+
'';
113+
default = 600;
114+
};
115+
retry = mkOption {
116+
type = types.nullOr types.int;
117+
description = ''
118+
An integer value specifying the number of seconds an RTR client is requested to wait after it failed to receive a data set.
119+
'';
120+
default = 600;
121+
};
122+
expire = mkOption {
123+
type = types.nullOr types.int;
124+
description = ''
125+
An integer value specifying the number of seconds an RTR client is requested to use a data set if it cannot get an update before throwing it away and continuing with no data at all.
126+
'';
127+
default = 7200;
128+
};
129+
};
130+
};
131+
description = ''
132+
Configuration for Routinator 3000, see <https://routinator.docs.nlnetlabs.nl/en/stable/manual-page.html#configuration-file> for options.
133+
'';
134+
default = { };
135+
};
136+
};
137+
138+
config = {
139+
systemd.services.routinator = {
140+
description = "Routinator 3000 is free, open-source RPKI Relying Party software made by NLnet Labs.";
141+
wantedBy = [ "multi-user.target" ];
142+
after = [ "network.target" ];
143+
path = with pkgs; [ rsync ];
144+
serviceConfig = {
145+
Type = "exec";
146+
ExecStart = escapeSystemdExecArgs (
147+
[
148+
(getExe cfg.package)
149+
"--config=${
150+
settingsFormat.generate "routinator.conf" (filterAttrsRecursive (n: v: v != null) cfg.settings)
151+
}"
152+
]
153+
++ cfg.extraArgs
154+
++ [
155+
"server"
156+
]
157+
++ cfg.extraServerArgs
158+
);
159+
Restart = "on-failure";
160+
CapabilityBoundingSet = [ "" ];
161+
DynamicUser = true;
162+
LockPersonality = true;
163+
MemoryDenyWriteExecute = true;
164+
NoNewPrivileges = true;
165+
PrivateDevices = true;
166+
PrivateTmp = true;
167+
ProtectClock = true;
168+
ProtectControlGroups = true;
169+
ProtectHome = true;
170+
ProtectHostname = true;
171+
ProtectKernelLogs = true;
172+
ProtectKernelModules = true;
173+
ProtectKernelTunables = true;
174+
ProtectSystem = "strict";
175+
RestrictAddressFamilies = [
176+
"AF_INET"
177+
"AF_INET6"
178+
"AF_UNIX"
179+
];
180+
RestrictNamespaces = true;
181+
RestrictRealtime = true;
182+
StateDirectory = "routinator";
183+
SystemCallArchitectures = "native";
184+
SystemCallErrorNumber = "EPERM";
185+
SystemCallFilter = "@system-service";
186+
UMask = "0027";
187+
};
188+
};
189+
};
190+
191+
meta.maintainers = with maintainers; [ xgwq ];
192+
}

nixos/tests/all-tests.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,7 @@ in {
924924
rmfakecloud = runTest ./rmfakecloud.nix;
925925
robustirc-bridge = handleTest ./robustirc-bridge.nix {};
926926
roundcube = handleTest ./roundcube.nix {};
927+
routinator = handleTest ./routinator.nix {};
927928
rosenpass = handleTest ./rosenpass.nix {};
928929
rshim = handleTest ./rshim.nix {};
929930
rspamd = handleTest ./rspamd.nix {};

nixos/tests/routinator.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
system ? builtins.currentSystem,
3+
pkgs ? import ../.. {
4+
inherit system;
5+
config = { };
6+
},
7+
}:
8+
9+
let
10+
inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
11+
in
12+
makeTest {
13+
name = "routinator";
14+
15+
nodes.server =
16+
{ pkgs, ... }:
17+
{
18+
services.routinator = {
19+
enable = true;
20+
extraArgs = [ "--no-rir-tals" ];
21+
settings = {
22+
http-listen = [ "[::]:8382" ];
23+
};
24+
};
25+
};
26+
27+
testScript = ''
28+
start_all()
29+
30+
server.wait_for_unit("routinator.service")
31+
32+
with subtest("Check if routinator reports the correct version"):
33+
server.wait_until_succeeds("[[ \"$(curl http://localhost:8382/version)\" = \"${pkgs.routinator.version}\" ]]")
34+
'';
35+
}

pkgs/by-name/ro/routinator/package.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
fetchFromGitHub,
55
stdenv,
66
darwin,
7+
nixosTests,
78
}:
89

910
rustPlatform.buildRustPackage rec {
@@ -36,4 +37,8 @@ rustPlatform.buildRustPackage rec {
3637
maintainers = with maintainers; [ _0x4A6F ];
3738
mainProgram = "routinator";
3839
};
40+
41+
passthru.tests = {
42+
basic-functioniality = nixosTests.routinator;
43+
};
3944
}

0 commit comments

Comments
 (0)