diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/ryan-config/base-system.scm | 2 | ||||
| -rw-r--r-- | modules/ryan-services/networking.scm | 84 |
2 files changed, 86 insertions, 0 deletions
diff --git a/modules/ryan-config/base-system.scm b/modules/ryan-config/base-system.scm index e4e7f90..e1cf87b 100644 --- a/modules/ryan-config/base-system.scm +++ b/modules/ryan-config/base-system.scm | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #:use-module (gnu services xorg) | 29 | #:use-module (gnu services xorg) |
| 30 | #:use-module (gnu services ssh) | 30 | #:use-module (gnu services ssh) |
| 31 | #:use-module (ryan-services nix) | 31 | #:use-module (ryan-services nix) |
| 32 | #:use-module (ryan-services networking) | ||
| 32 | #:use-module (gnu services sound) | 33 | #:use-module (gnu services sound) |
| 33 | #:use-module (gnu services docker) | 34 | #:use-module (gnu services docker) |
| 34 | #:use-module (gnu services avahi) | 35 | #:use-module (gnu services avahi) |
| @@ -191,6 +192,7 @@ | |||
| 191 | (service tailscale-service-type | 192 | (service tailscale-service-type |
| 192 | (tailscale-configuration | 193 | (tailscale-configuration |
| 193 | (socket "/var/run/tailscale/tailscaled.sock"))) | 194 | (socket "/var/run/tailscale/tailscaled.sock"))) |
| 195 | (service netbird-service-type) | ||
| 194 | (service containerd-service-type) | 196 | (service containerd-service-type) |
| 195 | (service nix-service-type | 197 | (service nix-service-type |
| 196 | (nix-configuration | 198 | (nix-configuration |
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 @@ | |||
| 1 | (define-module (ryan-services networking) | ||
| 2 | #:use-module (guix gexp) | ||
| 3 | #:use-module (guix records) | ||
| 4 | #:use-module (ryan-packages networking) | ||
| 5 | #:use-module (gnu packages linux) | ||
| 6 | #:use-module (gnu packages dns) | ||
| 7 | #:use-module (gnu packages base) | ||
| 8 | #:use-module (gnu services) | ||
| 9 | #:use-module (gnu services admin) | ||
| 10 | #:use-module (gnu services configuration) | ||
| 11 | #:use-module (gnu services shepherd) | ||
| 12 | #:export (netbird-configuration | ||
| 13 | netbird-service-type)) | ||
| 14 | |||
| 15 | (define-configuration netbird-configuration | ||
| 16 | (netbird | ||
| 17 | (file-like netbird-bin) | ||
| 18 | "The netbird package to use") | ||
| 19 | |||
| 20 | (iptables | ||
| 21 | (file-like iptables-nft) | ||
| 22 | "The iptables implementation to use") | ||
| 23 | |||
| 24 | (dns-manager | ||
| 25 | (file-like openresolv) | ||
| 26 | "Resolv.conf manager") | ||
| 27 | |||
| 28 | (log-file | ||
| 29 | (string "/var/log/netbird.log") | ||
| 30 | "Path to logs") | ||
| 31 | |||
| 32 | (socket | ||
| 33 | (string "/var/run/netbird.sock") | ||
| 34 | "Path of UNIX socket") | ||
| 35 | |||
| 36 | (verbosity | ||
| 37 | (string "warning") | ||
| 38 | "Log verbosity. Default is 'warning'") | ||
| 39 | |||
| 40 | (extra-options | ||
| 41 | (list-of-strings '()) | ||
| 42 | "List of extra options") | ||
| 43 | (no-serialization)) | ||
| 44 | |||
| 45 | (define netbird-shepherd-service | ||
| 46 | (match-record-lambda <netbird-configuration> | ||
| 47 | (netbird iptables dns-manager log-file socket verbosity extra-options) | ||
| 48 | (let ((environment | ||
| 49 | #~(list (string-append "PATH=" | ||
| 50 | (string-join | ||
| 51 | '(#$(file-append iptables "/sbin") | ||
| 52 | #$(file-append iproute "/sbin") | ||
| 53 | #$(file-append dns-manager "/sbin") | ||
| 54 | #$(file-append coreutils "/bin")) | ||
| 55 | ":"))))) | ||
| 56 | (list (shepherd-service | ||
| 57 | (documentation "Run netbird") | ||
| 58 | (provision '(netbird)) | ||
| 59 | (requirement '(user-processes)) | ||
| 60 | (start | ||
| 61 | #~(make-forkexec-constructor | ||
| 62 | (list | ||
| 63 | #$(file-append netbird "/bin/netbird") | ||
| 64 | "service" "run" | ||
| 65 | "--log-level" #$verbosity | ||
| 66 | "--daemon-addr" (string-append "unix://" #$socket) | ||
| 67 | "--log-file" "console" | ||
| 68 | #$@extra-options) | ||
| 69 | #:environment-variables #$environment | ||
| 70 | #:log-file #$log-file)) | ||
| 71 | (stop #~(make-kill-destructor))))))) | ||
| 72 | |||
| 73 | (define netbird-service-type | ||
| 74 | (service-type | ||
| 75 | (name 'netbird) | ||
| 76 | (extensions | ||
| 77 | (list (service-extension shepherd-root-service-type | ||
| 78 | netbird-shepherd-service) | ||
| 79 | (service-extension profile-service-type | ||
| 80 | (compose list netbird-configuration-netbird)) | ||
| 81 | (service-extension log-rotation-service-type | ||
| 82 | (compose list netbird-configuration-log-file)))) | ||
| 83 | (default-value (netbird-configuration)) | ||
| 84 | (description "Run netbird."))) | ||
