From a752443975ce2b3c1ca83551b2063bcf72af3206 Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Sun, 27 Dec 2020 15:21:58 +0100 Subject: Add the service to add a static IPv6 to the system --- .guix-channel | 6 ++++ guix/vkraus/services/static-ipv6.scm | 62 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .guix-channel create mode 100644 guix/vkraus/services/static-ipv6.scm diff --git a/.guix-channel b/.guix-channel new file mode 100644 index 0000000..8e7197b --- /dev/null +++ b/.guix-channel @@ -0,0 +1,6 @@ +(channel + (version 0) + (directory "guix")) +;; Local Variables: +;; mode: scheme +;; End: diff --git a/guix/vkraus/services/static-ipv6.scm b/guix/vkraus/services/static-ipv6.scm new file mode 100644 index 0000000..a0f3a45 --- /dev/null +++ b/guix/vkraus/services/static-ipv6.scm @@ -0,0 +1,62 @@ +(define-module (vkraus services static-ipv6) + #:use-module (gnu services) + #:use-module (gnu services shepherd) + #:use-module (guix gexp) + #:use-module (guix modules) + #:use-module (guix records) + #:use-module (gnu packages linux) + #:use-module (ice-9 match) + #:use-module (ice-9 optargs)) + +(define-record-type* + static-ipv6-configuration + make-static-ipv6-configuration + static-ipv6-configuration? + (iproute static-ipv6-configuration-iproute (default iproute)) + (address static-ipv6-configuration-address) + (interface static-ipv6-configuration-interface)) + +(export + static-ipv6-configuration + make-static-ipv6-configuration + static-ipv6-configuration? + static-ipv6-configuration-iproute + static-ipv6-configuration-address + static-ipv6-configuration-interface) + +(define static-ipv6-shepherd-service + (match-lambda + (($ + iproute address interface) + (list + (shepherd-service + (provision '(static-ipv6)) + (documentation (format #f "Add ~a/128 to interface ~a" + address interface)) + (requirement '(user-processes loopback syslogd)) + (start + #~(lambda _ + (system* + (string-append #$iproute "/sbin/ip") + "address" + "add" + "dev" + #$interface + (string-append #$address "/128")))) + (stop + #~(lambda _ + (system* + (string-append #$iproute "/sbin/ip") + "address" + "delete" + "dev" + #$interface + (string-append #$address "/128"))))))))) + +(define-public static-ipv6-service-type + (service-type (name 'static-ipv6) + (extensions + (list + (service-extension + shepherd-root-service-type + static-ipv6-service))))) -- cgit v1.2.3