blob: a4ca8690476ccd8ffc7fadcba4f58e1822052317 [file] [log] [blame]
Matthias Andreas Benkardc55bfae2021-01-02 07:35:21 +01001RM_F = rm -f
2
3DOCKER = docker
4NIX_DOCKER = $(DOCKER) run --rm --mount source=type=volume,source=nix,target=/nix --volume $$(pwd):$$(pwd) --workdir $$(pwd) nixos/nix
5
6#NIX_BUILD = vctl run -it --rm --volume $$(pwd)/nix:/nix --volume $$(pwd):$$(pwd) --workdir $$(pwd) nixos/nix nix-build
7NIX_BUILD = $(NIX_DOCKER) nix-build
8NIX_BUILD_OUT = $(NIX_DOCKER) sh -c '$$(nix-build)'
9
10IMAGES = mailcow nano nextcloud prosody samba vim webcron
11IMAGES_BIN = $(patsubst %,%.bin,$(IMAGES))
12IMAGES_LOAD = $(patsubst %,%.load,$(IMAGES))
13
14.PHONY: all images clean #$(IMAGES_LOAD)
15
16all: images
17
18clean:
19 $(RM_F) $(IMAGES_BIN)
20
21images: $(IMAGES_LOAD)
22
23# The following approaches were all considered and discarded:
24#
25# Takes ~240 seconds (nextcloud image):
26#
27# $(IMAGES):
28# $(NIX_DOCKER) sh -c '$$(nix-build images.nix -A $@.streamed)' | $(DOCKER) load
29#
30# Takes ~60 seconds (nextcloud image):
31#
32# $(IMAGES):
33# $(NIX_DOCKER) sh -c 'cat $$(nix-build images.nix -A $@.layered)' | $(DOCKER) load
34#
35# The final approach takes ~20 seconds to build the nextcloud image.
36
37%.bin: images.nix
38 $(NIX_DOCKER) sh -c 'cp $$(nix-build images.nix -A $(patsubst %.bin,%,$@).layered) $@'
39
40%.load: %.bin
41 $(DOCKER) load --input=$<