Add tests
This commit is contained in:
parent
e6ae17fe1d
commit
0ba79f37af
|
@ -1,5 +1,6 @@
|
||||||
(define-module (kulupu services activity-pub)
|
(define-module (kulupu services gotosocial)
|
||||||
#:use-module (guix gexp)
|
#:use-module (guix gexp)
|
||||||
|
#:use-module ((guix licenses) #:prefix license:)
|
||||||
#:use-module (guix records)
|
#:use-module (guix records)
|
||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
#:use-module (gnu services)
|
#:use-module (gnu services)
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
#:use-module (gnu system shadow)
|
#:use-module (gnu system shadow)
|
||||||
#:use-module (gnu packages admin)
|
#:use-module (gnu packages admin)
|
||||||
#:use-module (gnu packages bash)
|
#:use-module (gnu packages bash)
|
||||||
|
#:use-module (gnu packages base)
|
||||||
#:use-module (kulupu packages gotosocial)
|
#:use-module (kulupu packages gotosocial)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:export (gotosocial-service-type
|
#:export (gotosocial-service-type
|
||||||
|
@ -41,9 +43,9 @@
|
||||||
(run-dir
|
(run-dir
|
||||||
(string "/var/run/gotosocial")
|
(string "/var/run/gotosocial")
|
||||||
"GTS runtime directory")
|
"GTS runtime directory")
|
||||||
(database-type
|
(postgres?
|
||||||
(string "sqlite")
|
(boolean #t)
|
||||||
"Database type to use, default to sqlite")
|
"Set up postgres DB, use sqlite if false")
|
||||||
(database-address
|
(database-address
|
||||||
(string "/var/run/gotosocial/gts.db")
|
(string "/var/run/gotosocial/gts.db")
|
||||||
"Address of the database, default /var/run/gotosocial/gts.db")
|
"Address of the database, default /var/run/gotosocial/gts.db")
|
||||||
|
@ -51,7 +53,7 @@
|
||||||
|
|
||||||
(define (gotosocial-shepherd-service config)
|
(define (gotosocial-shepherd-service config)
|
||||||
(match-record config <gotosocial-configuration>
|
(match-record config <gotosocial-configuration>
|
||||||
(gotosocial frontend config-file port work-dir run-dir host database-type database-address)
|
(gotosocial frontend config-file port work-dir run-dir host postgres? database-address)
|
||||||
(let* ((gts (file-append gotosocial "/bin/gotosocial")))
|
(let* ((gts (file-append gotosocial "/bin/gotosocial")))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(documentation "Run GoToSocial")
|
(documentation "Run GoToSocial")
|
||||||
|
@ -62,7 +64,7 @@
|
||||||
(#$(file-append gotosocial "/bin/gotosocial")
|
(#$(file-append gotosocial "/bin/gotosocial")
|
||||||
"server" "start" "--syslog-enabled"
|
"server" "start" "--syslog-enabled"
|
||||||
"--port=" (number->string #$port)
|
"--port=" (number->string #$port)
|
||||||
"--db-type=" #$database-type
|
$#(when (not postgres?) "--db-type=sqlite")
|
||||||
"--db-address=" #$database-address
|
"--db-address=" #$database-address
|
||||||
"--letsencrypt-cert-dir=" #$work-dir "/storage/certs"
|
"--letsencrypt-cert-dir=" #$work-dir "/storage/certs"
|
||||||
"--storage-local-base-path=" #$work-dir "/storage"
|
"--storage-local-base-path=" #$work-dir "/storage"
|
||||||
|
@ -74,6 +76,13 @@
|
||||||
#:directory #$work-dir))
|
#:directory #$work-dir))
|
||||||
(stop #~(make-kill-destructor)))))))
|
(stop #~(make-kill-destructor)))))))
|
||||||
|
|
||||||
|
(define (gotosocial-postgres-roles config)
|
||||||
|
(match-record config <gotosocial-configuration>
|
||||||
|
(postgres?)
|
||||||
|
(if postgres? (list (postgresql-role
|
||||||
|
(name "gotosocial")
|
||||||
|
(create-database? #t)))
|
||||||
|
'())))
|
||||||
|
|
||||||
(define (gotosocial-accounts config)
|
(define (gotosocial-accounts config)
|
||||||
(match-record config <gotosocial-configuration>
|
(match-record config <gotosocial-configuration>
|
||||||
|
@ -94,6 +103,7 @@
|
||||||
(name 'gotosocial)
|
(name 'gotosocial)
|
||||||
(extensions
|
(extensions
|
||||||
(list (service-extension shepherd-root-service-type gotosocial-shepherd-service)
|
(list (service-extension shepherd-root-service-type gotosocial-shepherd-service)
|
||||||
(service-extension account-service-type gotosocial-accounts)))
|
(service-extension account-service-type gotosocial-accounts)
|
||||||
|
(service-extension postgresql-role-service-type gitea-postgresql-roles)))
|
||||||
(description "Runs GoToSocial")
|
(description "Runs GoToSocial")
|
||||||
(default-value (gotosocial-configuration))))
|
(default-value (gotosocial-configuration))))
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
guix repl -L . --listen=tcp:37146
|
|
@ -0,0 +1,28 @@
|
||||||
|
(define-module (tests utils)
|
||||||
|
#:use-module (gnu)
|
||||||
|
#:use-module (gnu services networking)
|
||||||
|
#:use-module (gnu services ssh)
|
||||||
|
#:use-module (gnu packages ssh)
|
||||||
|
#:use-module (kulupu services gotosocial))
|
||||||
|
|
||||||
|
(define-public %container-system
|
||||||
|
(operating-system
|
||||||
|
(host-name "localhost")
|
||||||
|
(bootloader (bootloader-configuration
|
||||||
|
(bootloader grub-bootloader)
|
||||||
|
(targets '("/dev/sdX"))))
|
||||||
|
;; It's fitting to support the equally bare bones ‘-nographic’
|
||||||
|
;; QEMU option, which also nicely sidesteps forcing QWERTY.
|
||||||
|
(kernel-arguments (list "console=ttyS0,115200"))
|
||||||
|
(file-systems (cons (file-system
|
||||||
|
(device (file-system-label "my-root"))
|
||||||
|
(mount-point "/")
|
||||||
|
(type "ext4"))
|
||||||
|
%base-file-systems))))
|
||||||
|
|
||||||
|
(define-public %gotosocial-container
|
||||||
|
(operating-system
|
||||||
|
(inherit %container-system)
|
||||||
|
(services (list (service gotosocial-service-type)))))
|
||||||
|
|
||||||
|
%gotosocial-container
|
Loading…
Reference in New Issue