+;;; 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))))))