blob: 41bf1972f152c99c8c850f3b9f14be97357084d3 (
about) (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
;;; Whispers --- Stealth VPN and ssh tunneler
;;; Copyright © 2024 Runciter <runciter@whispers-vpn.org>
;;;
;;; This file is part of Whispers.
;;;
;;; Whispers is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; Whispers is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with Whispers. If not, see <http://www.gnu.org/licenses/>.
(define-module (whispers services proton)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (gnu services admin)
#:use-module (gnu packages mail)
#:export (hydroxide-configuration
hydroxide-service-type
hydroxide-configuration?
hydroxide-service-type))
(define-record-type* <hydroxide-configuration>
hydroxide-configuration make-hydroxide-configuration
hydroxide-configuration?
this-hydroxide-configuration
;; A file-like object
(hydroxide-package hydroxide-configuration-hydroxide-package
(default hydroxide))
;; A string
(user hydroxide-configuration-user
(default "johndoe"))
;; A boolean value
(https-proxy? hydroxide-configuration-https-proxy?
(default #f))
;; A string
(https-proxy hydroxide-configuration-https-proxy
(default "socks5://localhost:8971"))
;; A boolean value
(imap? hydroxide-configuration-imap?
(default #t))
;; A boolean value
(smtp? hydroxide-configuration-smtp?
(default #t))
;; A boolean value
(carddav? hydroxide-configuration-carddav?
(default #t))
;; A boolean value
(%auto-start? hydroxide-configuration-auto-start?
(default #t)))
(define (hydroxide-constructor-gexp config)
"Returns a G-exp to a procedure starting an hydroxide server
configurable by CONFIG, a record of the <hydroxide-configuration> type."
(let ((hydroxide-package (hydroxide-configuration-hydroxide-package
config))
(user (hydroxide-configuration-user config))
(https-proxy? (hydroxide-configuration-https-proxy? config))
(https-proxy (hydroxide-configuration-https-proxy config))
(imap? (hydroxide-configuration-imap? config))
(carddav? (hydroxide-configuration-carddav? config))
(smtp? (hydroxide-configuration-smtp? config)))
#~(make-forkexec-constructor
(append (list #$(file-append hydroxide-package
"/bin/hydroxide"))
(if #$imap?
(list)
(list "--disable-imap"))
(if #$carddav?
(list)
(list "--disable-carddav"))
(if #$smtp?
(list)
(list "--disable-smtp"))
(list "serve"))
#:environment-variables
(append (list (string-append "XDG_CONFIG_HOME="
(passwd:dir (getpwnam #$user))
"/.config"))
#$(if https-proxy?
#~(list (string-append "https_proxy="
#$https-proxy))
#~(list))))))
(define (hydroxide-shepherd-services config)
"Returns a list of shepherd services handling an hydroxide server
configured by CONFIG, a record of the <hydroxide-configuration> type."
(let ((auto-start? (hydroxide-configuration-auto-start? config)))
(list
(shepherd-service
(documentation "Hydroxide service")
(provision '(hydroxide))
(requirement '())
(start (hydroxide-constructor-gexp config))
(stop #~(make-kill-destructor))
(auto-start? auto-start?)))))
(define hydroxide-service-type
(service-type
(name 'hydroxide)
(description "Hydroxide node service")
(extensions
(list (service-extension shepherd-root-service-type
hydroxide-shepherd-services)
(service-extension
profile-service-type
(lambda (config)
(list (hydroxide-configuration-hydroxide-package config))))))
(default-value (hydroxide-configuration))))
|