WIP: bees service
authorJack Hill <jackhill@jackhill.us>
Fri, 26 Feb 2021 17:38:06 +0000 (12:38 -0500)
committerJack Hill <jackhill@jackhill.us>
Fri, 9 Jul 2021 23:42:05 +0000 (19:42 -0400)
gnu/local.mk
gnu/services/bees.scm [new file with mode: 0644]

index 77ddb65..b242cd4 100644 (file)
@@ -604,6 +604,7 @@ GNU_SYSTEM_MODULES =                                \
   %D%/services/auditd.scm                      \
   %D%/services/avahi.scm                       \
   %D%/services/base.scm                                \
+  %D%/services/bees.scm                                \
   %D%/services/certbot.scm                     \
   %D%/services/cgit.scm                        \
   %D%/services/ci.scm                          \
diff --git a/gnu/services/bees.scm b/gnu/services/bees.scm
new file mode 100644 (file)
index 0000000..6ba76ca
--- /dev/null
@@ -0,0 +1,119 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 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 bees)
+  #:use-module (gnu services)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+  #:use-module (ice-9 match)
+  #:export (bees-configuration
+            bees-configuration?
+            bees-service-type))
+
+(define-record-type* <bees-configuration>
+  bees-configuration       make-bees-configuration
+  bees-configuration?
+  (bees                    bees-configuration-bees
+                           (default bees))
+  (uuid                    bees-configuration-uuid)
+  (work-dir                bees-configuration-work-dir
+                           (default '()))
+  (mnt-dir                 bees-configuration-mnt-dir
+                           (default '()))
+  (beeshome                bees-configuration-beeshome
+                           (default '()))
+  (beesstatus              bees-configuration-beesstatus
+                           (default '()))
+  (thread-count            bees-configuration-thread-count
+                           (default '()))
+  (thread-factor           bees-configuration-thread-factor
+                           (default '()))
+  (thread-min              bees-configuration-thread-min
+                           (default '()))
+  (loadavg-target          bees-configuration-loadavg-target
+                           (default '()))
+  (scan-mode               bees-configuration-scan-mode
+                           (default '()))
+  (workaround-btrfs-send   bees-configuration-workaround-btrfs-send
+                           (default '()))
+  (timestamps              bees-configuration-timestamps
+                           (default '()))
+  (absolute-paths          bees-configuration-absolute-paths
+                           (default '()))
+  (log-level               bees-configuration-log-level
+                           (default '()))
+  (db-size                 bees-configuration-db-size
+                           (default '())))
+
+
+(define bees-configuration-file
+  (match-lambda
+      (($ <bees-configuration> bees uuid work-dir
+                               mnt-dir beeshome
+                               beesstatus thread-count
+                               thread-factor thread-min
+                               loadavg-target scan-mode
+                               workaround-btrfs-send
+                               timestamps absolute-paths
+                               log-level db-size)
+       (mixed-text-file "bees.conf"
+                   "UUID=" uuid "\n"
+                   (unless (eq? work-dir '())
+                     "WORK_DIR=" work-dir "\n")
+                   (unless (eq? mnt-dir '())
+                     "MNT_DIR=" mnt-dir "\n")
+                   (unless (eq? beeshome '())
+                     "BEESHOME" beeshome "\n")
+                   (unless (eq? beesstatus '())
+                     "BEESSTATUS=" beesstatus "\n")
+                   (unless (eq? db-size '())
+                     "DB_SIZE=" db-size "\n")
+                   "OPTIONS=\""
+                   (unless (eq? thread-count '())
+                     "--thread-count " thread-count " ")
+                   (unless (eq? thread-factor '())
+                     "--thread-factor " thread-factor " ")
+                   (unless (eq? thread-min '())
+                     "--thread-min " thread-min " ")
+                   (unless (eq? loadavg-target '())
+                     "--loadavg-target " loadavg-target " ")
+                   (unless (eq? scan-mode '())
+                     "--scan-mode " scan-mode " ")
+                   (unless (or (eq? workaround-btrfs-send '())
+                               (not workaround-btrfs-send))
+                     "--workaround-btrfs-send ")
+                   (case timestamps
+                     ((#t) "--timestamps ")
+                     ((#f) "--no-timestamps "))
+                   (case absolute-paths
+                     ((#t) "--absolute-paths ")
+                     ((#f) "--strip-paths "))
+                   (unless (eq? log-level '())
+                     "--verbose " log-level)
+                   "\"\n"))))
+
+(define (bees-etc-service config)
+  (list `("bees/beesd.conf" ,(bees-configuration-file config))))
+
+(define bees-service-type
+  (service-type
+   (name 'bees)
+   (extensions
+    (list (service-extension etc-service-type
+                             bees-etc-service)))
+   (description "run bees")))