modules/stayrtr: rename, make enableable

This commit is contained in:
Astro 2024-04-13 00:53:08 +02:00
parent 622503946e
commit 5229ec7f24
4 changed files with 41 additions and 24 deletions

View File

@ -38,15 +38,17 @@ in
roa4 table dnroa4;
roa6 table dnroa6;
protocol rpki roa_dn42 {
roa4 { table dnroa4; };
roa6 { table dnroa6; };
remote 127.0.0.1;
port 8082;
refresh 600;
retry 300;
expire 7200;
}
${lib.optionalString config.services.dn42-stayrtr.enable ''
protocol rpki roa_dn42 {
roa4 { table dnroa4; };
roa6 { table dnroa6; };
remote 127.0.0.1;
port 8082;
refresh 600;
retry 300;
expire 7200;
}
''}
include "${../resources/community_filter.conf}";
include "${../resources/filters.conf}";

View File

@ -6,7 +6,7 @@ in
imports = [
./firewall.nix
./bird2.nix
./rtr.nix
./stayrtr.nix
];
options.networking.dn42 = {

View File

@ -1,14 +0,0 @@
{ pkgs, ... }:
{
systemd.services.dn42-stayrtr = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${pkgs.stayrtr}/bin/stayrtr -cache https://dn42.burble.com/roa/dn42_roa_46.json -checktime=false -bind :8082";
DynamicUser = true;
User = "dn42-stayrtr";
};
};
}

29
modules/stayrtr.nix Normal file
View File

@ -0,0 +1,29 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.dn42-stayrtr;
in
{
options.services.dn42-stayrtr = with lib; {
enable = mkEnableOption "dn42-stayrtr";
cache = mkOption {
type = types.url;
default = "https://dn42.burble.com/roa/dn42_roa_46.json";
};
};
config = lib.mkIf cfg.enable {
systemd.services.dn42-stayrtr = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${pkgs.stayrtr}/bin/stayrtr -cache '${cfg.cache}' -checktime=false -bind :8082";
DynamicUser = true;
User = "dn42-stayrtr";
};
};
};
}