chore: reformat

This commit is contained in:
Tim Schubert 2025-06-03 20:04:44 +02:00
parent b638c4125b
commit 1402ee13cc
No known key found for this signature in database
57 changed files with 845 additions and 466 deletions

View file

@ -1,52 +1,70 @@
{ config
, pkgs
, lib
, ...
{
config,
pkgs,
lib,
...
}:
with lib; let
with lib;
let
cfg = config.dadada.ddns;
ddnsConfig = { domains, credentialsPath, interface }: {
systemd.timers = listToAttrs (forEach domains (domain:
nameValuePair "ddns-${domain}"
{
wantedBy = [ "timers.target" ];
partOf = [ "ddns-${domain}.service" ];
timerConfig.OnCalendar = "hourly";
}));
ddnsConfig =
{
domains,
credentialsPath,
interface,
}:
{
systemd.timers = listToAttrs (
forEach domains (
domain:
nameValuePair "ddns-${domain}" {
wantedBy = [ "timers.target" ];
partOf = [ "ddns-${domain}.service" ];
timerConfig.OnCalendar = "hourly";
}
)
);
systemd.services = listToAttrs (forEach domains (domain:
nameValuePair "ddns-${domain}"
{
serviceConfig = {
Type = "oneshot";
PrivateTmp = true;
PrivateDevices = true;
PrivateUsers = true;
PrivateMounts = true;
PrivateIPC = true;
ProtectHome = true;
ProtectSystem = "strict";
ProtectKernelTunables = true;
BindReadOnlyPaths = [ credentialsPath ];
NoNewPrivileges = true;
CapabilitBoundingSet = [ ];
};
script = ''
function url() {
echo "https://svc.joker.com/nic/update?username=$1&password=$2&hostname=$3"
}
systemd.services = listToAttrs (
forEach domains (
domain:
nameValuePair "ddns-${domain}" {
serviceConfig = {
Type = "oneshot";
PrivateTmp = true;
PrivateDevices = true;
PrivateUsers = true;
PrivateMounts = true;
PrivateIPC = true;
ProtectHome = true;
ProtectSystem = "strict";
ProtectKernelTunables = true;
BindReadOnlyPaths = [ credentialsPath ];
NoNewPrivileges = true;
CapabilitBoundingSet = [ ];
};
script = ''
function url() {
echo "https://svc.joker.com/nic/update?username=$1&password=$2&hostname=$3"
}
IFS=':'
read -r user password < ${credentialsPath}
unset IFS
IFS=':'
read -r user password < ${credentialsPath}
unset IFS
curl_url=$(url "$user" "$password" ${domain})
curl_url=$(url "$user" "$password" ${domain})
${pkgs.curl}/bin/curl --ipv4 "$curl_url" ${if interface == null then "" else "--interface ${interface}"} || true
${pkgs.curl}/bin/curl --ipv6 "$curl_url" ${if interface == null then "" else "--interface ${interface}"}
'';
}));
};
${pkgs.curl}/bin/curl --ipv4 "$curl_url" ${
if interface == null then "" else "--interface ${interface}"
} || true
${pkgs.curl}/bin/curl --ipv6 "$curl_url" ${
if interface == null then "" else "--interface ${interface}"
}
'';
}
)
);
};
in
{
options = {