nixos/home/routing-common: Move mstpd config to separate file
All checks were successful
CI / Check, build and cache Nix flake (push) Successful in 17m10s

This commit is contained in:
Jack O'Sullivan 2023-11-21 11:18:17 +00:00
parent 0e115544e4
commit d347234e82
2 changed files with 60 additions and 48 deletions

View File

@ -59,27 +59,18 @@ in
let let
inherit (lib) mkIf mkMerge mkForce; inherit (lib) mkIf mkMerge mkForce;
inherit (lib.my) networkdAssignment; inherit (lib.my) networkdAssignment;
# TODO: Move into nixpkgs
mstpd = pkgs.mstpd.overrideAttrs {
patches = [ ./mstpd.patch ];
};
in in
{ {
imports = [ (import ./dns.nix index) ]; imports = map (m: import m index) [
./mstpd.nix
./dns.nix
];
config = { config = {
environment = { environment = {
systemPackages = [ systemPackages = with pkgs; [
pkgs.ethtool ethtool
mstpd
]; ];
etc = {
"bridge-stp.conf".text = ''
MANAGE_MSTPD=n
MSTP_BRIDGES=lan
'';
};
}; };
services = { services = {
@ -95,43 +86,11 @@ in
openFirewall = true; openFirewall = true;
}; };
networkd-dispatcher = { networkd-dispatcher.enable = true;
enable = true;
rules = {
configure-mstpd = {
onState = [ "routable" ];
script = ''
#!${pkgs.runtimeShell}
if [ $IFACE = "lan" ]; then
${mstpd}/sbin/mstpctl setforcevers $IFACE rstp
fi
'';
};
};
};
}; };
networking.domain = "h.${pubDomain}"; networking.domain = "h.${pubDomain}";
systemd = {
services = {
mstpd = {
description = "MSTP daemon";
before = [ "network-pre.target" ];
serviceConfig = {
Type = "forking";
ExecStart = "${mstpd}/sbin/bridge-stp restart";
ExecReload = "${mstpd}/sbin/bridge-stp restart_config";
PIDFile = "/run/mstpd.pid";
Restart = "always";
PrivateTmp = true;
ProtectHome = true;
};
wantedBy = [ "multi-user.target" ];
};
};
};
systemd.network = { systemd.network = {
wait-online.enable = false; wait-online.enable = false;
config = { config = {

View File

@ -0,0 +1,53 @@
index: { lib, pkgs, ... }:
let
# TODO: Move into nixpkgs
mstpd = pkgs.mstpd.overrideAttrs {
patches = [ ./mstpd.patch ];
};
in
{
environment = {
systemPackages = [
mstpd
];
etc = {
"bridge-stp.conf".text = ''
MANAGE_MSTPD=n
MSTP_BRIDGES=lan
'';
};
};
services = {
networkd-dispatcher.rules = {
configure-mstpd = {
onState = [ "routable" ];
script = ''
#!${pkgs.runtimeShell}
if [ $IFACE = "lan" ]; then
${mstpd}/sbin/mstpctl setforcevers $IFACE rstp
fi
'';
};
};
};
systemd = {
services = {
mstpd = {
description = "MSTP daemon";
before = [ "network-pre.target" ];
serviceConfig = {
Type = "forking";
ExecStart = "${mstpd}/sbin/bridge-stp restart";
ExecReload = "${mstpd}/sbin/bridge-stp restart_config";
PIDFile = "/run/mstpd.pid";
Restart = "always";
PrivateTmp = true;
ProtectHome = true;
};
wantedBy = [ "multi-user.target" ];
};
};
};
}