Compare commits
6 Commits
0ba79f37af
...
ec9185f503
Author | SHA1 | Date |
---|---|---|
TakeV | ec9185f503 | |
TakeV | bd32605d84 | |
TakeV | adcc79730a | |
TakeV | c7acbbcf90 | |
TakeV | 8fc7e960f2 | |
TakeV | 52a832327b |
|
@ -0,0 +1,100 @@
|
|||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
;; Per-directory local variables for GNU Emacs 23 and later.
|
||||
|
||||
((nil
|
||||
. ((fill-column . 78)
|
||||
(tab-width . 8)
|
||||
(sentence-end-double-space . t)
|
||||
|
||||
;; For use with 'bug-reference-prog-mode'.
|
||||
(bug-reference-url-format . "https://gitlab.com/nonguix/nonguix/issues/%s")
|
||||
(bug-reference-bug-regexp
|
||||
. "\\(#\\([0-9]+\\)\\)")))
|
||||
(c-mode . ((c-file-style . "gnu")))
|
||||
(scheme-mode
|
||||
.
|
||||
((indent-tabs-mode . nil)
|
||||
(eval . (put 'eval-when 'scheme-indent-function 1))
|
||||
(eval . (put 'call-with-prompt 'scheme-indent-function 1))
|
||||
(eval . (put 'test-assert 'scheme-indent-function 1))
|
||||
(eval . (put 'test-assertm 'scheme-indent-function 1))
|
||||
(eval . (put 'test-equalm 'scheme-indent-function 1))
|
||||
(eval . (put 'test-equal 'scheme-indent-function 1))
|
||||
(eval . (put 'test-eq 'scheme-indent-function 1))
|
||||
(eval . (put 'call-with-input-string 'scheme-indent-function 1))
|
||||
(eval . (put 'guard 'scheme-indent-function 1))
|
||||
(eval . (put 'lambda* 'scheme-indent-function 1))
|
||||
(eval . (put 'substitute* 'scheme-indent-function 1))
|
||||
(eval . (put 'match-record 'scheme-indent-function 2))
|
||||
|
||||
;; 'modify-phases' and its keywords.
|
||||
(eval . (put 'modify-phases 'scheme-indent-function 1))
|
||||
(eval . (put 'replace 'scheme-indent-function 1))
|
||||
(eval . (put 'add-before 'scheme-indent-function 2))
|
||||
(eval . (put 'add-after 'scheme-indent-function 2))
|
||||
|
||||
(eval . (put 'modify-services 'scheme-indent-function 1))
|
||||
(eval . (put 'with-directory-excursion 'scheme-indent-function 1))
|
||||
(eval . (put 'package 'scheme-indent-function 0))
|
||||
(eval . (put 'origin 'scheme-indent-function 0))
|
||||
(eval . (put 'build-system 'scheme-indent-function 0))
|
||||
(eval . (put 'bag 'scheme-indent-function 0))
|
||||
(eval . (put 'graft 'scheme-indent-function 0))
|
||||
(eval . (put 'operating-system 'scheme-indent-function 0))
|
||||
(eval . (put 'file-system 'scheme-indent-function 0))
|
||||
(eval . (put 'manifest-entry 'scheme-indent-function 0))
|
||||
(eval . (put 'manifest-pattern 'scheme-indent-function 0))
|
||||
(eval . (put 'substitute-keyword-arguments 'scheme-indent-function 1))
|
||||
(eval . (put 'with-store 'scheme-indent-function 1))
|
||||
(eval . (put 'with-external-store 'scheme-indent-function 1))
|
||||
(eval . (put 'with-error-handling 'scheme-indent-function 0))
|
||||
(eval . (put 'with-mutex 'scheme-indent-function 1))
|
||||
(eval . (put 'with-atomic-file-output 'scheme-indent-function 1))
|
||||
(eval . (put 'call-with-compressed-output-port 'scheme-indent-function 2))
|
||||
(eval . (put 'call-with-decompressed-port 'scheme-indent-function 2))
|
||||
(eval . (put 'call-with-gzip-input-port 'scheme-indent-function 1))
|
||||
(eval . (put 'call-with-gzip-output-port 'scheme-indent-function 1))
|
||||
(eval . (put 'call-with-lzip-input-port 'scheme-indent-function 1))
|
||||
(eval . (put 'call-with-lzip-output-port 'scheme-indent-function 1))
|
||||
(eval . (put 'signature-case 'scheme-indent-function 1))
|
||||
(eval . (put 'emacs-batch-eval 'scheme-indent-function 0))
|
||||
(eval . (put 'emacs-batch-edit-file 'scheme-indent-function 1))
|
||||
(eval . (put 'emacs-substitute-sexps 'scheme-indent-function 1))
|
||||
(eval . (put 'emacs-substitute-variables 'scheme-indent-function 1))
|
||||
(eval . (put 'with-derivation-narinfo 'scheme-indent-function 1))
|
||||
(eval . (put 'with-derivation-substitute 'scheme-indent-function 2))
|
||||
(eval . (put 'with-status-report 'scheme-indent-function 1))
|
||||
(eval . (put 'with-status-verbosity 'scheme-indent-function 1))
|
||||
|
||||
(eval . (put 'mlambda 'scheme-indent-function 1))
|
||||
(eval . (put 'mlambdaq 'scheme-indent-function 1))
|
||||
(eval . (put 'syntax-parameterize 'scheme-indent-function 1))
|
||||
(eval . (put 'with-monad 'scheme-indent-function 1))
|
||||
(eval . (put 'mbegin 'scheme-indent-function 1))
|
||||
(eval . (put 'mwhen 'scheme-indent-function 1))
|
||||
(eval . (put 'munless 'scheme-indent-function 1))
|
||||
(eval . (put 'mlet* 'scheme-indent-function 2))
|
||||
(eval . (put 'mlet 'scheme-indent-function 2))
|
||||
(eval . (put 'run-with-store 'scheme-indent-function 1))
|
||||
(eval . (put 'run-with-state 'scheme-indent-function 1))
|
||||
(eval . (put 'wrap-program 'scheme-indent-function 1))
|
||||
(eval . (put 'with-imported-modules 'scheme-indent-function 1))
|
||||
(eval . (put 'with-extensions 'scheme-indent-function 1))
|
||||
|
||||
(eval . (put 'with-database 'scheme-indent-function 2))
|
||||
(eval . (put 'call-with-transaction 'scheme-indent-function 2))
|
||||
|
||||
(eval . (put 'call-with-container 'scheme-indent-function 1))
|
||||
(eval . (put 'container-excursion 'scheme-indent-function 1))
|
||||
(eval . (put 'eventually 'scheme-indent-function 1))
|
||||
|
||||
(eval . (put 'call-with-progress-reporter 'scheme-indent-function 1))
|
||||
|
||||
;; This notably allows '(' in Paredit to not insert a space when the
|
||||
;; preceding symbol is one of these.
|
||||
(eval . (modify-syntax-entry ?~ "'"))
|
||||
(eval . (modify-syntax-entry ?$ "'"))
|
||||
(eval . (modify-syntax-entry ?+ "'"))))
|
||||
(emacs-lisp-mode . ((indent-tabs-mode . nil)))
|
||||
(texinfo-mode . ((indent-tabs-mode . nil)
|
||||
(fill-column . 72))))
|
|
@ -1,23 +1,23 @@
|
|||
(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 (gnu services)
|
||||
#:use-module (gnu services)
|
||||
#:use-module (gnu services certbot)
|
||||
#:use-module (gnu services configuration)
|
||||
#:use-module (gnu services databases)
|
||||
#:use-module (gnu services base)
|
||||
#:use-module (gnu services shepherd)
|
||||
#:use-module (gnu services base)
|
||||
#:use-module (gnu services shepherd)
|
||||
#:use-module (gnu services web)
|
||||
#:use-module (gnu system shadow)
|
||||
#:use-module (gnu packages admin)
|
||||
#: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
|
||||
gotosocial-configuration))
|
||||
#:use-module (kulupu packages gotosocial)
|
||||
#:use-module (ice-9 match)
|
||||
#:export (gotosocial-service-type
|
||||
gotosocial-configuration))
|
||||
|
||||
(define-maybe string)
|
||||
|
||||
|
@ -46,64 +46,126 @@
|
|||
(postgres?
|
||||
(boolean #t)
|
||||
"Set up postgres DB, use sqlite if false")
|
||||
(nginx?
|
||||
(boolean #t)
|
||||
"Set up reverse proxy via nginx")
|
||||
(https?
|
||||
(boolean #t)
|
||||
"Set up HTTPS via certbot")
|
||||
(database-address
|
||||
(string "/var/run/gotosocial/gts.db")
|
||||
"Address of the database, default /var/run/gotosocial/gts.db")
|
||||
(no-serialization))
|
||||
|
||||
(define (gotosocial-shepherd-service config)
|
||||
(match-record config <gotosocial-configuration>
|
||||
(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")
|
||||
(requirement '(networking))
|
||||
(provision '(gotosocial))
|
||||
(start #~(make-forkexec-constructor
|
||||
(list
|
||||
(#$(file-append gotosocial "/bin/gotosocial")
|
||||
"server" "start" "--syslog-enabled"
|
||||
"--port=" (number->string #$port)
|
||||
$#(when (not postgres?) "--db-type=sqlite")
|
||||
"--db-address=" #$database-address
|
||||
"--letsencrypt-cert-dir=" #$work-dir "/storage/certs"
|
||||
"--storage-local-base-path=" #$work-dir "/storage"
|
||||
"--web-asset-base-dir=" #$(file-append frontend "/gotosocial/web/assets")
|
||||
"--web-template-base-dir=" #$(file-append frontend "/gotosocial/web/template")
|
||||
"--host=" host))
|
||||
#:user "gotosocial"
|
||||
#:group "gotosocial"
|
||||
#:directory #$work-dir))
|
||||
(stop #~(make-kill-destructor)))))))
|
||||
|
||||
(define (gotosocial-postgres-roles config)
|
||||
(match-record config <gotosocial-configuration>
|
||||
(postgres?)
|
||||
(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")
|
||||
(requirement `(networking ,@(if postgres? '(postgres) '())))
|
||||
(provision '(gotosocial))
|
||||
(start #~(make-forkexec-constructor
|
||||
(list
|
||||
(#$(file-append gotosocial "/bin/gotosocial")
|
||||
"server" "start" "--syslog-enabled"
|
||||
"--port=" (number->string #$port)
|
||||
$#(when (not postgres?) "--db-type=sqlite")
|
||||
"--db-address=" #$database-address
|
||||
"--letsencrypt-cert-dir=" #$work-dir "/storage/certs"
|
||||
"--storage-local-base-path=" #$work-dir "/storage"
|
||||
"--web-asset-base-dir=" #$(file-append frontend "/gotosocial/web/assets")
|
||||
"--web-template-base-dir=" #$(file-append frontend "/gotosocial/web/template")
|
||||
"--host=" host))
|
||||
#:user "gotosocial"
|
||||
#:group "gotosocial"
|
||||
#:directory #$work-dir))
|
||||
(stop #~(make-kill-destructor)))))))
|
||||
|
||||
(define (gotosocial-postgresql-roles config)
|
||||
(match-record config <gotosocial-configuration>
|
||||
(postgres?)
|
||||
(if postgres? (list (postgresql-role
|
||||
(name "gotosocial")
|
||||
(create-database? #t)))
|
||||
'())))
|
||||
|
||||
(define (gotosocial-certbot config)
|
||||
(match-record config <gotosocial-configuration>
|
||||
(https? host nginx?)
|
||||
(if (not https?) '()
|
||||
(list (certificate-configuration
|
||||
(domains (list host))
|
||||
(deploy-hook (if nginx? %nginx-cert-deploy-hook %gotosocial-cert-deploy-hook)))))))
|
||||
|
||||
(define %nginx-cert-deploy-hook
|
||||
(program-file
|
||||
"nginx-cert-deploy-hook"
|
||||
#~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
|
||||
(kill pid SIGHUP))))
|
||||
|
||||
(define %gotosocial-cert-deploy-hook
|
||||
(program-file
|
||||
"gotosocial-cert-deploy-hook"
|
||||
(with-imported-modules '((guix build utils))
|
||||
#~(begin (use-module (guix build utils))
|
||||
(invoke "herd" "restart" "gotosocial")))))
|
||||
|
||||
(define (gotosocial-nginx config)
|
||||
(match-record config <gotosocial-configuration>
|
||||
(nginx? https? host run-dir)
|
||||
(if (not nginx?) '()
|
||||
(list (nginx-server-configuration
|
||||
(listen (if https? '("443 ssl") '("80")))
|
||||
(server-name (list host))
|
||||
(ssl-certificate (if https? (string-append "/etc/letsencrypt/live/" host "/fullchain.pem") #f))
|
||||
(ssl-certificate-key (if https? (string-append "/etc/letsencrypt/live/" host "/privkey.pem") #f))
|
||||
(locations (list
|
||||
(nginx-location-configuration
|
||||
(uri "/")
|
||||
(body `(,(string-append "proxy_pass http://unix:" run-dir "/gotosocial.socket;")
|
||||
"proxy_set_header Host $host;"
|
||||
"proxy_set_header X-Real_IP $remote_addr;"
|
||||
"proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;"
|
||||
"proxy_set_header X-Forwarded-Proto $scheme;"))))))))))
|
||||
|
||||
(define (gotosocial-activation config)
|
||||
(match-record config <gotosocial-configuration>
|
||||
(work-dir run-dir)
|
||||
#~(begin
|
||||
(use-modules (guix build utils)
|
||||
(ice-9 string-fun))
|
||||
(let* ((user (getpw "gotosocial"))
|
||||
(user-id (passwd:uid user))
|
||||
(group-id (passwd:gid user)))
|
||||
(mkdir-p #$work-dir)
|
||||
(mkdir-p #$run-dir)
|
||||
(chown #$work-dir user-id group-id)
|
||||
(chown #$run-dir user-id group-id)))))
|
||||
|
||||
(define (gotosocial-accounts config)
|
||||
(match-record config <gotosocial-configuration>
|
||||
(work-dir)
|
||||
(list (user-group
|
||||
(name "gotosocial")
|
||||
(system? #t))
|
||||
(user-account
|
||||
(name "gotosocial")
|
||||
(system? #t)
|
||||
(group "gotosocial")
|
||||
(comment "GoToSocial server user")
|
||||
(home-directory work-dir)
|
||||
(shell (file-append bash-minimal "/bin/bash"))))))
|
||||
(name "gotosocial")
|
||||
(system? #t))
|
||||
(user-account
|
||||
(name "gotosocial")
|
||||
(system? #t)
|
||||
(group "gotosocial")
|
||||
(comment "GoToSocial server user")
|
||||
(home-directory work-dir)
|
||||
(shell (file-append bash-minimal "/bin/bash"))))))
|
||||
|
||||
(define gotosocial-service-type
|
||||
(service-type
|
||||
(name 'gotosocial)
|
||||
(extensions
|
||||
(list (service-extension shepherd-root-service-type gotosocial-shepherd-service)
|
||||
(service-extension account-service-type gotosocial-accounts)
|
||||
(service-extension postgresql-role-service-type gitea-postgresql-roles)))
|
||||
(description "Runs GoToSocial")
|
||||
(default-value (gotosocial-configuration))))
|
||||
(define-public gotosocial-service-type
|
||||
(service-type
|
||||
(name 'gotosocial)
|
||||
(extensions
|
||||
(list (service-extension shepherd-root-service-type gotosocial-shepherd-service)
|
||||
(service-extension account-service-type gotosocial-accounts)
|
||||
(service-extension activation-service-type gotosocial-activation)
|
||||
(service-extension nginx-service-type gotosocial-nginx)
|
||||
(service-extension certbot-service-type gotosocial-certbot)
|
||||
(service-extension postgresql-role-service-type gotosocial-postgresql-roles)))
|
||||
(description "Runs GoToSocial")
|
||||
(default-value (gotosocial-configuration))))
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
(define-module (kulupu tests gotosocial)
|
||||
#:use-module (kulupu services gotosocial)
|
||||
#:use-module (kulupu packages gotosocial)
|
||||
#:use-module (kulupu tests utils)
|
||||
#:use-module (srfi srfi-64))
|
|
@ -0,0 +1,56 @@
|
|||
(define-module (kulupu tests utils)
|
||||
#:use-module (gnu)
|
||||
#:use-module (gnu services databases)
|
||||
#:use-module (gnu services networking)
|
||||
#:use-module (gnu packages databases)
|
||||
#:use-module (gnu services ssh)
|
||||
#:use-module (gnu services certbot)
|
||||
#:use-module (gnu packages linux)
|
||||
#:use-module (gnu packages ssh)
|
||||
#:use-module (kulupu services gotosocial))
|
||||
|
||||
(define %base-container-services
|
||||
(cons
|
||||
(service static-networking-service-type
|
||||
(list (static-networking
|
||||
(addresses
|
||||
(list (network-address
|
||||
(device "veth")
|
||||
(value "10.0.0.2/24"))))
|
||||
(routes
|
||||
(list (network-route
|
||||
(destination "default")
|
||||
(gateway "10.0.0.1")))))))
|
||||
%base-services))
|
||||
|
||||
(define-public %container-system
|
||||
(operating-system
|
||||
(kernel linux-libre-lts)
|
||||
(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))
|
||||
(services %base-container-services)))
|
||||
|
||||
(define-public %gotosocial-container
|
||||
(operating-system
|
||||
(inherit %container-system)
|
||||
(services (cons*
|
||||
(service certbot-service-type
|
||||
(certbot-configuration
|
||||
(email "test@test.com")))
|
||||
(service postgresql-service-type
|
||||
(postgresql-configuration
|
||||
(postgresql postgresql-10)))
|
||||
(service gotosocial-service-type)
|
||||
%base-container-services))))
|
||||
|
||||
%gotosocial-container
|
|
@ -1,28 +0,0 @@
|
|||
(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