WIP: bees service
[jackhill/guix/guix.git] / gnu / services / bees.scm
CommitLineData
f01446c3
JH
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2021 Jack Hill <jackhill@jackhill.us>
3;;;
4;;; This file is part of GNU Guix.
5;;;
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.
10;;;
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.
15;;;
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/>.
18
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
25 bees-configuration?
26 bees-service-type))
27
28(define-record-type* <bees-configuration>
29 bees-configuration make-bees-configuration
30 bees-configuration?
31 (bees bees-configuration-bees
32 (default bees))
33 (uuid bees-configuration-uuid)
34 (work-dir bees-configuration-work-dir
35 (default '()))
36 (mnt-dir bees-configuration-mnt-dir
37 (default '()))
38 (beeshome bees-configuration-beeshome
39 (default '()))
40 (beesstatus bees-configuration-beesstatus
41 (default '()))
42 (thread-count bees-configuration-thread-count
43 (default '()))
44 (thread-factor bees-configuration-thread-factor
45 (default '()))
46 (thread-min bees-configuration-thread-min
47 (default '()))
48 (loadavg-target bees-configuration-loadavg-target
49 (default '()))
50 (scan-mode bees-configuration-scan-mode
51 (default '()))
52 (workaround-btrfs-send bees-configuration-workaround-btrfs-send
53 (default '()))
54 (timestamps bees-configuration-timestamps
55 (default '()))
56 (absolute-paths bees-configuration-absolute-paths
57 (default '()))
58 (log-level bees-configuration-log-level
59 (default '()))
60 (db-size bees-configuration-db-size
61 (default '())))
62
63
64(define bees-configuration-file
65 (match-lambda
66 (($ <bees-configuration> bees uuid work-dir
67 mnt-dir beeshome
68 beesstatus thread-count
69 thread-factor thread-min
70 loadavg-target scan-mode
71 workaround-btrfs-send
72 timestamps absolute-paths
73 log-level db-size)
74 (mixed-text-file "bees.conf"
75 "UUID=" uuid "\n"
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")
86 "OPTIONS=\""
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 ")
100 (case timestamps
101 ((#t) "--timestamps ")
102 ((#f) "--no-timestamps "))
103 (case absolute-paths
104 ((#t) "--absolute-paths ")
105 ((#f) "--strip-paths "))
106 (unless (eq? log-level '())
107 "--verbose " log-level)
108 "\"\n"))))
109
110(define (bees-etc-service config)
111 (list `("bees/beesd.conf" ,(bees-configuration-file config))))
112
113(define bees-service-type
114 (service-type
115 (name 'bees)
116 (extensions
117 (list (service-extension etc-service-type
118 bees-etc-service)))
119 (description "run bees")))