nixos/mptcpd: generate config declaratively (#395893)
This commit is contained in:
@@ -5,11 +5,9 @@
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
||||
cfg = config.services.mptcpd;
|
||||
|
||||
settingsFormat = pkgs.formats.ini { };
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options = {
|
||||
@@ -20,15 +18,57 @@ in
|
||||
|
||||
package = lib.mkPackageOption pkgs "mptcpd" { };
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = settingsFormat.type;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
core = {
|
||||
"addr-flags" = "subflow";
|
||||
"notify-flags" = "existing,skip_link_local,skip_loopback,check_route";
|
||||
"load-plugins" = "addr_adv,sspi";
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
mptcpd configuration written to {file}`/etc/mptcpd/mptcpd.conf`.
|
||||
|
||||
See {manpage}`mptcpd(8)` for details about available options and syntax.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
# Disable NetworkManager from configuring the MPTCP endpoints.
|
||||
# See https://github.com/multipath-tcp/mptcpd/blob/48942b2110805af236ca41164fde67830efd7507/README.md?plain=1#L19-L38
|
||||
networking.networkmanager.connectionConfig = {
|
||||
"connection.mptcp-flags" = 1;
|
||||
};
|
||||
|
||||
environment.etc."mptcpd/mptcpd.conf".source = settingsFormat.generate "mptcpd.conf" cfg.settings;
|
||||
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
services.mptcpd.settings = {
|
||||
core = {
|
||||
log = lib.mkDefault "journal";
|
||||
"plugin-dir" = "${cfg.package}/lib/mptcpd";
|
||||
"path-manager" = lib.mkDefault "addr_adv";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.packages = [ cfg.package ];
|
||||
systemd.services.mptcp = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig.ExecStart = [
|
||||
""
|
||||
"${cfg.package}/libexec/mptcpd"
|
||||
];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -47,9 +47,15 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
postConfigure = "doxygen -u";
|
||||
|
||||
configureFlags = [
|
||||
"--sysconfdir=/etc"
|
||||
"--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
|
||||
];
|
||||
|
||||
installFlags = [
|
||||
# The NixOS module generates /etc/mptcpd/mptcpd.conf declaratively.
|
||||
"pkgsysconfdir=$out/etc/mptcpd"
|
||||
];
|
||||
|
||||
# fix: 'Fontconfig error: Cannot load default config file: No such file: (null)'
|
||||
env.FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user