diff options
author | Thanos Apollo <[email protected]> | 2024-05-13 08:42:44 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-05-13 08:42:44 +0300 |
commit | 2e74d58a4f675b5301e69cae105503198d7ff846 (patch) | |
tree | e92cca5c6406898e9ac1eae08653d894c24e3acf /guix/services/tailscale.scm | |
parent | b6d164b032b255767b04a73e8ac0e04b61991048 (diff) | |
parent | 5d6840de02f01c017cc1ce99238d6962331087da (diff) |
Merge branch 'guix-config'
Diffstat (limited to 'guix/services/tailscale.scm')
-rw-r--r-- | guix/services/tailscale.scm | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/guix/services/tailscale.scm b/guix/services/tailscale.scm new file mode 100644 index 0000000..0632a41 --- /dev/null +++ b/guix/services/tailscale.scm @@ -0,0 +1,66 @@ +;; Under construction + +(define-module (services tailscale) + #:use-module (gnu services) + #:use-module (gnu services shepherd) + #:use-module (gnu services configuration) + #:use-module (guix records) + #:use-module (guix gexp) + #:use-module (ice-9 match) + #:use-module (packages tailscale) + #:use-module (gnu packages linux) + #:export (tailscaled-service-type tailscaled-configuration)) + +;; TODO: https://tailscale.com/kb/1188/linux-dns/#dhcp-dhclient-overwriting-etcresolvconf + +(define-record-type* <tailscaled-configuration> + tailscaled-configuration make-tailscaled-configuration + tailscaled-configuration? + (tailscale tailscaled-configuration-tailscale + (default tailscale)) + (listen-port tailscaled-configuration-listen-port + (default "41641")) + (state-file tailscaled-configuration-state-file + (default "tailscaled.state"))) + +(define (tailscaled-activation config) + "Run tailscaled --cleanup" + #~(begin + (system* #$(file-append tailscale "/usr/bin/tailscaled") "--cleanup"))) + +(define (tailscaled-shepherd-service config) + "Return a <shepherd-service> for Tailscaled with CONFIG" + (let ((tailscale + (tailscaled-configuration-tailscale config)) + (listen-port + (tailscaled-configuration-listen-port config)) + (state-file + (tailscaled-configuration-state-file config)) + (environment #~(list (string-append + "PATH=" ; iptables is required for tailscale to work + (string-append #$iptables "/sbin") + ":" + (string-append #$iptables "/bin"))))) + (list + (shepherd-service + (provision '(tailscaled)) + (requirement '(networking)) ;; services this depends on + (start #~(make-forkexec-constructor + (list #$(file-append tailscale "/usr/bin/tailscaled") + "-state" #$state-file + ;"-port" #$listen-port + "-verbose" "10") + #:environment-variables #$environment + #:log-file "/var/log/tailscaled.log")) + (stop #~(make-kill-destructor)))))) + +(define tailscaled-service-type + (service-type + (name 'tailscaled) + (extensions + (list (service-extension shepherd-root-service-type + tailscaled-shepherd-service) + (service-extension activation-service-type + tailscaled-activation))) + (default-value (tailscaled-configuration)) + (description "Launch tailscaled."))) |