WIP:afs-service-commit wip-kafs
authorJack Hill <jackhill@jackhill.us>
Mon, 17 Aug 2020 04:34:50 +0000 (00:34 -0400)
committerJack Hill <jackhill@jackhill.us>
Fri, 18 Sep 2020 15:02:42 +0000 (11:02 -0400)
gnu/local.mk
gnu/services/afs.scm [new file with mode: 0644]

index 04ec259..e5794ca 100644 (file)
@@ -579,6 +579,7 @@ GNU_SYSTEM_MODULES =                                \
                                                \
   %D%/services.scm                             \
   %D%/services/admin.scm                       \
+  %D%/services/afs.scm                         \
   %D%/services/audio.scm                        \
   %D%/services/auditd.scm                      \
   %D%/services/avahi.scm                       \
diff --git a/gnu/services/afs.scm b/gnu/services/afs.scm
new file mode 100644 (file)
index 0000000..846de5a
--- /dev/null
@@ -0,0 +1,58 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix 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.
+;;;
+;;; GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services afs)
+  #:use-module (gnu services)
+  #:use-module (gnu services linux)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu packages afs)
+  #:use-module (guix build syscalls)
+  #:use-module (guix records)
+  #:export (afs-client-configuration
+            afs-client-configuration?
+            afs-client-configuration-kafs-client
+            afs-client-service-type))
+
+(define-record-type* <afs-client-configuration>
+  afs-client-configuration make-afs-client-configuration
+  afs-client-configuration?
+  (kafs-client afs-client-configuration-kafs-client
+               (default kafs-client)))
+
+(define (afs-client-shepherd-service config)
+  (shepherd-service
+   (documentation "Mount the /afs file system.")
+   (provision '(afs-client))
+   (start #~(lambda _
+              (system #$(file-append
+                         (afs-client-configuration-kafs-client config)
+                         "/libexec/kafs-preload"))
+              (mkdir "/afs")
+              (mount "afs" "/afs" "afs" 0 "dyn" #:update-mtab? #t)))
+   (stop #~(lambda _
+             (umount "/afs" #:update-mtab #t)))))
+
+(define afs-client-service-type
+  (service-type
+   (name 'afs-client)
+   (default-value (afs-client-configuration))
+   (extensions
+    (list (service-extension kernel-module-loader-service-type
+                             (const (list "kafs")))
+          (service-extension shepherd-root-service-type
+                             (compose list afs-client-shepherd-service))))))