nixos/services.inadyn: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-28 21:19:10 +02:00 committed by Jörg Thalheim
parent f69dd2df9a
commit b610b3cac2

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.inadyn;
@ -11,10 +8,10 @@ let
renderOption = k: v:
if builtins.elem k [ "provider" "custom" ] then
lib.concatStringsSep "\n"
(mapAttrsToList
(lib.mapAttrsToList
(name: config: ''
${k} ${name} {
${lib.concatStringsSep "\n " (mapAttrsToList renderOption (filterAttrs nonEmptyValue config))}
${lib.concatStringsSep "\n " (lib.mapAttrsToList renderOption (lib.filterAttrs nonEmptyValue config))}
}'')
v)
else if k == "include" then
@ -22,7 +19,7 @@ let
else if k == "hostname" && builtins.isList v then
"${k} = { ${builtins.concatStringsSep ", " (map (s: "\"${s}\"") v)} }"
else if builtins.isBool v then
"${k} = ${boolToString v}"
"${k} = ${lib.boolToString v}"
else if builtins.isString v then
"${k} = \"${v}\""
else
@ -33,32 +30,32 @@ let
# This file was generated by nix
# do not edit
${(lib.concatStringsSep "\n" (mapAttrsToList renderOption (filterAttrs nonEmptyValue cfg.settings)))}
${(lib.concatStringsSep "\n" (lib.mapAttrsToList renderOption (lib.filterAttrs nonEmptyValue cfg.settings)))}
'';
configFile = if (cfg.configFile != null) then cfg.configFile else configFile';
in
{
options.services.inadyn = with types;
options.services.inadyn = with lib.types;
let
providerOptions =
{
include = mkOption {
include = lib.mkOption {
default = null;
description = "File to include additional settings for this provider from.";
type = nullOr path;
};
ssl = mkOption {
ssl = lib.mkOption {
default = true;
description = "Whether to use HTTPS for this DDNS provider.";
type = bool;
};
username = mkOption {
username = lib.mkOption {
default = null;
description = "Username for this DDNS provider.";
type = nullOr str;
};
password = mkOption {
password = lib.mkOption {
default = null;
description = ''
Password for this DDNS provider.
@ -68,7 +65,7 @@ in
'';
type = nullOr str;
};
hostname = mkOption {
hostname = lib.mkOption {
default = "*";
example = "your.cool-domain.com";
description = "Hostname alias(es).";
@ -77,12 +74,12 @@ in
};
in
{
enable = mkEnableOption (''
enable = lib.mkEnableOption (''
synchronise your machine's IP address with a dynamic DNS provider using inadyn
'');
user = mkOption {
user = lib.mkOption {
default = "inadyn";
type = types.str;
type = lib.types.str;
description = ''
User account under which inadyn runs.
@ -93,9 +90,9 @@ in
:::
'';
};
group = mkOption {
group = lib.mkOption {
default = "inadyn";
type = types.str;
type = lib.types.str;
description = ''
Group account under which inadyn runs.
@ -106,7 +103,7 @@ in
:::
'';
};
interval = mkOption {
interval = lib.mkOption {
default = "*-*-* *:*:00";
description = ''
How often to check the current IP.
@ -119,24 +116,24 @@ in
default = "notice";
description = "Set inadyn's log level.";
};
settings = mkOption {
settings = lib.mkOption {
default = { };
description = "See `inadyn.conf (5)`";
type = submodule {
freeformType = attrs;
options = {
allow-ipv6 = mkOption {
allow-ipv6 = lib.mkOption {
default = config.networking.enableIPv6;
defaultText = "`config.networking.enableIPv6`";
description = "Whether to get IPv6 addresses from interfaces.";
type = bool;
};
forced-update = mkOption {
forced-update = lib.mkOption {
default = 2592000;
description = "Duration (in seconds) after which an update is forced.";
type = ints.positive;
};
provider = mkOption {
provider = lib.mkOption {
default = { };
description = ''
Settings for DDNS providers built-in to inadyn.
@ -148,7 +145,7 @@ in
options = providerOptions;
});
};
custom = mkOption {
custom = lib.mkOption {
default = { };
description = ''
Settings for custom DNS providers.
@ -156,11 +153,11 @@ in
type = attrsOf (submodule {
freeformType = attrs;
options = providerOptions // {
ddns-server = mkOption {
ddns-server = lib.mkOption {
description = "DDNS server name.";
type = str;
};
ddns-path = mkOption {
ddns-path = lib.mkOption {
description = ''
DDNS server path.
@ -175,7 +172,7 @@ in
};
};
};
configFile = mkOption {
configFile = lib.mkOption {
default = null;
description = ''
Configuration file for inadyn.
@ -238,12 +235,12 @@ in
timers.inadyn.timerConfig.Persistent = true;
};
users.users.inadyn = mkIf (cfg.user == "inadyn") {
users.users.inadyn = lib.mkIf (cfg.user == "inadyn") {
group = cfg.group;
isSystemUser = true;
};
users.groups = mkIf (cfg.group == "inadyn") {
users.groups = lib.mkIf (cfg.group == "inadyn") {
inadyn = { };
};
};