Skip to content

Commit

Permalink
Use the path option in systemd instead of repeating pkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
notthebee committed Oct 26, 2024
1 parent a185040 commit f76d0b3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions nixos/modules/services/misc/duckdns.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ in
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
startAt = "*:0/5";
path = [
pkgs.gnused
pkgs.systemd
pkgs.curl
];
serviceConfig = {
Type = "simple";
LoadCredential = [
Expand All @@ -57,14 +62,14 @@ in
DynamicUser = true;
};
script = ''
export DUCKDNS_TOKEN=$(${pkgs.systemd}/bin/systemd-creds cat DUCKDNS_TOKEN_FILE)
export DUCKDNS_TOKEN=$(systemd-creds cat DUCKDNS_TOKEN_FILE)
${lib.optionalString (cfg.domains != null) ''
export DUCKDNS_DOMAINS='${lib.strings.concatStringsSep "," cfg.domains}'
''}
${lib.optionalString (cfg.domainsFile != null) ''
export DUCKDNS_DOMAINS=$(${pkgs.systemd}/bin/systemd-creds cat DUCKDNS_DOMAINS_FILE | ${pkgs.gnused}/bin/sed -z 's/\n/,/g')
export DUCKDNS_DOMAINS=$(systemd-creds cat DUCKDNS_DOMAINS_FILE | sed -z 's/\n/,/g')
''}
${pkgs.curl}/bin/curl --no-progress-meter -k "https://www.duckdns.org/update?domains=$DUCKDNS_DOMAINS&token=$DUCKDNS_TOKEN&ip=" | grep -v "KO"
curl --no-progress-meter -k "https://www.duckdns.org/update?domains=$DUCKDNS_DOMAINS&token=$DUCKDNS_TOKEN&ip=" | grep -v "KO"
'';
};
};
Expand Down

0 comments on commit f76d0b3

Please sign in to comment.