1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2021 Jack Hill <jackhill@jackhill.us>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu services bees)
20 #:use-module (gnu services)
21 #:use-module (guix gexp)
22 #:use-module (guix records)
23 #:use-module (ice-9 match)
24 #:export (bees-configuration
28 (define-record-type* <bees-configuration>
29 bees-configuration make-bees-configuration
31 (bees bees-configuration-bees
33 (uuid bees-configuration-uuid)
34 (work-dir bees-configuration-work-dir
36 (mnt-dir bees-configuration-mnt-dir
38 (beeshome bees-configuration-beeshome
40 (beesstatus bees-configuration-beesstatus
42 (thread-count bees-configuration-thread-count
44 (thread-factor bees-configuration-thread-factor
46 (thread-min bees-configuration-thread-min
48 (loadavg-target bees-configuration-loadavg-target
50 (scan-mode bees-configuration-scan-mode
52 (workaround-btrfs-send bees-configuration-workaround-btrfs-send
54 (timestamps bees-configuration-timestamps
56 (absolute-paths bees-configuration-absolute-paths
58 (log-level bees-configuration-log-level
60 (db-size bees-configuration-db-size
64 (define bees-configuration-file
66 (($ <bees-configuration> bees uuid work-dir
68 beesstatus thread-count
69 thread-factor thread-min
70 loadavg-target scan-mode
72 timestamps absolute-paths
74 (mixed-text-file "bees.conf"
76 (unless (eq? work-dir '())
77 "WORK_DIR=" work-dir "\n")
78 (unless (eq? mnt-dir '())
79 "MNT_DIR=" mnt-dir "\n")
80 (unless (eq? beeshome '())
81 "BEESHOME" beeshome "\n")
82 (unless (eq? beesstatus '())
83 "BEESSTATUS=" beesstatus "\n")
84 (unless (eq? db-size '())
85 "DB_SIZE=" db-size "\n")
87 (unless (eq? thread-count '())
88 "--thread-count " thread-count " ")
89 (unless (eq? thread-factor '())
90 "--thread-factor " thread-factor " ")
91 (unless (eq? thread-min '())
92 "--thread-min " thread-min " ")
93 (unless (eq? loadavg-target '())
94 "--loadavg-target " loadavg-target " ")
95 (unless (eq? scan-mode '())
96 "--scan-mode " scan-mode " ")
97 (unless (or (eq? workaround-btrfs-send '())
98 (not workaround-btrfs-send))
99 "--workaround-btrfs-send ")
101 ((#t) "--timestamps ")
102 ((#f) "--no-timestamps "))
104 ((#t) "--absolute-paths ")
105 ((#f) "--strip-paths "))
106 (unless (eq? log-level '())
107 "--verbose " log-level)
110 (define (bees-etc-service config)
111 (list `("bees/beesd.conf" ,(bees-configuration-file config))))
113 (define bees-service-type
117 (list (service-extension etc-service-type
119 (description "run bees")))