From 7d692df00b3b50e86493e8cd718cd48ba673c8c2 Mon Sep 17 00:00:00 2001 From: Jack Hill Date: Fri, 26 Feb 2021 12:38:06 -0500 Subject: [PATCH] WIP: bees service --- gnu/local.mk | 1 + gnu/services/bees.scm | 119 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 gnu/services/bees.scm diff --git a/gnu/local.mk b/gnu/local.mk index 77ddb650d7..b242cd42bd 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -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 index 0000000000..6ba76ca7fd --- /dev/null +++ b/gnu/services/bees.scm @@ -0,0 +1,119 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Jack Hill +;;; +;;; 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 . + +(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 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 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"))) -- 2.20.1