diff --git a/kulupu/services/activity-pub.scm b/kulupu/services/gotosocial.scm similarity index 83% rename from kulupu/services/activity-pub.scm rename to kulupu/services/gotosocial.scm index cd7cdf3..156fc5b 100644 --- a/kulupu/services/activity-pub.scm +++ b/kulupu/services/gotosocial.scm @@ -1,5 +1,6 @@ -(define-module (kulupu services activity-pub) +(define-module (kulupu services gotosocial) #:use-module (guix gexp) + #:use-module ((guix licenses) #:prefix license:) #:use-module (guix records) #:use-module (guix packages) #:use-module (gnu services) @@ -12,6 +13,7 @@ #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (gnu packages bash) + #:use-module (gnu packages base) #:use-module (kulupu packages gotosocial) #:use-module (ice-9 match) #:export (gotosocial-service-type @@ -41,9 +43,9 @@ (run-dir (string "/var/run/gotosocial") "GTS runtime directory") - (database-type - (string "sqlite") - "Database type to use, default to sqlite") + (postgres? + (boolean #t) + "Set up postgres DB, use sqlite if false") (database-address (string "/var/run/gotosocial/gts.db") "Address of the database, default /var/run/gotosocial/gts.db") @@ -51,7 +53,7 @@ (define (gotosocial-shepherd-service config) (match-record config - (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"))) (list (shepherd-service (documentation "Run GoToSocial") @@ -62,7 +64,7 @@ (#$(file-append gotosocial "/bin/gotosocial") "server" "start" "--syslog-enabled" "--port=" (number->string #$port) - "--db-type=" #$database-type + $#(when (not postgres?) "--db-type=sqlite") "--db-address=" #$database-address "--letsencrypt-cert-dir=" #$work-dir "/storage/certs" "--storage-local-base-path=" #$work-dir "/storage" @@ -74,6 +76,13 @@ #:directory #$work-dir)) (stop #~(make-kill-destructor))))))) +(define (gotosocial-postgres-roles config) + (match-record config + (postgres?) + (if postgres? (list (postgresql-role + (name "gotosocial") + (create-database? #t))) + '()))) (define (gotosocial-accounts config) (match-record config @@ -94,6 +103,7 @@ (name 'gotosocial) (extensions (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") (default-value (gotosocial-configuration)))) diff --git a/run-repl.sh b/run-repl.sh new file mode 100755 index 0000000..7c9828e --- /dev/null +++ b/run-repl.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +guix repl -L . --listen=tcp:37146 diff --git a/tests/utils.scm b/tests/utils.scm new file mode 100644 index 0000000..9c482b2 --- /dev/null +++ b/tests/utils.scm @@ -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