diff options
author | EuAndreh <eu@euandre.org> | 2023-03-27 08:32:49 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-03-27 08:32:49 -0300 |
commit | ab742a1ebc61d571bb9d13d7692ef7e245bba192 (patch) | |
tree | 0329573f78946daac6fa62802d189ca53ef2e809 | |
parent | Makefile: Rename "result" to "system" (diff) | |
download | server-ab742a1ebc61d571bb9d13d7692ef7e245bba192.tar.gz server-ab742a1ebc61d571bb9d13d7692ef7e245bba192.tar.xz |
Build HTML and install it via CI
Notes
See CI logs with:
git notes --ref=refs/notes/ci-logs show ab742a1ebc61d571bb9d13d7692ef7e245bba192
git notes --ref=refs/notes/ci-data show ab742a1ebc61d571bb9d13d7692ef7e245bba192
Exit status: 0
Duration: 27
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Makefile | 41 | ||||
-rw-r--r-- | src/infrastructure/guix/packages.scm | 70 | ||||
-rw-r--r-- | src/infrastructure/guix/system.scm | 7 | ||||
-rwxr-xr-x | src/infrastructure/scripts/reconfigure.sh | 5 |
5 files changed, 118 insertions, 10 deletions
@@ -1,3 +1,4 @@ +/public/ /src/secrets/ -/result -/result-next +/packages +/system @@ -1,30 +1,55 @@ .POSIX: +NAME = servers +PREFIX = /usr/local +SHAREDIR = $(PREFIX)/share +DOCDIR = $(SHAREDIR)/doc/$(NAME) -all: +all: public -system: ALWAYS src/infrastructure/keys/SSH/root@euandre.org.id_rsa.pub.stripped +packages system: ALWAYS \ + src/infrastructure/keys/SSH/root@euandre.org.id_rsa.pub.stripped rm -f $@ - guix system -v3 -r $@ build src/infrastructure/guix/$@.scm + guix build -r $@ -v3 -f src/infrastructure/guix/$@.scm src/infrastructure/keys/SSH/root@euandre.org.id_rsa.pub.stripped: \ src/infrastructure/keys/SSH/root@euandre.org.id_rsa.pub.txt - cut -d' ' -f6- < $(@D)/`basename $@ .stripped`.txt > $@ + cut -d' ' -f6- < $(@D)/`basename $(@F) .stripped`.txt > $@ +install: all + mkdir -p \ + '$(DESTDIR)$(DOCDIR)' + cp -R public/* '$(DESTDIR)$(DOCDIR)' -check-shellcheck: - sh tests/assert-shellcheck.sh +uninstall: + rm -rf \ + '$(DESTDIR)$(DOCDIR)' + + +assert-scripts = \ + tests/assert-shellcheck.sh \ + +$(assert-scripts): ALWAYS + sh $@ + +check: all $(assert-scripts) + + +installcheck-docdir: + test -e '$(DESTDIR)$(DOCDIR)'/index.html -check: check-shellcheck +installcheck: installcheck-docdir clean: rm -rf \ - src/secrets/*.txt result result-next \ + public/ src/secrets/*.txt packages system \ public: + mkdir -p public + echo xablau > public/index.html prod-secrets.txt.gpg = \ diff --git a/src/infrastructure/guix/packages.scm b/src/infrastructure/guix/packages.scm new file mode 100644 index 0000000..c2f76e1 --- /dev/null +++ b/src/infrastructure/guix/packages.scm @@ -0,0 +1,70 @@ +(define-module (packages) + #:use-module ((ice-9 popen) #:prefix popen:) + #:use-module ((ice-9 rdelim) #:prefix rdelim:) + #:use-module ((org euandre queue) #:prefix queue:) + #:use-module ((xyz euandreh heredoc) #:prefix heredoc:) + #:use-module (gnu) + #:use-module (guix build utils) + #:use-module (guix build-system gnu) + #:use-module (guix packages)) +(use-package-modules + check + finance + groff + haskell-apps + haskell-xyz + imagemagick + python + python-web + python-xyz + version-control) +(heredoc:enable-syntax) + + +(define working-dir + (if (directory-exists? "/opt/deploy/current") + "/opt/deploy/current" + (canonicalize-path "."))) + +(define version-cmd #"- + if grep -q deployer /etc/passwd && [ -e /opt/deploy/current ]; then + sudo -u deployer git -C /opt/deploy/current rev-parse HEAD + else + git rev-parse HEAD + fi + "#) + +(define repo-version + (let* ((port (popen:open-input-pipe version-cmd)) + (v (rdelim:read-line port))) + (popen:close-pipe port) + v)) + +(define-public servers + (package + (name "servers") + (version repo-version) + (source + (local-file working-dir #:recursive? #t)) + (build-system gnu-build-system) + (arguments + (list + #:make-flags #~(list (string-append "PREFIX=" %output)) + #:phases + #~(modify-phases %standard-phases + (delete 'configure) + (add-after 'install 'installcheck + (lambda* (#:key make-flags #:allow-other-keys) + (define dash-j (format #f "-j~a" (parallel-job-count))) + (apply invoke "make" dash-j "installcheck" make-flags)))))) + (native-inputs + (list + git-minimal + shellcheck)) + (home-page #f) + (synopsis #f) + (description #f) + (license #f))) + +(list + servers) diff --git a/src/infrastructure/guix/system.scm b/src/infrastructure/guix/system.scm index 0cc8377..9257cc6 100644 --- a/src/infrastructure/guix/system.scm +++ b/src/infrastructure/guix/system.scm @@ -40,6 +40,12 @@ "/opt/deploy/current" (canonicalize-path "."))) +(add-to-load-path + (string-append working-dir "/src/infrastructure/guix")) +(use-modules + ((packages) #:prefix packages:)) + + (define (str . rest) (apply string-append rest)) @@ -307,6 +313,7 @@ trash-cli tree)) (list + packages:servers (script "gc" (file "src/infrastructure/scripts/gc.sh")) (script "check" (file "src/infrastructure/scripts/check.sh")) (script "backup" (file "src/infrastructure/scripts/backup.sh")) diff --git a/src/infrastructure/scripts/reconfigure.sh b/src/infrastructure/scripts/reconfigure.sh index 51c7de8..4936e07 100755 --- a/src/infrastructure/scripts/reconfigure.sh +++ b/src/infrastructure/scripts/reconfigure.sh @@ -130,5 +130,10 @@ else sudo -i guix system -c$NPROC -v3 reconfigure /etc/guix/system.scm + rsync \ + --chmod=D775,F664 \ + -a \ + --exclude='dev/ci/*' \ + /run/current-system/profile/share/doc/servers/ /srv/www/s/servers/ deploy fi |