blob: ba374e3b9969ea0a20efada40150ac3b0464a7cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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>
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>
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
(($ <static-ipv6-configuration>
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-shepherd-service)))))
|