diff options
| author | Mathias Magnusson <mathias@magnusson.space> | 2025-11-18 16:00:45 +0100 |
|---|---|---|
| committer | Mathias Magnusson <mathias@magnusson.space> | 2025-11-18 16:00:45 +0100 |
| commit | 3c214d788e671e867231d30374465f14969c46dd (patch) | |
| tree | 46d6d89984b6f28960a3d399fb7c7ab4d1b41cb5 | |
| parent | c95b2340926c9158f72a8e4a0248ea0d7ac384f0 (diff) | |
| download | oden-3c214d788e671e867231d30374465f14969c46dd.tar.gz | |
move ddns setup to hetzner
| -rw-r--r-- | flake.lock | 19 | ||||
| -rw-r--r-- | flake.nix | 2 | ||||
| -rw-r--r-- | router.nix | 19 | ||||
| -rw-r--r-- | secrets/dyndns-url.txt.age | bin | 890 -> 0 bytes | |||
| -rw-r--r-- | secrets/hcloud-token.txt.age | 11 | ||||
| -rw-r--r-- | secrets/secrets.nix | 2 |
6 files changed, 46 insertions, 7 deletions
@@ -101,7 +101,8 @@ "agenix": "agenix", "disko": "disko", "impermanence": "impermanence", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "unstable": "unstable" } }, "systems": { @@ -118,6 +119,22 @@ "repo": "default", "type": "github" } + }, + "unstable": { + "locked": { + "lastModified": 1763283776, + "narHash": "sha256-Y7TDFPK4GlqrKrivOcsHG8xSGqQx3A6c+i7novT85Uk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "50a96edd8d0db6cc8db57dab6bb6d6ee1f3dc49a", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } } }, "root": "root", @@ -1,6 +1,7 @@ { inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; + unstable.url = "github:nixos/nixpkgs/nixos-unstable"; disko.url = "github:nix-community/disko/latest"; disko.inputs.nixpkgs.follows = "nixpkgs"; @@ -15,6 +16,7 @@ inputs@{ self, nixpkgs, + unstable, disko, impermanence, agenix, @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, inputs, ... }: { boot.kernel.sysctl."net.ipv4.conf.all.forwarding" = true; @@ -113,7 +113,11 @@ }; services.resolved.enable = false; - services.networkd-dispatcher = { + services.networkd-dispatcher = + let + logPath = "/home/mathias/networkd-dispatcher-run"; + in + { enable = true; rules."ddns" = { onState = [ "routable" ]; @@ -124,8 +128,13 @@ exit 0 fi - ${pkgs.curl}/bin/curl "$(cat "${config.age.secrets."dyndns-url.txt".path}")" - printf "%s: %s\n" "$(date)" "$ADDR" >> /home/mathias/networkd-dispatcher-run + { + echo + printf "%s: %s\n" "$(date)" "$ADDR" + HCLOUD_TOKEN="$(cat "${config.age.secrets."hcloud-token.txt".path}")" \ + ${inputs.unstable.legacyPackages.${pkgs.system}.hcloud}/bin/hcloud \ + zone rrset set-records 0m.nu @ A --record "''${ADDR%% *}" 2>&1 + } >> "${logPath}" exit 0 ''; @@ -197,5 +206,5 @@ age.secrets."wifi-password-staff.txt".file = ./secrets/wifi-password-staff.txt.age; age.secrets."wifi-password-guest.txt".file = ./secrets/wifi-password-guest.txt.age; - age.secrets."dyndns-url.txt".file = ./secrets/dyndns-url.txt.age; + age.secrets."hcloud-token.txt".file = ./secrets/hcloud-token.txt.age; } diff --git a/secrets/dyndns-url.txt.age b/secrets/dyndns-url.txt.age Binary files differdeleted file mode 100644 index dbf3c3a..0000000 --- a/secrets/dyndns-url.txt.age +++ /dev/null diff --git a/secrets/hcloud-token.txt.age b/secrets/hcloud-token.txt.age new file mode 100644 index 0000000..701a063 --- /dev/null +++ b/secrets/hcloud-token.txt.age @@ -0,0 +1,11 @@ +age-encryption.org/v1 +-> ssh-ed25519 rf0kpA wxZ09LiaTQpcdLKOKIQqcE3/CdInswNAJ35sd/Pt22I +375f2Xnso9H2G6C+5aHRn2NYa5wFqf5CqPBPQYmbD40 +-> piv-p256 Ddzw4A A0Kb2sXQpRfcGcbH6y7AOP7BcFmfqIvdGXYq3/FVRk4j +8ayXqPGcsziJE9JYXwX1fYNXp05GI5LVs4ECKLNhE4I +-> piv-p256 9aSbLw A9HL79joXH6caWdS10Xs9WE8O9Ge/+TWi7tJ0OT4SFI1 +MlrtoF7177oEsTeFu6EFGHKNs1j2ryAEfSbEAmGHeOE +-> ssh-ed25519 YS7/yg H0+P1FqpX7kyWXOJgGw08MR8MoSD1knH3CFFNMzdi0g +1+vMosdhLLulrGwMfspuZKeDSlSZq1YBbXpjLxofPxk +--- 65Ii7+Abj6Y4RlMMXkheq6bU41gj9on/Oc8qDnTvRyE +Bb™$Ç6訣+ŸÀLU’݇ú¦„?³ûwÍ:·z#&ù†Óìíª Ìœk*éû·‰ˆÉ!ß¾øJAô}™Ôœ4Þ—#³}†Ö3+âw%»%ëdÀ¼ÑŸùnmµÑ
\ No newline at end of file diff --git a/secrets/secrets.nix b/secrets/secrets.nix index be661f8..acb5d8d 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -10,7 +10,7 @@ let "wifi-password-staff.txt.age" "wifi-password-guest.txt.age" "password-hash.txt.age" - "dyndns-url.txt.age" + "hcloud-token.txt.age" ]; in builtins.listToAttrs ( |
