Compare commits

...

2 Commits

Author SHA1 Message Date
Collin J. Doering e917139f34
rekahsoft-gnu: Add cephfs configuration and service
* rekahsoft-gnu/services/ceph.scm: New file; provide a mechanism to mount cephfs
file-systems on guix
2023-03-26 21:01:35 -04:00
Collin J. Doering da0b888bbf
README.org: Added README 2023-03-26 21:00:50 -04:00
2 changed files with 133 additions and 0 deletions

28
README.org Normal file
View File

@ -0,0 +1,28 @@
#+TITLE: rekahsoft-guix
#+AUTHOR: Collin J. Doering
#+begin_export html
<p><a href="https://guix-ci.home.rekahsoft.ca/jobset/rekahsoft-guix"><img src="https://guix-ci.home.rekahsoft.ca/jobset/rekahsoft-guix/badge.svg?type=0" alt="Cuirass Status"></a></p>
#+end_export
#+begin_abstract
This channel ([[https://git.rekahsoft.ca/rekahsoft/rekahsoft-guix.git][rekahsoft-guix]]), is a personal channel that is meant as a
staging ground for changes I plan on making upstream to guix. However, there
may be packages that may never be contributed due to technical or ideological
reasons; in the later case, packages will be submitted upstream to the [[https://gitlab.com/nonguix/nonguix][nonguix]]
channel.
#+end_abstract
To use this channel, add the rekahsoft-guix channel to your channels file and
update using ~guix pull~.
#+begin_src scheme
(channel
(name 'rekahsoft-guix)
(url "https://git.rekahsoft.ca/rekahsoft/rekahsoft-guix")
(introduction
(make-channel-introduction
"34b5f938ad7404d980b20f0c896913c5ee597b2a"
(openpgp-fingerprint
"F8D5 46F3 AF37 EF53 D1B6 48BE 7B4D EB93 212B 3022"))))
#+end_src

View File

@ -0,0 +1,105 @@
;;; Copyright © 2023 Collin J. Doering <collin@rekahsoft.ca>
;;;
;;; This file is part of the GNU Guix channel rekahsoft-guix
;;;
;;; The rekahsoft-guix channel for 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.
;;;
;;; The rekahsoft-guix channel for 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 the rekahsoft-guix channel for GNU Guix. If not, see
;;; <http://www.gnu.org/licenses/>.
(define-module (rekahsoft-gnu services ceph)
#:use-module (gnu services configuration)
#:use-module (gnu packages storage)
#:use-module (guix packages)
#:use-module (ice-9 match)
#:use-module (gnu services shepherd)
#:use-module (gnu)
#:export (cephfs-configuration cephfs-configuration? cephfs-service-type))
(define-configuration/no-serialization cephfs-configuration
(package
(package ceph)
"The ceph package to use.")
(mount-point
(string)
"Mount point used for cephfs filesystem.")
(name
(string)
"The Rados client (user) name.")
(fsid
(string)
"The CephFS file-system id.")
(fs-name
(string)
"A symbolic name to use for the CephFS mount.")
(options
(string "rw,relatime,acl")
"File-system mount options. Defaults to 'rw,relatime,acl'")
(secret-file
(string)
"Secret file path to use for authentication.")
(monitors
(list-of-strings)
"A list of monitor addresses in the form of <host>:<port>.")
(subdir
(string "/")
"An optional subdirectory to mount (defaults to '/').")
(legacy-mount-syntax?
(boolean #f)
"Use the legacy mount.ceph syntax; see ceph.mount documentation for more details."))
(define cephfs-shepherd-service
(match-lambda
(($ <cephfs-configuration> package mount-point name fsid fs-name options secret-file monitors subdir legacy-mount-syntax?)
(list (shepherd-service
(provision (list (string->symbol (string-append "cephfs-" mount-point))))
(documentation (string-append "Mount cephfs filesystem '" fsid "' (" mount-point ")."))
(requirement `(networking ,(string->symbol (string-append "file-system-" mount-point))))
(start #~(make-system-constructor "/run/setuid-programs/mount /mnt/cephfs"))
(stop #~(make-system-constructor "/run/setuid-programs/umount /mnt/cephfs"))
(respawn? #f))))))
;; Mount syntax changed between ceph 16 and 17, however the old syntax is still supported
;;
;; 16.x Pacific - https://docs.ceph.com/en/pacific/man/8/mount.ceph/
;; mount.ceph [mon1_socket,mon2_socket,…]:/[subdir] dir [-o options]
;; 17.x Quincy - https://docs.ceph.com/en/quincy/man/8/mount.ceph/
;; mount.ceph name*@*fsid.*fs_name*=/[subdir] dir [-o options]
(define cephfs-file-systems
(match-lambda
(($ <cephfs-configuration> package mount-point name fsid fs-name options secret-file monitors subdir legacy-mount-syntax?)
(list (file-system
(device (if legacy-mount-syntax?
(string-append (string-join monitors ",") ":" subdir)
(string-append name "@" fsid "." fs-name "=" subdir)))
(options (string-append options ","
(if legacy-mount-syntax?
(string-append "name=" name)
(string-append "mon_addr=" (string-join monitors "/")))
",secretfile=" secret-file))
;; Filesystem cannot be mounted as its not a real device; instead a shepherd service is used to mount the file-system
(mount? #f)
(create-mount-point? #t)
(mount-point mount-point)
(type "ceph"))))))
(define cephfs-profile
(compose list cephfs-configuration-package))
(define cephfs-service-type
(service-type
(name 'cephfs)
(description "Mount cephfs filesystems.")
(extensions
(list (service-extension shepherd-root-service-type cephfs-shepherd-service)
(service-extension file-system-service-type cephfs-file-systems)
(service-extension profile-service-type cephfs-profile)))))