WIP:afs-service-commit
[jackhill/guix/guix.git] / gnu / services / afs.scm
CommitLineData
bfd1d478
JH
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
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 afs)
20 #:use-module (gnu services)
21 #:use-module (gnu services linux)
22 #:use-module (gnu services shepherd)
23 #:use-module (gnu packages afs)
24 #:use-module (guix build syscalls)
25 #:use-module (guix records)
26 #:export (afs-client-configuration
27 afs-client-configuration?
28 afs-client-configuration-kafs-client
29 afs-client-service-type))
30
31(define-record-type* <afs-client-configuration>
32 afs-client-configuration make-afs-client-configuration
33 afs-client-configuration?
34 (kafs-client afs-client-configuration-kafs-client
35 (default kafs-client)))
36
37(define (afs-client-shepherd-service config)
38 (shepherd-service
39 (documentation "Mount the /afs file system.")
40 (provision '(afs-client))
41 (start #~(lambda _
42 (system #$(file-append
43 (afs-client-configuration-kafs-client config)
44 "/libexec/kafs-preload"))
45 (mkdir "/afs")
46 (mount "afs" "/afs" "afs" 0 "dyn" #:update-mtab? #t)))
47 (stop #~(lambda _
48 (umount "/afs" #:update-mtab #t)))))
49
50(define afs-client-service-type
51 (service-type
52 (name 'afs-client)
53 (default-value (afs-client-configuration))
54 (extensions
55 (list (service-extension kernel-module-loader-service-type
56 (const (list "kafs")))
57 (service-extension shepherd-root-service-type
58 (compose list afs-client-shepherd-service))))))