guix-builder/Makefile

63 lines
1.5 KiB
Makefile

.DEFAULT_GOAL := build
GUIX_MANIFEST := manifest.scm
GUIX_MANIFEST_DEV := manifest-dev.scm
TARBALL ?= guix-tarball-pack.tar.gz
LINKS_TARBALL ?= links.tar.gz
PASSWD_FILE ?= passwd
OCI_REGISTRY ?= docker-local.nexus.home.rekahsoft.ca
IMAGE_NAME ?= guix-builder
IMAGE_TAG ?= latest
LOCAL_IMAGE_NAME := $(IMAGE_NAME):$(IMAGE_TAG)
PUSH_IMAGE_NAME := $(OCI_REGISTRY)/$(LOCAL_IMAGE_NAME)
$(PASSWD_FILE):
echo 'root:x:0:0:root:/root:/bin/sh' > passwd
$(LINKS_TARBALL):
ln -s /guix-builder/bin bin
mkdir etc && ln -s /guix-builder/etc/ssl etc/ssl
tar -czvf $@ bin etc
rm -r etc bin
$(TARBALL):
@cp $$(guix pack -RR -S /bin=bin -S /etc/ssl=etc/ssl -S /lib/locale=lib/locale -m $(GUIX_MANIFEST)) $@
@chmod +w $@
.PHONY: size
size: $(TARBALL)
guix size $$(guix pack -RR -S /bin=bin -S /etc/ssl=etc/ssl -m $(GUIX_MANIFEST))
.PHONY: pre-build
pre-build: $(TARBALL) $(LINKS_TARBALL) $(PASSWD_FILE)
.PHONY: build
build: pre-build
@docker build -t $(IMAGE_NAME) .
.PHONY: run
run: build
@docker run --rm -it \
-v /var/guix/daemon-socket/socket:/var/guix/daemon-socket/socket \
-v /gnu/store:/gnu/store:ro \
$(IMAGE_NAME):latest
.PHONY: run-no-store
run-no-store: build
@docker run --rm -it $(IMAGE_NAME):latest
.PHONY: shell
shell:
@./shell.sh $(GUIX_MANIFEST) $(GUIX_MANIFEST_DEV)
.PHONY: clean
clean:
rm -r $(TARBALL) $(LINKS_TARBALL) $(PASSWD_FILE)
.PHONY: deploy
deploy:
docker tag $(IMAGE_NAME) $(PUSH_IMAGE_NAME)
docker push $(PUSH_IMAGE_NAME)