diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-11-21 13:55:12 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-11-21 13:55:12 +0100 |
commit | 9bc697b85a69af4d1a270aa5272db150c98bed42 (patch) | |
tree | 93d3d1172ef9fc6de8dad6e56e8226146722029e /Makefile | |
download | koszko-org-server-9bc697b85a69af4d1a270aa5272db150c98bed42.tar.gz koszko-org-server-9bc697b85a69af4d1a270aa5272db150c98bed42.zip |
initial commit
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3c5f7e8 --- /dev/null +++ b/Makefile @@ -0,0 +1,88 @@ +# SPDX-License-Identifier: CC0-1.0 + +# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org> +# +# Available under the terms of Creative Commons Zero v1.0 Universal. + +GUIX := guix + +# Almost all commands in this Makefilo are run through `guix time-machine` with +# Guix revision fixed to the one from the commit below. This ensures that the +# same working environment is always used. +GUIX_COMMIT := a86979b41a49a8fcdaa887970ba594dbba701226 + +GUIX_TM = $(GUIX) time-machine --commit=$(GUIX_COMMIT) -- + +GUIX_LOAD_PATHS = $$( \ + find subrepos/ -mindepth 1 -maxdepth 1 \ + -exec printf '-L %s/guix-module-dir/' {} ';' \ + ) + +GUIX_SYS_CONTAINER = $(GUIX_TM) system container $(GUIX_LOAD_PATHS) + +GUIX_SHELL = $(GUIX_TM) shell + +KOSZKO_ORG_WEBSITE_INFO = \ + subrepos/koszko-org-website/src/koszko_org_website.egg-info/PKG-INFO + +all: | container-runner.touchfile log + +$(KOSZKO_ORG_WEBSITE_INFO): + $(MAKE) -C subrepos/koszko-org-website dist + +container-runner: | container.scm $(KOSZKO_ORG_WEBSITE_INFO) + $(GUIX_SYS_CONTAINER) container.scm -r container-runner + touch container-runner.touchfile + +container-runner.touchfile: \ + container.scm $(KOSZKO_ORG_WEBSITE_INFO) + $(MAKE) clean-runner + $(MAKE) container-runner + +hosts: hosts-extra /etc/hosts + cat $^ > $@ + +log: + mkdir -p log + +start-container: guix-container.sh container-runner.touchfile | log + ./run-with-fake-mounts.sh \ + ./$< start -e ./container-runner -p ./pidfile -l ./log + +stop-container: guix-container.sh + ./$< stop -e ./container-runner -p ./pidfile + +restart-container: guix-container.sh container-runner.touchfile | log + ./run-with-fake-mounts.sh \ + ./$< restart -e ./container-runner -p ./pidfile -l ./log + +enter-container: pidfile + nsenter -a -t "$$(cat pidfile)" \ + /run/current-system/profile/bin/bash --login + +fake-client: fake-client-setup-mounts.sh hosts + unshare --map-root-user --mount ./$< \ + "$${SHELL:-/bin/sh}" "$$(id -ru)" "$$(id -rg)" + +install: container.scm sdists + cp guix-container.sh /etc/init.d/guix-container + mkdir -p /usr/local/bin + $(GUIX_SYS_CONTAINER) container.scm -r /usr/local/bin/guix-container + +reinstall: + rm -rf /usr/local/bin/guix-container + $(MAKE) install + +clean-runner: + rm -rf container-runner container-runner.touchfile + +clean: clean-runner + $(MAKE) -C subrepos/koszko-org-website clean + rm -rf log hosts + +.PHONY: all \ + clean-runner clean \ + start-container stop-container restart-container \ + enter-container fake-client \ + install reinstall \ + sdists koszko-org-wesite-sdist |