aboutsummaryrefslogtreecommitdiff
path: root/contrib/services/shepherd/ng0_wip/0001-gnu-services-Add-gnunet-service.patch
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/services/shepherd/ng0_wip/0001-gnu-services-Add-gnunet-service.patch')
-rw-r--r--contrib/services/shepherd/ng0_wip/0001-gnu-services-Add-gnunet-service.patch225
1 files changed, 0 insertions, 225 deletions
diff --git a/contrib/services/shepherd/ng0_wip/0001-gnu-services-Add-gnunet-service.patch b/contrib/services/shepherd/ng0_wip/0001-gnu-services-Add-gnunet-service.patch
deleted file mode 100644
index a494434e0..000000000
--- a/contrib/services/shepherd/ng0_wip/0001-gnu-services-Add-gnunet-service.patch
+++ /dev/null
@@ -1,225 +0,0 @@
1From 434b05bc1a11b4865c0bd634281acd91dfce972c Mon Sep 17 00:00:00 2001
2From: ng0 <ng0@we.make.ritual.n0.is>
3Date: Mon, 12 Sep 2016 12:26:52 +0000
4Subject: [PATCH] gnu: services: Add gnunet-service.
5
6Signed-off-by: Nils Gillmann <ng0@n0.is>
7---
8 doc/guix.texi | 36 ++++++++++
9 gnu/services/networking.scm | 134 +++++++++++++++++++++++++++++++++++-
10 2 files changed, 169 insertions(+), 1 deletion(-)
11
12diff --git a/doc/guix.texi b/doc/guix.texi
13index 00bf24d3f..73589c88b 100644
14--- a/doc/guix.texi
15+++ b/doc/guix.texi
16@@ -10138,6 +10138,42 @@ Package object of the Open vSwitch.
17 @end table
18 @end deftp
19
20+@cindex GNUnet
21+@cindex gnunet
22+@subsubheading GNUnet Service
23+
24+@deffn {Scheme Variable} gnunet-service-type
25+This is the type of the @uref{https://gnunet.org, GNUnet}
26+service, whose value should be an @code{gnunet-configuration} object
27+as in this example:
28+
29+@example
30+(service gnunet-service-type
31+ (gnunet-configuration
32+ (config-file (local-file "./gnunet.conf"))))
33+@end example
34+@end deffn
35+
36+@deftp {Data Type} gnunet-configuration
37+Data type representing the configuration of GNUnet.
38+
39+@table @asis
40+@item @code{package} (default: @var{gnunet})
41+Package object of the GNUnet service.
42+
43+@item @code{config-file} (default: @var{%default-gnunet-file})
44+File-like object of the GNUnet configuration file to use. For NAT is
45+assumes by default that you are behind a NAT (@var{BEHIND_NAT = YES})
46+and enables UPNP (@var{ENABLE_UPNP = YES}).
47+The hostlist is configured with the options @var{-b} (bootstrap using
48+configured hostlist servers) and @var{-e} (enable learning advertised hostlists).
49+Read the configuration files in @var{"~/.guix-profile/share/gnunet/config.d/"}
50+for more information. These files also set the defaults when you don't set
51+any explicit values to override them.
52+
53+@end table
54+@end deftp
55+
56 @node X Window
57 @subsubsection X Window
58
59diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
60index 99a3d493c..fe682b267 100644
61--- a/gnu/services/networking.scm
62+++ b/gnu/services/networking.scm
63@@ -5,6 +5,7 @@
64 ;;; Copyright © 2016 John Darrington <jmd@gnu.org>
65 ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
66 ;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
67+;;; Copyright © 2017 ng0 <ng0@no-reply.pragmatique.xyt>
68 ;;;
69 ;;; This file is part of GNU Guix.
70 ;;;
71@@ -29,6 +30,7 @@
72 #:use-module (gnu system pam)
73 #:use-module (gnu packages admin)
74 #:use-module (gnu packages connman)
75+ #:use-module (gnu packages gnunet)
76 #:use-module (gnu packages linux)
77 #:use-module (gnu packages tor)
78 #:use-module (gnu packages messaging)
79@@ -92,7 +94,12 @@
80 wpa-supplicant-service-type
81
82 openvswitch-service-type
83- openvswitch-configuration))
84+ openvswitch-configuration
85+
86+ gnunet-configuration
87+ gnunet-configuration?
88+ gnunet-service-type
89+ %default-gnunet-config-file))
90
91 ;;; Commentary:
92 ;;;
93@@ -1069,4 +1076,129 @@ dns=" dns "
94 (service-extension shepherd-root-service-type
95 openvswitch-shepherd-service)))))
96
97+;;;
98+;;; GNUnet
99+;;;
100+
101+;; steps:
102+;; 0. The service works!!!
103+;; 1. We want a completely adjustable config.
104+;; 2. We want to extend this service with functions like
105+;; vpn, comparable to tor-service
106+;; Because of (1) we can't have a default. We can have
107+;; default values which can be adjusted. A config is
108+;; generated from these.
109+
110+(define-record-type* <gnunet-configuration>
111+ gnunet-configuration make-gnunet-configuration
112+ gnunet-configuration?
113+ (gnunet gnunet-configuration-package
114+ (default gnunet))
115+ (config-file gnunet-configuration-config-file
116+ (default (plain-file "empty" ""))))
117+
118+(define %default-gnunet-config-file
119+ (plain-file "gnunet.conf" "
120+[PATHS]
121+SERVICEHOME = /var/lib/gnunet
122+GNUNET_CONFIG_HOME = /var/lib/gnunet
123+
124+[arm]
125+SYSTEM_ONLY = NO
126+USER_ONLY = NO
127+
128+[nat]
129+BEHIND_NAT = YES
130+ENABLE_UPNP = YES
131+
132+[hostlist]
133+OPTIONS = -b -e
134+"))
135+
136+(define gnunet-shepherd-service
137+ (match-lambda
138+ (($ <gnunet-configuration> package config-file)
139+ (list (shepherd-service
140+ (provision '(gnunet))
141+ (requirement '(user-processes loopback networking))
142+ (documentation "Run the GNUnet service.")
143+ (start
144+ (let ((gnunet
145+ (file-append package "/lib/gnunet/libexec/gnunet-service-arm")))
146+ #~(make-forkexec-constructor
147+ (list #$gnunet "-c" #$config-file "-d")
148+ #:pid-file "/var/run/gnunet/arm-service.pid"
149+ #:user "gnunet"
150+ #:group "gnunet"
151+ ;;#:log-file "/var/lib/gnunet/gnunet.log")))
152+ #:log-file "/var/log/gnunet.log")))
153+ (stop #~(make-kill-destructor)))))))
154+
155+(define %gnunet-accounts
156+ (list (user-group (name "gnunetdns") (system? #t))
157+ (user-group (name "gnunet") (system? #t))
158+ (user-account
159+ (name "gnunet")
160+ (group "gnunet")
161+ (system? #t)
162+ (comment "GNUnet system user")
163+ (home-directory "/var/empty")
164+ (shell (file-append shadow "/sbin/nologin")))))
165+
166+;; ${GNUNET_HOME}/.local/share/gnunet/gnunet.conf -> chmod 600
167+;; mkdir -p ${GNUNET_HOME}/.cache/gnunet
168+
169+(define gnunet-activation
170+ (match-lambda
171+ (($ <gnunet-configuration> package config-file)
172+ (let ((gnunet
173+ (file-append package "/lib/gnunet/libexec/gnunet-service-arm")))
174+ #~(begin
175+ (use-modules (guix build utils))
176+ (define %user (getpw "gnunet"))
177+ (mkdir-p "/var/lib/gnunet/")
178+ (chown "/var/lib/gnunet" (passwd:uid %user) (passwd:gid %user))
179+ ;;(chmod "/var/lib/gnunet/" #o755)
180+ (mkdir-p "/var/lib/gnunet/.local/share/gnunet")
181+ (mkdir-p "/var/lib/gnunet/.cache/gnunet")
182+ (mkdir-p "/var/lib/gnunet/hostlist")
183+ (mkdir-p "/var/lib/gnunet/.config/gnunet")
184+ (chown "/var/lib/gnunet/.local/share/gnunet" (passwd:uid %user) (passwd:gid %user))
185+ (chown "/var/lib/gnunet/.cache/gnunet" (passwd:uid %user) (passwd:gid %user))
186+ (chown "/var/lib/gnunet/hostlist" (passwd:uid %user) (passwd:gid %user))
187+ ;;(chown "/var/lib/gnunet/gnunet.conf" (passwd:uid %user) (passwd:gid %user))
188+ (chown "/var/lib/gnunet/.config/gnunet" (passwd:uid %user) (passwd:gid %user)))))))
189+ ;;(chmod "/var/lib/gnunet/.config/gnunet" #o755)
190+ ;;(chmod "/var/lib/gnunet/.cache/gnunet" #o755)
191+ ;;(chmod "/var/lib/gnunet/.local/share/gnunet" #o755))))))
192+
193+;; SUID_ROOT_HELPERS="exit nat-server nat-client transport-bluetooth transport-wlan vpn"
194+;; set chmod u+s for those above.
195+;; chmodown_execbin ${libexec}/gnunet-helper-dns 4750 root:gnunetdns
196+;; chmodown_execbin ${libexec}/gnunet-service-dns 2750 gnunet:gnunetdns
197+(define gnunet-setuid-programs
198+ (match-lambda
199+ (($ <gnunet-configuration> package)
200+ (list (file-append package "/lib/gnunet/libexec/gnunet-helper-exit")
201+ (file-append package "/lib/gnunet/libexec/gnunet-helper-nat-server")
202+ (file-append package "/lib/gnunet/libexec/gnunet-helper-nat-client")
203+ (file-append package "/lib/gnunet/libexec/gnunet-helper-transport-bluetooth")
204+ (file-append package "/lib/gnunet/libexec/gnunet-helper-transport-wlan")
205+ (file-append package "/lib/gnunet/libexec/gnunet-helper-vpn")))))
206+
207+(define gnunet-service-type
208+ (service-type
209+ (name 'gnunet)
210+ (extensions (list (service-extension account-service-type
211+ (const %gnunet-accounts))
212+ (service-extension activation-service-type
213+ gnunet-activation)
214+ (service-extension profile-service-type
215+ (compose list gnunet-configuration-package))
216+ (service-extension setuid-program-service-type
217+ gnunet-setuid-programs)
218+ (service-extension shepherd-root-service-type
219+ gnunet-shepherd-service)))))
220+;;; --- here starts the rewrite.
221+
222 ;;; networking.scm ends here
223--
2242.17.0
225