summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rodion/services/miniflux.scm70
1 files changed, 61 insertions, 9 deletions
diff --git a/rodion/services/miniflux.scm b/rodion/services/miniflux.scm
index 17f7876..23db38c 100644
--- a/rodion/services/miniflux.scm
+++ b/rodion/services/miniflux.scm
@@ -1,13 +1,65 @@
(define-module (rodion services miniflux)
- #:use-module (gnu services shepherd))
+ #:use-module (gnu services shepherd)
+ #:use-module (gnu services)
+ #:use-module (gnu services configuration)
+ #:use-module (gnu system shadow)
+ #:use-module (guix gexp)
+ #:use-module (guix records)
+ #:use-module (gnu packages admin)
+ #:use-module (gnu services databases)
+ #:use-module (rodion packages go)
+ #:export (miniflux-service-type
+ miniflux-configuration
+ miniflux-configuration?
+ miniflux-configuration-test?))
-(define miniflux-shepherd-service (shepherd-service
- (documentation "Run Miniflux server")
- (provision '(miniflux))
- (requirement '(networking postgresql))))
+(define-record-type* <miniflux-configuration>
+ miniflux-configuration make-miniflux-configuration
+ miniflux-configuration?
+ (test? miniflux-configuration-test? (default #t)))
+
+(define (miniflux-shepherd-service _) (list (shepherd-service
+ (documentation "Run Miniflux server")
+ (provision '(miniflux))
+ (requirement '(networking postgresql))
+ (start #~(make-forkexec-constructor
+ (list (string-append #$miniflux "/bin/miniflux"))
+ #:environment-variables (list
+ "DATABASE_URL=host=/var/run/postgresql user=miniflux dbname=miniflux sslmode=disable"
+ "RUN_MIGRATIONS=1"
+ "CREATE_ADMIN=1"
+ "ADMIN_USERNAME=admin"
+ "ADMIN_PASSWORD=password")
+ #:user "miniflux"
+ #:group "miniflux"
+ #:log-file "/var/log/miniflux.log"))
+ (stop #~(make-kill-destructor)))))
+
+(define (miniflux-account config) (list (user-group
+ (name "miniflux")
+ (system? #t))
+ (user-account
+ (name "miniflux")
+ (group "miniflux")
+ (home-directory "/var/empty")
+ (shell (file-append shadow "/sbin/nologin"))
+ (system? #t))))
+
+(define (miniflux-postgresql-role config)
+ (list (postgresql-role
+ (name "miniflux")
+ (create-database? #t))))
(define miniflux-service-type
- (service-type (name 'miniflux)
- (extensions
- (list (service-extension shepherd-root-service-type
- miniflux-shepherd-service)))))
+ (service-type
+ (name 'miniflux)
+ (description "Miniflux service")
+ (default-value (miniflux-configuration))
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ miniflux-shepherd-service)
+ (service-extension account-service-type
+ miniflux-account)
+ (service-extension postgresql-service-type (const #t))
+ (service-extension postgresql-role-service-type
+ miniflux-postgresql-role)))))