fediport-modifications (#1)

Reviewed-on: #1
Co-authored-by: TakeV <takev@disroot.org>
Co-committed-by: TakeV <takev@disroot.org>
This commit is contained in:
TakeV 2023-08-14 04:25:41 +00:00 committed by TakeV
parent b6c3ac4b13
commit 103497de15
12 changed files with 325 additions and 0 deletions

1
.guix-authorizations Symbolic link
View File

@ -0,0 +1 @@
contrib/guix/guix-authorizations

1
.guix-channel Symbolic link
View File

@ -0,0 +1 @@
contrib/guix/guix-channel

BIN
composer Executable file

Binary file not shown.

100
contrib/guix/.dir-locals.el Normal file
View File

@ -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))))

View File

@ -0,0 +1,19 @@
;; What follows is a "manifest" equivalent to the command line you gave.
;; You can store it in a file that you may then pass to any 'guix' command
;; that accepts a '--manifest' (or '-m') option.
(specifications->manifest
(list "bash"
"coreutils"
"git"
"gnupg"
"node"
"nss-certs"
"openssl"
"php"
"postgresql"
"redis"))
;;; Local Variables:
;;; mode: scheme
;;; End:

View File

@ -0,0 +1,4 @@
(authorizations
(version 0)
(("1086 326D E207 068C 1C02 5129 A64F 4134 5C74 00AF"
(name "TakeV"))))

View File

@ -0,0 +1,8 @@
(channel
(version 0)
(directory "./modules"))
;;; Local Variables:
;;; mode: scheme
;;; End:

View File

@ -0,0 +1,131 @@
(define-module (pixelfed-service)
#:use-module (guix gexp)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix records)
#:use-module (guix packages)
#: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 web)
#:use-module (gnu system shadow)
#:use-module (gnu packages admin)
#:use-module (gnu packages bash)
#:use-module (gnu packages base)
#:use-module (pixelfed)
#:use-module (ice-9 match)
#:export (pixelfed-service-type
pixelfed-configuration))
(define-maybe string)
(define-maybe integer)
(define-configuration/no-serialization pixelfed-configuration
;; Guix config settings
(pixelfed
(package pixelfed)
"The pixelfed package to use")
(config-file
(maybe-string)
"Path to configuration file, defaults to no configuration file")
(port
(integer 8080)
"Port to listen on, default 8080")
(work-dir
(string "/var/lib/pixelfed")
"Pixelfed work directory")
(postgres?
(boolean #t)
"If true, extends the postgresql service running in the same system")
;; App variables
(app-name
(string "Pixelfed")
"Name which appears onn headerbar and other locations")
(app-url
(string "https://localhost")
"Url for the pixelfed instance")
(app-domain
(string "localhost")
"Domain for the app. This should be app-url without the protocol")
(app-key
(maybe-string)
"App key. If not provided, one will be autogenerated")
(session-domain
(string "localhost")
"Domain of session manager")
;; Database variables
(db-database
(string "pixelfed")
"The name of the database to connect to")
(db-host
(maybe-string)
"URL to the database host")
(db-port
(maybe-integer)
"Databse host port")
(db-username
(maybe-string)
"The database user to connect as")
(db-password
(maybe-string)
"Password for the database user")
;; Nginx/https configuration
(nginx?
(boolean #t)
"Set up reverse proxy via nginx")
(https?
(boolean #t)
"Set up HTTPS via certbot"))
(define (pixelfed-activation config)
(match-record config <pixelfed-configuration>
(work-dir pixelfed)))
(define (pixelfed-nginx config)
(match-record config <pixelfed-configuration>
(nginx? https? work-dir)
(if (not nginx?) '()
(list (nginx-server-configuration
(listen (if https? '("443 ssl") '("80")))
(server-name (list app-domain))
(root work-dir)
(ssl-certificate (if https? (string-append "/etc/letsencrypt/live" app-domain "/fullchain.pem") #f))
(ssl-certificate-key (if https? (string-append "/etc/letsencrypt/live" app-domain "/fullchain.pem") #f)))))))
(define (pixelfed-postgresql-role config)
(match-record config <pixelfed-configuration>
(postgres? db-database db-username db-password)
(if postgres?
(list (postgresql-role
(name db-database)
(create-database? #t)))
'())))
(define (pixelfed-accounts config)
(match-record config <pixelfed-configuration>
(work-dir)
(list (user-group
(name "pixelfed")
(system? #t))
(user-account
(name "pixelfed")
(system? #t)
(group "pixelfed")
(comment "pixelfed server user")
(home-directory work-dir)
(shell (file-append bash-minimal "/bin/bash"))))))
(define-public pixelfed-service-type
(service-type
(name 'pixelfed)
(extensions
(list (service-extension account-service-type pixelfed-accounts)
(service-extension nginx-service-type pixelfed-nginx)
(service-extension postgresql-service-type pixelfed-postgresql-role)))
(description "Runs pixelfed")
(default-value (pixelfed-configuration))))

View File

@ -0,0 +1,54 @@
(define-module (pixelfed)
#:use-module (gnu packages imagemagick)
#:use-module (gnu packages php)
#:use-module (guix)
#:use-module (guix build-system copy)
#:use-module (guix build utils)
#:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module ((guix licenses)
#:prefix license:)
#:use-module (guix packages))
(define vcs-file?
(or (git-predicate "../../..")
(const #t)))
(define-public pixelfed
(package
(name "pixelfed")
(version "pixelfed-src")
(source (local-file "../../.."
"-checkout"
#:recursive? #t
#:select? vcs-file?))
(build-system copy-build-system)
(inputs (list imagemagick))
(propagated-inputs (list php))
(arguments
(list #:phases #~(modify-phases %standard-phases
(add-before 'install 'run-tests
(lambda _
(invoke "php" "artisan" "test")))
;; TODO Switch to allowlist copy
(add-after 'run-tests 'cleanup
(lambda _
(begin
(delete-file "composer")
(delete-file-recursively "tests")
(delete-file-recursively "contrib")
(map (lambda (x)
(delete-file-recursively (string-append
"vendor/" x)))
(list "brianium/paratest"
"fakerphp"
"laravel/telescope"
"mockery"
"nunomaduro/collision"
"phpunit/phpunit"))))))))
(home-page "")
(synopsis "")
(description "")
(license license:agpl3)))
pixelfed

5
contrib/guix/run-guix Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
# Run guix shell with a [C]ontainer, linked [P]rofile,
# [N]etwork, [m]anifest, and [f]ile
guix shell -CPNFm dev-manifest.scm -f modules/pixelfed.scm

1
guix.scm Symbolic link
View File

@ -0,0 +1 @@
contrib/guix/modules/pixelfed.scm

1
manifest.scm Symbolic link
View File

@ -0,0 +1 @@
contrib/guix/dev-manifest.scm