diff options
Diffstat (limited to 'contrib/services/shepherd/ng0_wip/001-gnu-services-Add-gnunet-service.patch')
-rw-r--r-- | contrib/services/shepherd/ng0_wip/001-gnu-services-Add-gnunet-service.patch | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/contrib/services/shepherd/ng0_wip/001-gnu-services-Add-gnunet-service.patch b/contrib/services/shepherd/ng0_wip/001-gnu-services-Add-gnunet-service.patch new file mode 100644 index 000000000..0017ec8cf --- /dev/null +++ b/contrib/services/shepherd/ng0_wip/001-gnu-services-Add-gnunet-service.patch | |||
@@ -0,0 +1,204 @@ | |||
1 | From 91241bacb6533745535ff28d20f087ecd571e7be Mon Sep 17 00:00:00 2001 | ||
2 | From: ng0 <ng0@we.make.ritual.n0.is> | ||
3 | Date: Mon, 12 Sep 2016 12:26:52 +0000 | ||
4 | Subject: [PATCH] gnu: services: Add gnunet-service. | ||
5 | |||
6 | --- | ||
7 | doc/guix.texi | 36 ++++++++++++++ | ||
8 | gnu/services/networking.scm | 114 +++++++++++++++++++++++++++++++++++++++++++- | ||
9 | 2 files changed, 149 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/doc/guix.texi b/doc/guix.texi | ||
12 | index 99bde4aca..6c683393e 100644 | ||
13 | --- a/doc/guix.texi | ||
14 | +++ b/doc/guix.texi | ||
15 | @@ -8903,6 +8903,42 @@ Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6 | ||
16 | sockets. | ||
17 | @end deffn | ||
18 | |||
19 | +@cindex GNUnet | ||
20 | +@cindex gnunet | ||
21 | +@subsubheading GNUnet Service | ||
22 | + | ||
23 | +@deffn {Scheme Variable} gnunet-service-type | ||
24 | +This is the type of the @uref{https://gnunet.org, GNUnet} | ||
25 | +service, whose value should be an @code{gnunet-configuration} object | ||
26 | +as in this example: | ||
27 | + | ||
28 | +@example | ||
29 | +(service gnunet-service-type | ||
30 | + (gnunet-configuration | ||
31 | + (config-file (local-file "./gnunet.conf")))) | ||
32 | +@end example | ||
33 | +@end deffn | ||
34 | + | ||
35 | +@deftp {Data Type} gnunet-configuration | ||
36 | +Data type representing the configuration of GNUnet. | ||
37 | + | ||
38 | +@table @asis | ||
39 | +@item @code{package} (default: @var{gnunet}) | ||
40 | +Package object of the GNUnet service. | ||
41 | + | ||
42 | +@item @code{config-file} (default: @var{%default-gnunet-file}) | ||
43 | +File-like object of the GNUnet configuration file to use. For NAT is | ||
44 | +assumes by default that you are behind a NAT (@var{BEHIND_NAT = YES}) | ||
45 | +and enables UPNP (@var{ENABLE_UPNP = YES}). | ||
46 | +The hostlist is configured with the options @var{-b} (bootstrap using | ||
47 | +configured hostlist servers) and @var{-e} (enable learning advertised hostlists). | ||
48 | +Read the configuration files in @var{"~/.guix-profile/share/gnunet/config.d/"} | ||
49 | +for more information. These files also set the defaults when you don't set | ||
50 | +any explicit values to override them. | ||
51 | + | ||
52 | +@end table | ||
53 | +@end deftp | ||
54 | + | ||
55 | |||
56 | @node X Window | ||
57 | @subsubsection X Window | ||
58 | diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm | ||
59 | index d672ecf68..ff3615ea2 100644 | ||
60 | --- a/gnu/services/networking.scm | ||
61 | +++ b/gnu/services/networking.scm | ||
62 | @@ -3,6 +3,7 @@ | ||
63 | ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> | ||
64 | ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il> | ||
65 | ;;; Copyright © 2016 John Darrington <jmd@gnu.org> | ||
66 | +;;; Copyright © 2016 ng0 <ng0@libertad.pw> | ||
67 | ;;; | ||
68 | ;;; This file is part of GNU Guix. | ||
69 | ;;; | ||
70 | @@ -27,6 +28,7 @@ | ||
71 | #:use-module (gnu system pam) | ||
72 | #:use-module (gnu packages admin) | ||
73 | #:use-module (gnu packages connman) | ||
74 | + #:use-module (gnu packages gnunet) | ||
75 | #:use-module (gnu packages linux) | ||
76 | #:use-module (gnu packages tor) | ||
77 | #:use-module (gnu packages messaging) | ||
78 | @@ -66,7 +68,12 @@ | ||
79 | wicd-service | ||
80 | network-manager-service | ||
81 | connman-service | ||
82 | - wpa-supplicant-service-type)) | ||
83 | + wpa-supplicant-service-type | ||
84 | + | ||
85 | + gnunet-configuration | ||
86 | + gnunet-configuration? | ||
87 | + gnunet-service-type | ||
88 | + %default-gnunet-config-file)) | ||
89 | |||
90 | ;;; Commentary: | ||
91 | ;;; | ||
92 | @@ -781,4 +788,109 @@ configure networking." | ||
93 | (service-extension dbus-root-service-type list) | ||
94 | (service-extension profile-service-type list))))) | ||
95 | |||
96 | + | ||
97 | +;;; GNUnet | ||
98 | +;;; | ||
99 | +;;; | ||
100 | + | ||
101 | +(define-record-type* <gnunet-configuration> | ||
102 | + gnunet-configuration make-gnunet-configuration | ||
103 | + gnunet-configuration? | ||
104 | + (package gnunet-configuration-package | ||
105 | + (default gnunet)) | ||
106 | + (config-file gnunet-configuration-config-file | ||
107 | + (default %default-gnunet-config-file))) | ||
108 | + | ||
109 | +(define %default-gnunet-config-file | ||
110 | + (plain-file "gnunet.conf" " | ||
111 | +[PATHS] | ||
112 | +SERVICEHOME = /var/lib/gnunet | ||
113 | +GNUNET_CONFIG_HOME = /var/lib/gnunet | ||
114 | + | ||
115 | +[arm] | ||
116 | +SYSTEM_ONLY = YES | ||
117 | +USER_ONLY = NO | ||
118 | + | ||
119 | +[nat] | ||
120 | +BEHIND_NAT = YES | ||
121 | +ENABLE_UPNP = YES | ||
122 | + | ||
123 | +[hostlist] | ||
124 | +OPTIONS = -b -e | ||
125 | +")) | ||
126 | + | ||
127 | +(define gnunet-shepherd-service | ||
128 | + (match-lambda | ||
129 | + (($ <gnunet-configuration> package config-file) | ||
130 | + (list (shepherd-service | ||
131 | + (provision '(gnunet)) | ||
132 | + (requirement '(user-processes loopback)) | ||
133 | + (documentation "Run the GNUnet service.") | ||
134 | + (start | ||
135 | + (let ((gnunet | ||
136 | + (file-append package "/lib/gnunet/libexec/gnunet-service-arm"))) | ||
137 | + #~(make-forkexec-constructor | ||
138 | + (list #$gnunet "-c" #$config-file) | ||
139 | + #:pid-file "/var/run/gnunet.pid"))) | ||
140 | + (stop | ||
141 | + #~(make-kill-destructor | ||
142 | + (list #$gnunet "-e")))))))) | ||
143 | + | ||
144 | +(define %gnunet-accounts | ||
145 | + (list (user-group | ||
146 | + (name "gnunetdns") | ||
147 | + (system? #t)) | ||
148 | + (user-group | ||
149 | + (name "gnunet") | ||
150 | + (system? #t)) | ||
151 | + (user-account | ||
152 | + (name "gnunet") | ||
153 | + (group "gnunet") | ||
154 | + (system? #t) | ||
155 | + (comment "GNUnet system user") | ||
156 | + (home-directory "/var/empty") | ||
157 | + (shell #~(string-append #$shadow "/sbin/nologin"))))) | ||
158 | + | ||
159 | +(define gnunet-activation | ||
160 | + (match-lambda | ||
161 | + (($ <gnunet-configuration> package config-file) | ||
162 | + (let ((gnunet | ||
163 | + (file-append package "/lib/gnunet/libexec/gnunet-service-arm"))) | ||
164 | + #~(begin | ||
165 | + (use-modules (guix build utils)) | ||
166 | + (define %user (getpw "gnunet")) | ||
167 | + (mkdir-p "/var/lib/gnunet/") | ||
168 | + (chown "/var/lib/gnunet" (passwd:uid %user) (passwd:gid %user)) | ||
169 | + (chmod "/var/lib/gnunet/" #o600) | ||
170 | + (mkdir-p "/var/lib/gnunet/.local/share/gnunet") | ||
171 | + (mkdir-p "/var/lib/gnunet/.cache/gnunet") | ||
172 | + (mkdir-p "/var/lib/gnunet/.config/gnunet") | ||
173 | + (chmod "/var/lib/gnunet/.config/gnunet" #o600) | ||
174 | + (chmod "/var/lib/gnunet/.cache/gnunet" #o600) | ||
175 | + (chmod "/var/lib/gnunet/.local/share/gnunet" #o600)))))) | ||
176 | + | ||
177 | +(define gnunet-setuid-programs | ||
178 | + (match-lambda | ||
179 | + (($ <gnunet-configuration> package) | ||
180 | + (list (file-append package "/lib/gnunet/libexec/gnunet-helper-exit") | ||
181 | + (file-append package "/lib/gnunet/libexec/gnunet-helper-nat-server") | ||
182 | + (file-append package "/lib/gnunet/libexec/gnunet-helper-nat-client") | ||
183 | + (file-append package "/lib/gnunet/libexec/gnunet-helper-transport-bluetooth") | ||
184 | + (file-append package "/lib/gnunet/libexec/gnunet-helper-transport-wlan") | ||
185 | + (file-append package "/lib/gnunet/libexec/gnunet-helper-vpn"))))) | ||
186 | + | ||
187 | +(define gnunet-service-type | ||
188 | + (service-type | ||
189 | + (name 'gnunet) | ||
190 | + (extensions (list (service-extension account-service-type | ||
191 | + (const %gnunet-accounts)) | ||
192 | + (service-extension activation-service-type | ||
193 | + gnunet-activation) | ||
194 | + (service-extension profile-service-type | ||
195 | + (compose list gnunet-configuration-package)) | ||
196 | + (service-extension setuid-program-service-type | ||
197 | + gnunet-setuid-programs) | ||
198 | + (service-extension shepherd-root-service-type | ||
199 | + gnunet-shepherd-service))))) | ||
200 | + | ||
201 | ;;; networking.scm ends here | ||
202 | -- | ||
203 | 2.11.0 | ||
204 | |||