gnu: Add texlive-latex-base.
[jackhill/guix/guix.git] / gnu / services / nfs.scm
CommitLineData
d6a07ee6
JD
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 John Darrington <jmd@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu services nfs)
20 #:use-module (gnu)
21 #:use-module (gnu services shepherd)
22 #:use-module (gnu packages onc-rpc)
eb419bc9 23 #:use-module (gnu packages linux)
d6a07ee6
JD
24 #:use-module (guix)
25 #:use-module (guix records)
eb419bc9
JD
26 #:use-module (ice-9 match)
27 #:use-module (gnu build file-systems)
d6a07ee6
JD
28 #:export (rpcbind-service-type
29 rpcbind-configuration
eb419bc9
JD
30 rpcbind-configuration?
31
32 pipefs-service-type
33 pipefs-configuration
34 pipefs-configuration?
35
36 idmap-service-type
37 idmap-configuration
38 idmap-configuration?
39
40 gss-service-type
41 gss-configuration
42 gss-configuration?))
43
44
45(define default-pipefs-directory "/var/lib/nfs/rpc_pipefs")
46
47\f
d6a07ee6
JD
48
49(define-record-type* <rpcbind-configuration>
50 rpcbind-configuration make-rpcbind-configuration
51 rpcbind-configuration?
52 (rpcbind rpcbind-configuration-rpcbind
53 (default rpcbind))
54 (warm-start? rpcbind-configuration-warm-start?
55 (default #t)))
56
57(define rpcbind-service-type
58 (shepherd-service-type
59 'rpcbind
60 (lambda (config)
43f7af42 61 (define nfs-utils
d6a07ee6
JD
62 (rpcbind-configuration-rpcbind config))
63
64 (define rpcbind-command
43f7af42 65 #~(list (string-append #$nfs-utils "/bin/rpcbind") "-f"
d6a07ee6
JD
66 #$@(if (rpcbind-configuration-warm-start? config) '("-w") '())))
67
68 (shepherd-service
69 (documentation "Start the RPC bind daemon.")
70 (requirement '(networking))
71 (provision '(rpcbind-daemon))
72
73 (start #~(make-forkexec-constructor #$rpcbind-command))
74 (stop #~(make-kill-destructor))))))
eb419bc9
JD
75
76\f
77
78(define-record-type* <pipefs-configuration>
79 pipefs-configuration make-pipefs-configuration
80 pipefs-configuration?
81 (mount-point pipefs-configuration-mount-point
82 (default default-pipefs-directory)))
83
84(define pipefs-service-type
85 (shepherd-service-type
86 'pipefs
87 (lambda (config)
88 (define pipefs-directory (pipefs-configuration-mount-point config))
89
90 (shepherd-service
91 (documentation "Mount the pipefs pseudo filesystem.")
92 (provision '(rpc-pipefs))
93
94 (start #~(lambda ()
95 (mkdir-p #$pipefs-directory)
96 (mount "rpc_pipefs" #$pipefs-directory "rpc_pipefs")
97 (member #$pipefs-directory (mount-points))))
98
99 (stop #~(lambda (pid . args)
100 (umount #$pipefs-directory MNT_DETACH)
101 (not (member #$pipefs-directory (mount-points)))))))))
102
103\f
104
105(define-record-type* <gss-configuration>
106 gss-configuration make-gss-configuration
107 gss-configuration?
108 (pipefs-directory gss-configuration-pipefs-directory
109 (default default-pipefs-directory))
110 (nfs-utils gss-configuration-gss
111 (default nfs-utils)))
112
113(define gss-service-type
114 (shepherd-service-type
115 'gss
116 (lambda (config)
117 (define nfs-utils
118 (gss-configuration-gss config))
119
120 (define pipefs-directory
121 (gss-configuration-pipefs-directory config))
122
123 (define gss-command
124 #~(list (string-append #$nfs-utils "/sbin/rpc.gssd") "-f"
125 "-p" #$pipefs-directory))
126
127 (shepherd-service
128 (documentation "Start the RPC GSS daemon.")
129 (requirement '(rpcbind-daemon rpc-pipefs))
130 (provision '(gss-daemon))
131
132 (start #~(make-forkexec-constructor #$gss-command))
133 (stop #~(make-kill-destructor))))))
134
135\f
136
137(define-record-type* <idmap-configuration>
138 idmap-configuration make-idmap-configuration
139 idmap-configuration?
140 (pipefs-directory idmap-configuration-pipefs-directory
141 (default default-pipefs-directory))
142 (domain idmap-configuration-domain
143 (default #f))
144 (nfs-utils idmap-configuration-idmap
145 (default nfs-utils)))
146
147(define idmap-service-type
148 (shepherd-service-type
149 'idmap
150 (lambda (config)
151
152 (define nfs-utils
153 (idmap-configuration-idmap config))
154
155 (define pipefs-directory
156 (idmap-configuration-pipefs-directory config))
157
158 (define domain (idmap-configuration-domain config))
159
160 (define (idmap-config-file config)
161 (plain-file "idmapd.conf"
162 (string-append
163 "\n[General]\n"
164 (if domain
165 (format #f "Domain = ~a\n" domain))
166 "\n[Mapping]\n"
167 "Nobody-User = nobody\n"
168 "Nobody-Group = nogroup\n")))
169
170 (define idmap-command
171 #~(list (string-append #$nfs-utils "/sbin/rpc.idmapd") "-f"
172 "-p" #$pipefs-directory
173 "-c" #$(idmap-config-file config)))
174
175 (shepherd-service
176 (documentation "Start the RPC IDMAP daemon.")
177 (requirement '(rpcbind-daemon rpc-pipefs))
178 (provision '(idmap-daemon))
179 (start #~(make-forkexec-constructor #$idmap-command))
180 (stop #~(make-kill-destructor))))))
181