0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 06:00:33 +03:00

nixos/services.babeld: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-28 21:19:01 +02:00 committed by Jörg Thalheim
parent eb8d4ed264
commit 7da36d70ff

View file

@ -1,20 +1,17 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.babeld; cfg = config.services.babeld;
conditionalBoolToString = value: if (isBool value) then (boolToString value) else (toString value); conditionalBoolToString = value: if (lib.isBool value) then (lib.boolToString value) else (toString value);
paramsString = params: paramsString = params:
concatMapStringsSep " " (name: "${name} ${conditionalBoolToString (getAttr name params)}") lib.concatMapStringsSep " " (name: "${name} ${conditionalBoolToString (lib.getAttr name params)}")
(attrNames params); (lib.attrNames params);
interfaceConfig = name: interfaceConfig = name:
let let
interface = getAttr name cfg.interfaces; interface = lib.getAttr name cfg.interfaces;
in in
"interface ${name} ${paramsString interface}\n"; "interface ${name} ${paramsString interface}\n";
@ -22,17 +19,17 @@ let
'' ''
skip-kernel-setup true skip-kernel-setup true
'' ''
+ (optionalString (cfg.interfaceDefaults != null) '' + (lib.optionalString (cfg.interfaceDefaults != null) ''
default ${paramsString cfg.interfaceDefaults} default ${paramsString cfg.interfaceDefaults}
'') '')
+ (concatMapStrings interfaceConfig (attrNames cfg.interfaces)) + (lib.concatMapStrings interfaceConfig (lib.attrNames cfg.interfaces))
+ extraConfig); + extraConfig);
in in
{ {
meta.maintainers = with maintainers; [ hexa ]; meta.maintainers = with lib.maintainers; [ hexa ];
###### interface ###### interface
@ -40,15 +37,15 @@ in
services.babeld = { services.babeld = {
enable = mkEnableOption "the babeld network routing daemon"; enable = lib.mkEnableOption "the babeld network routing daemon";
interfaceDefaults = mkOption { interfaceDefaults = lib.mkOption {
default = null; default = null;
description = '' description = ''
A set describing default parameters for babeld interfaces. A set describing default parameters for babeld interfaces.
See {manpage}`babeld(8)` for options. See {manpage}`babeld(8)` for options.
''; '';
type = types.nullOr (types.attrsOf types.unspecified); type = lib.types.nullOr (lib.types.attrsOf lib.types.unspecified);
example = example =
{ {
type = "tunnel"; type = "tunnel";
@ -56,13 +53,13 @@ in
}; };
}; };
interfaces = mkOption { interfaces = lib.mkOption {
default = {}; default = {};
description = '' description = ''
A set describing babeld interfaces. A set describing babeld interfaces.
See {manpage}`babeld(8)` for options. See {manpage}`babeld(8)` for options.
''; '';
type = types.attrsOf (types.attrsOf types.unspecified); type = lib.types.attrsOf (lib.types.attrsOf lib.types.unspecified);
example = example =
{ enp0s2 = { enp0s2 =
{ type = "wired"; { type = "wired";
@ -72,9 +69,9 @@ in
}; };
}; };
extraConfig = mkOption { extraConfig = lib.mkOption {
default = ""; default = "";
type = types.lines; type = lib.types.lines;
description = '' description = ''
Options that will be copied to babeld.conf. Options that will be copied to babeld.conf.
See {manpage}`babeld(8)` for details. See {manpage}`babeld(8)` for details.
@ -87,7 +84,7 @@ in
###### implementation ###### implementation
config = mkIf config.services.babeld.enable { config = lib.mkIf config.services.babeld.enable {
boot.kernel.sysctl = { boot.kernel.sysctl = {
"net.ipv6.conf.all.forwarding" = 1; "net.ipv6.conf.all.forwarding" = 1;