;; List of "historical" committers---people once authorized committers before ;; the '.guix-authorizations' file was created. ;; ;; This file is provided for historical and auditing purposes. It is known ;; good starting at least at 'v1.0.0'. ;; ;; The format is the same as for '.guix-authorizations'. User names are those ;; found on along ;; with the fingerprint of the signing (sub)key. (authorizations (version 0) (("AD17 A21E F8AE D8F1 CC02 DBD9 F7D5 C9BF 765C 61E3" (name "andreas")) ("2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5" (name "ajgrf")) ("306F CB8F 2C01 C25D 29D3 0556 61EF 502E F602 52F2" (name "alexvong1995")) ("4FB9 9F49 2B12 A365 7997 E664 8246 0C08 2A0E E98F" (name "alezost")) ("50F3 3E2E 5B0C 3D90 0424 ABE8 9BDC F497 A4BB CC7F" (name "ambrevar")) ("27D5 86A4 F890 0854 329F F09F 1260 E464 82E6 3562" (name "apteryx")) ("7F73 0343 F2F0 9F3C 77BF 79D3 2E25 EE8B 6180 2BB3" (name "arunisaac")) (;; primary: "3B12 9196 AE30 0C3C 0E90 A26F A715 5567 3271 9948" "9A2B 401E D001 0650 1584 BAAC 8BC4 F447 6E8A 8E00" (name "atheia")) (;; primary: "BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103" "39B3 3C8D 9448 0D2D DCC2 A498 8B44 A0CD C7B9 56F2" (name "bandali")) (;; primary: "34FF 38BC D151 25A6 E340 A0B5 3453 2F9F AFCA 8B8E" "A0C5 E352 2EF8 EF5C 64CD B7F0 FD73 CAC7 19D3 2566" (name "bavier")) ("3774 8024 880F D3FF DCA2 C9AB 5893 6E0E 2F1B 5A4C" (name "beffa")) ("BCF8 F737 2CED 080A 67EB 592D 2A6A D9F4 AAC2 0DF6" (name "benwoodcroft")) ("45CC 63B8 5258 C9D5 5F34 B239 D37D 0EA7 CECC 3912" (name "biscuolo")) ("7988 3B9F 7D6A 4DBF 3719 0367 2506 A96C CF63 0B21" (name "boskovits")) ("DFC0 C7F7 9EE6 0CA7 AE55 5E19 6722 43C4 A03F 0EEE" (name "brettgilio")) (;; primary: "0401 7A2A 6D9A 0CCD C81D 8EC2 96AB 007F 1A7E D999" "09CD D25B 52
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 John Darrington <jmd@gnu.org>
;;; Copyright © 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; 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 nfs)
  #:use-module (gnu)
  #:use-module (gnu services shepherd)
  #:use-module (gnu packages onc-rpc)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages nfs)
  #:use-module (guix)
  #:use-module (guix records)
  #:use-module (srfi srfi-1)
  #:use-module (ice-9 match)
  #:use-module (gnu build file-systems)
  #:export (rpcbind-service-type
            rpcbind-configuration
            rpcbind-configuration?

            pipefs-service-type
            pipefs-configuration
            pipefs-configuration?

            idmap-service-type
            idmap-configuration
            idmap-configuration?

            gss-service-type
            gss-configuration
            gss-configuration?

            nfs-service-type
            nfs-configuration
            nfs-configuration?))


(define default-pipefs-directory "/var/lib/nfs/rpc_pipefs")



(define-record-type* <rpcbind-configuration>
  rpcbind-configuration make-rpcbind-configuration
  rpcbind-configuration?
  (rpcbind             rpcbind-configuration-rpcbind
                       (default rpcbind))
  (warm-start?         rpcbind-configuration-warm-start?
                       (default #t)))

(define rpcbind-service-type
  (let ((proc
         (lambda (config)
           (define rpcbind
             (rpcbind-configuration-rpcbind config))

           (define rpcbind-command
             #~(list (string-append #$rpcbind "/sbin/rpcbind") "-f"
                     #$@(if (rpcbind-configuration-warm-start? config) '("-w") '())))

           (shepherd-service
            (documentation "Start the RPC bind daemon.")
            (requirement '(networking))
            (provision '(rpcbind-daemon))

            (start #~(make-forkexec-constructor #$rpcbind-command))
            (stop #~(make-kill-destructor))))))
    (service-type
     (name 'rpcbind)
     (extensions
      (list (service-extension shepherd-root-service-type
                               (compose list proc))))
     ;; We use the extensions feature to allow other services to automatically
     ;; configure and start this service.  Only one value can be provided.  We
     ;; override it with the value returned by the extending service.
     (compose identity)
     (extend (lambda (config values)
               (match values
                 ((first . rest) first)
                 (_ config))))
     (default-value (rpcbind-configuration))
     (description "Run the RPC Bind service, which provides a facility to map
ONC RPC program numbers into universal addresses.  Many NFS related services
use this facility."))))



(define-record-type* <pipefs-configuration>
  pipefs-configuration make-pipefs-configuration
  pipefs-configuration?
  (mount-point           pipefs-configuration-mount-point
                         (default default-pipefs-directory)))

(define pipefs-service-type
  (let ((proc
         (lambda (config)
           (define pipefs-directory (pipefs-configuration-mount-point config))

           (shepherd-service
            (documentation "Mount the pipefs pseudo file system.")
            (provision '(rpc-pipefs))

            (start #~(lambda ()
                       (mkdir-p #$pipefs-directory)
                       (mount "rpc_pipefs" #$pipefs-directory "rpc_pipefs")
                       (member #$pipefs-directory (mount-points))))

            (stop #~(lambda (pid . args)
                      (umount #$pipefs-directory MNT_DETACH)
                      (not (member #$pipefs-directory (mount-points)))))))))
    (service-type
     (name 'pipefs)
     (extensions
      (list (service-extension shepherd-root-service-type
                               (compose list proc))))
     ;; We use the extensions feature to allow other services to automatically
     ;; configure and start this service.  Only one value can be provided.  We
     ;; override it with the value returned by the extending service.
     (compose identity)
     (extend (lambda (config values)
               (match values
                 ((first . rest) first)
                 (_ config))))
     (default-value (pipefs-configuration))
     (description "Mount the pipefs file system, which is used to transfer
NFS-related data between the kernel and user-space programs."))))



(define-record-type* <gss-configuration>
  gss-configuration make-gss-configuration
  gss-configuration