aboutsummaryrefslogtreecommitdiff
path: root/hosts/sagittarius/headscale.nix
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/sagittarius/headscale.nix')
-rw-r--r--hosts/sagittarius/headscale.nix93
1 files changed, 0 insertions, 93 deletions
diff --git a/hosts/sagittarius/headscale.nix b/hosts/sagittarius/headscale.nix
deleted file mode 100644
index 6874ad1..0000000
--- a/hosts/sagittarius/headscale.nix
+++ /dev/null
@@ -1,93 +0,0 @@
-{ pkgs, config, ... }:
-let
- domain = "headscale.sorre.xyz";
- port = 5892;
-in
-{
- imports = [ ./web/acme.nix ];
-
- services.headscale = {
- enable = true;
- inherit port;
- address = "127.0.0.1";
- settings = {
- server_url = "https://${domain}";
- dns = {
- base_domain = "sorre.internal";
- nameservers.global = [
- "1.1.1.1"
- "2301:db8:acad:a::1"
- ];
- extra_records = [
- {
- name = "vaultwarden.sorre.internal";
- type = "AAAA";
- value = "100.64.0.3";
- }
- {
- name = "git.sorre.internal";
- type = "AAAA";
- value = "100.64.0.3";
- }
- {
- name = "music.sorre.internal";
- type = "AAAA";
- value = "100.64.0.3";
- }
- ];
- };
- };
- };
- environment.systemPackages = [ config.services.headscale.package ];
-
- services.nginx.virtualHosts."${domain}" = {
- forceSSL = true;
- enableACME = true;
- locations."/" = {
- proxyPass = "http://localhost:${toString port}";
- proxyWebsockets = true;
- };
- };
-
- # also enable the tailscale client since this is a node too
- services.tailscale = {
- enable = true;
- openFirewall = true;
- };
- networking.firewall = {
- checkReversePath = "loose";
- trustedInterfaces = [ "tailscale0" ];
- allowedUDPPorts = [ config.services.tailscale.port ];
- };
-
- systemd.services.backup-headscale = {
- serviceConfig.Type = "oneshot";
- description = "Back up headscale data";
- conflicts = [ "headscale.service" ];
- path = [
- pkgs.gnutar
- pkgs.systemdMinimal
- ];
- enableStrictShellChecks = true;
- script = ''
- #!/usr/bin/env bash
- set -euo pipefail
-
- [ ! -d /var/lib/backup/headscale ] && mkdir -p /var/lib/backup/headscale
- TIMESTAMP="$(date +%Y%m%d%H%M%S)"
- tar cvf "/var/lib/backup/headscale/$TIMESTAMP.backup.tar" /var/lib/headscale
-
- find /var/lib/backup/headscale -type f -name '*.backup.tar' -print0 |
- sort --zero-terminated --reverse |
- tail --zero-terminated --lines=+6 |
- xargs --null --no-run-if-empty rm --
- '';
- postStop = "systemctl start headscale.service";
- };
-
- systemd.timers.backup-headscale = {
- description = "Back up headscale every morning";
- timerConfig.OnCalendar = "*-*-* 05:00:00";
- wantedBy = [ "timers.target" ];
- };
-}