From 69df0e16e7be69157f34523af28ceb83046e545e Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Thu, 8 Jan 2026 22:44:26 -0500 Subject: Netbird service --- modules/ryan-services/networking.scm | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 modules/ryan-services/networking.scm (limited to 'modules/ryan-services') diff --git a/modules/ryan-services/networking.scm b/modules/ryan-services/networking.scm new file mode 100644 index 0000000..9fd15bd --- /dev/null +++ b/modules/ryan-services/networking.scm @@ -0,0 +1,84 @@ +(define-module (ryan-services networking) + #:use-module (guix gexp) + #:use-module (guix records) + #:use-module (ryan-packages networking) + #:use-module (gnu packages linux) + #:use-module (gnu packages dns) + #:use-module (gnu packages base) + #:use-module (gnu services) + #:use-module (gnu services admin) + #:use-module (gnu services configuration) + #:use-module (gnu services shepherd) + #:export (netbird-configuration + netbird-service-type)) + +(define-configuration netbird-configuration + (netbird + (file-like netbird-bin) + "The netbird package to use") + + (iptables + (file-like iptables-nft) + "The iptables implementation to use") + + (dns-manager + (file-like openresolv) + "Resolv.conf manager") + + (log-file + (string "/var/log/netbird.log") + "Path to logs") + + (socket + (string "/var/run/netbird.sock") + "Path of UNIX socket") + + (verbosity + (string "warning") + "Log verbosity. Default is 'warning'") + + (extra-options + (list-of-strings '()) + "List of extra options") + (no-serialization)) + +(define netbird-shepherd-service + (match-record-lambda + (netbird iptables dns-manager log-file socket verbosity extra-options) + (let ((environment + #~(list (string-append "PATH=" + (string-join + '(#$(file-append iptables "/sbin") + #$(file-append iproute "/sbin") + #$(file-append dns-manager "/sbin") + #$(file-append coreutils "/bin")) + ":"))))) + (list (shepherd-service + (documentation "Run netbird") + (provision '(netbird)) + (requirement '(user-processes)) + (start + #~(make-forkexec-constructor + (list + #$(file-append netbird "/bin/netbird") + "service" "run" + "--log-level" #$verbosity + "--daemon-addr" (string-append "unix://" #$socket) + "--log-file" "console" + #$@extra-options) + #:environment-variables #$environment + #:log-file #$log-file)) + (stop #~(make-kill-destructor))))))) + +(define netbird-service-type + (service-type + (name 'netbird) + (extensions + (list (service-extension shepherd-root-service-type + netbird-shepherd-service) + (service-extension profile-service-type + (compose list netbird-configuration-netbird)) + (service-extension log-rotation-service-type + (compose list netbird-configuration-log-file)))) + (default-value (netbird-configuration)) + (description "Run netbird."))) -- cgit v1.2.3