1 From 434b05bc1a11b4865c0bd634281acd91dfce972c 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.
6 Signed-off-by: Nils Gillmann <ng0@n0.is>
8 doc/guix.texi | 36 ++++++++++
9 gnu/services/networking.scm | 134 +++++++++++++++++++++++++++++++++++-
10 2 files changed, 169 insertions(+), 1 deletion(-)
12 diff --git a/doc/guix.texi b/doc/guix.texi
13 index 00bf24d3f..73589c88b 100644
16 @@ -10138,6 +10138,42 @@ Package object of the Open vSwitch.
22 +@subsubheading GNUnet Service
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
30 +(service gnunet-service-type
31 + (gnunet-configuration
32 + (config-file (local-file "./gnunet.conf"))))
36 +@deftp {Data Type} gnunet-configuration
37 +Data type representing the configuration of GNUnet.
40 +@item @code{package} (default: @var{gnunet})
41 +Package object of the GNUnet service.
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.
57 @subsubsection X Window
59 diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
60 index 99a3d493c..fe682b267 100644
61 --- a/gnu/services/networking.scm
62 +++ b/gnu/services/networking.scm
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>
69 ;;; This file is part of GNU Guix.
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)
80 wpa-supplicant-service-type
82 openvswitch-service-type
83 - openvswitch-configuration))
84 + openvswitch-configuration
86 + gnunet-configuration
87 + gnunet-configuration?
89 + %default-gnunet-config-file))
93 @@ -1069,4 +1076,129 @@ dns=" dns "
94 (service-extension shepherd-root-service-type
95 openvswitch-shepherd-service)))))
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.
110 +(define-record-type* <gnunet-configuration>
111 + gnunet-configuration make-gnunet-configuration
112 + gnunet-configuration?
113 + (gnunet gnunet-configuration-package
115 + (config-file gnunet-configuration-config-file
116 + (default (plain-file "empty" ""))))
118 +(define %default-gnunet-config-file
119 + (plain-file "gnunet.conf" "
121 +SERVICEHOME = /var/lib/gnunet
122 +GNUNET_CONFIG_HOME = /var/lib/gnunet
136 +(define gnunet-shepherd-service
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.")
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"
151 + ;;#:log-file "/var/lib/gnunet/gnunet.log")))
152 + #:log-file "/var/log/gnunet.log")))
153 + (stop #~(make-kill-destructor)))))))
155 +(define %gnunet-accounts
156 + (list (user-group (name "gnunetdns") (system? #t))
157 + (user-group (name "gnunet") (system? #t))
162 + (comment "GNUnet system user")
163 + (home-directory "/var/empty")
164 + (shell (file-append shadow "/sbin/nologin")))))
166 +;; ${GNUNET_HOME}/.local/share/gnunet/gnunet.conf -> chmod 600
167 +;; mkdir -p ${GNUNET_HOME}/.cache/gnunet
169 +(define gnunet-activation
171 + (($ <gnunet-configuration> package config-file)
173 + (file-append package "/lib/gnunet/libexec/gnunet-service-arm")))
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))))))
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
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")))))
207 +(define gnunet-service-type
210 + (extensions (list (service-extension account-service-type
211 + (const %gnunet-accounts))
212 + (service-extension activation-service-type
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.
222 ;;; networking.scm ends here