summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--host/initramfs/Makefile10
-rw-r--r--host/initramfs/default.nix8
-rw-r--r--host/rootfs/Makefile15
-rw-r--r--host/rootfs/default.nix6
-rw-r--r--img/app/Makefile25
-rw-r--r--img/app/default.nix2
-rw-r--r--release/live/Makefile10
-rw-r--r--release/live/default.nix8
-rw-r--r--vm/sys/net/Makefile6
-rw-r--r--vm/sys/net/default.nix6
10 files changed, 48 insertions, 48 deletions
diff --git a/host/initramfs/Makefile b/host/initramfs/Makefile
index e341d1a..8dcf420 100644
--- a/host/initramfs/Makefile
+++ b/host/initramfs/Makefile
@@ -1,11 +1,13 @@
 # SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
 
 include ../../lib/common.mk
 
+dest = build/initramfs
+
 RUN_IMAGE = build/live.img
 
-build/initramfs: $(MICROCODE) build/local.cpio $(PACKAGES_CPIO)
+$(dest): $(MICROCODE) build/local.cpio $(PACKAGES_CPIO)
 	cat $(MICROCODE) > $@
 	cat build/local.cpio $(PACKAGES_CPIO) | gzip -9n >> $@
 
@@ -65,10 +67,10 @@ clean:
 	rm -rf build
 .PHONY: clean
 
-run: build/initramfs build/rootfs.verity.roothash $(RUN_IMAGE)
+run: $(dest) build/rootfs.verity.roothash $(RUN_IMAGE)
 	$(QEMU_KVM) -m 4G \
 	    -kernel $(KERNEL) \
-	    -initrd build/initramfs \
+	    -initrd $(dest) \
 	    -append "ro console=ttyS0 ext=vda intel_iommu=on roothash=$$(< build/rootfs.verity.roothash)" \
 	    -cpu host \
 	    -machine q35,kernel-irqchip=split \
diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix
index 1239134..b9b22ae 100644
--- a/host/initramfs/default.nix
+++ b/host/initramfs/default.nix
@@ -91,11 +91,9 @@ stdenvNoCC.mkDerivation {
 
   nativeBuildInputs = [ cpio ];
 
-  installPhase = ''
-    runHook preInstall
-    cp build/initramfs $out
-    runHook postInstall
-  '';
+  makeFlags = [ "dest=$(out)" ];
+
+  dontInstall = true;
 
   enableParallelBuilding = true;
 }
diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile
index 39911eb..73ac361 100644
--- a/host/rootfs/Makefile
+++ b/host/rootfs/Makefile
@@ -1,8 +1,10 @@
 # SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
 
 include ../../lib/common.mk
 
+dest = build/rootfs.ext4
+
 FILES = \
 	etc/fonts/fonts.conf \
 	etc/fstab \
@@ -39,7 +41,8 @@ LINKS = bin sbin
 
 BUILD_FILES = build/etc/mdev/modalias.sh build/etc/s6-rc
 
-build/rootfs.ext4:
+$(dest): build/rootfs.tar
+	$(TAR2EXT4) -i build/rootfs.tar -o $@
 
 build/empty:
 	mkdir -p $@
@@ -115,8 +118,8 @@ clean:
 # veritysetup format produces two files, but Make only (portably)
 # supports one output per rule, so we combine the two outputs then
 # define two more rules to separate them again.
-build/rootfs.verity: build/rootfs.ext4
-	$(VERITYSETUP) format build/rootfs.ext4 build/rootfs.verity.superblock.tmp \
+build/rootfs.verity: $(dest)
+	$(VERITYSETUP) format $(dest) build/rootfs.verity.superblock.tmp \
 	    | awk -F ':[[:blank:]]*' '$$1 == "Root hash" {print $$2; exit}' \
 	    > build/rootfs.verity.roothash.tmp
 	cat build/rootfs.verity.roothash.tmp build/rootfs.verity.superblock.tmp \
@@ -127,10 +130,10 @@ build/rootfs.verity.roothash: build/rootfs.verity
 build/rootfs.verity.superblock: build/rootfs.verity
 	tail -n +2 build/rootfs.verity > $@
 
-build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh build/rootfs.verity.superblock build/rootfs.verity.roothash build/rootfs.ext4
+build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh build/rootfs.verity.superblock build/rootfs.verity.roothash $(dest)
 	../../scripts/make-gpt.sh $@.tmp \
 	    build/rootfs.verity.superblock:2c7357ed-ebd2-46d9-aec1-23d437ec2bf5:$$(../../scripts/format-uuid.sh "$$(dd if=build/rootfs.verity.roothash bs=32 skip=1 count=1 status=none)") \
-	    build/rootfs.ext4:4f68bce3-e8cd-4db1-96e7-fbcaf984b709:$$(../../scripts/format-uuid.sh "$$(head -c 32 build/rootfs.verity.roothash)")
+	    $(dest):4f68bce3-e8cd-4db1-96e7-fbcaf984b709:$$(../../scripts/format-uuid.sh "$$(head -c 32 build/rootfs.verity.roothash)")
 	mv $@.tmp $@
 
 run: build/live.img $(EXT_FS) build/rootfs.verity.roothash
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index 3ca2830..23e4b38 100644
--- a/host/rootfs/default.nix
+++ b/host/rootfs/default.nix
@@ -130,9 +130,9 @@ stdenvNoCC.mkDerivation {
   MODULES_ORDER = "${kernel}/lib/modules/${kernel.modDirVersion}/modules.order";
   PACKAGES_TAR = packagesTar;
 
-  installPhase = ''
-    cp build/rootfs.ext4 $out
-  '';
+  makeFlags = [ "dest=$(out)" ];
+
+  dontInstall = true;
 
   enableParallelBuilding = true;
 
diff --git a/img/app/Makefile b/img/app/Makefile
index 187a5f8..7669568 100644
--- a/img/app/Makefile
+++ b/img/app/Makefile
@@ -1,30 +1,25 @@
 # SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
 
 include ../../lib/common.mk
 
-prefix = /usr/local
+prefix = build/host
 imgdir = $(prefix)/img
 
 VMM = qemu
 
 HOST_BUILD_FILES = \
-	build/host/appvm/blk/root.img \
-	build/host/appvm/vmlinux
+	$(imgdir)/appvm/blk/root.img \
+	$(imgdir)/appvm/vmlinux
 
 all: $(HOST_BUILD_FILES)
 .PHONY: all
 
-install: $(HOST_BUILD_FILES)
-	mkdir -p $(imgdir)
-	tar -c $(HOST_BUILD_FILES) | tar -C $(imgdir) -x --strip-components 2
-.PHONY: install
-
-build/host/appvm/vmlinux: $(VMLINUX)
+$(imgdir)/appvm/vmlinux: $(VMLINUX)
 	mkdir -p $$(dirname $@)
 	cp $(VMLINUX) $@
 
-build/host/appvm/blk/root.img: ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk build/rootfs.ext4
+$(imgdir)/appvm/blk/root.img: ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk build/rootfs.ext4
 	mkdir -p $$(dirname $@)
 	../../scripts/make-gpt.sh $@.tmp \
 	    build/rootfs.ext4:4f68bce3-e8cd-4db1-96e7-fbcaf984b709:5460386f-2203-4911-8694-91400125c604:root
@@ -90,9 +85,9 @@ start-virtiofsd:
 	    $(BACKGROUND) $(VIRTIOFSD) --fd 0 --shared-dir . ""
 .PHONY: start-virtiofsd
 
-run-qemu: build/host/appvm/blk/root.img start-virtiofsd
+run-qemu: $(imgdir)/appvm/blk/root.img start-virtiofsd
 	$(QEMU_KVM) -m 128 -cpu host -machine q35,kernel=$(KERNEL) -vga none \
-	  -drive file=build/host/appvm/blk/root.img,if=virtio,format=raw,readonly=on \
+	  -drive file=$(imgdir)/appvm/blk/root.img,if=virtio,format=raw,readonly=on \
 	  -drive file=$(RUN_IMG),if=virtio,format=raw,readonly=on \
 	  -append "console=ttyS0 root=PARTLABEL=root" \
 	  -netdev user,id=net0 \
@@ -106,11 +101,11 @@ run-qemu: build/host/appvm/blk/root.img start-virtiofsd
 	  -device virtconsole,chardev=virtiocon0
 .PHONY: run-qemu
 
-run-cloud-hypervisor: build/host/appvm/blk/root.img start-virtiofsd
+run-cloud-hypervisor: $(imgdir)/appvm/blk/root.img start-virtiofsd
 	$(CLOUD_HYPERVISOR) \
 	    --api-socket path=vmm.sock \
 	    --memory size=128M,shared=on \
-	    --disk path=build/host/appvm/blk/root.img,readonly=on \
+	    --disk path=$(imgdir)/appvm/blk/root.img,readonly=on \
 	           path=$(RUN_IMG),readonly=on \
 	    --net tap=tap0,mac=0A:B3:EC:00:00:00 \
 	    --fs tag=virtiofs0,socket=virtiofsd.sock \
diff --git a/img/app/default.nix b/img/app/default.nix
index 477a142..70e6e33 100644
--- a/img/app/default.nix
+++ b/img/app/default.nix
@@ -72,6 +72,8 @@ stdenvNoCC.mkDerivation {
 
   makeFlags = [ "prefix=$(out)" ];
 
+  dontInstall = true;
+
   enableParallelBuilding = true;
 
   passthru = { inherit kernel packagesSysroot; };
diff --git a/release/live/Makefile b/release/live/Makefile
index 4eeeaa6..8dfba28 100644
--- a/release/live/Makefile
+++ b/release/live/Makefile
@@ -1,9 +1,11 @@
 # SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
 
 include ../../lib/common.mk
 
-build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh build/boot.fat build/rootfs.verity.superblock build/rootfs.verity.roothash $(ROOT_FS) $(EXT_FS)
+dest = build/live.img
+
+$(dest): ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh build/boot.fat build/rootfs.verity.superblock build/rootfs.verity.roothash $(ROOT_FS) $(EXT_FS)
 	../../scripts/make-gpt.sh $@.tmp \
 	    build/boot.fat:c12a7328-f81f-11d2-ba4b-00a0c93ec93b \
 	    build/rootfs.verity.superblock:2c7357ed-ebd2-46d9-aec1-23d437ec2bf5:$$(../../scripts/format-uuid.sh "$$(dd if=build/rootfs.verity.roothash bs=32 skip=1 count=1 status=none)") \
@@ -47,7 +49,7 @@ clean:
 	rm -rf build
 .PHONY: clean
 
-run: build/live.img
+run: $(dest)
 	$(QEMU_KVM) -m 4G \
 	    -cpu host \
 	    -machine q35,kernel-irqchip=split \
@@ -57,5 +59,5 @@ run: build/live.img
 	    -device qemu-xhci \
 	    -device usb-storage,drive=drive1,removable=true \
 	    -drive file=$(OVMF_CODE),format=raw,if=pflash,readonly=true \
-	    -drive file=build/live.img,id=drive1,format=raw,if=none,readonly=true
+	    -drive file=$(dest),id=drive1,format=raw,if=none,readonly=true
 .PHONY: run
diff --git a/release/live/default.nix b/release/live/default.nix
index 3ba399d..7ab7a22 100644
--- a/release/live/default.nix
+++ b/release/live/default.nix
@@ -35,13 +35,9 @@ stdenvNoCC.mkDerivation {
   SYSTEMD_BOOT_EFI = "${systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi";
   EFINAME = "BOOT${toUpper efiArch}.EFI";
 
-  buildFlags = [ "build/live.img" ];
+  buildFlags = [ "dest=$(out)" ];
 
-  installPhase = ''
-    runHook preInstall
-    mv build/live.img $out
-    runHook postInstall
-  '';
+  dontInstall = true;
 
   enableParallelBuilding = true;
 
diff --git a/vm/sys/net/Makefile b/vm/sys/net/Makefile
index cb294a4..afed270 100644
--- a/vm/sys/net/Makefile
+++ b/vm/sys/net/Makefile
@@ -1,8 +1,10 @@
 # SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
 
 include ../../../lib/common.mk
 
+prefix = build/svc
+
 VMM = qemu
 
 HOST_BUILD_FILES = \
@@ -16,7 +18,7 @@ HOST_BUILD_FILES = \
 # intended to be part of the input, like temporary editor files or
 # .license files.  So for all these reasons, only explicitly listed
 # files are included in the build result.
-build/svc: $(HOST_BUILD_FILES)
+$(prefix): $(HOST_BUILD_FILES)
 	rm -rf $@
 	mkdir -p $@
 
diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix
index 852d5d0..2af46b2 100644
--- a/vm/sys/net/default.nix
+++ b/vm/sys/net/default.nix
@@ -79,9 +79,9 @@ stdenvNoCC.mkDerivation {
   PACKAGES_TAR = packagesTar;
   VMLINUX = "${kernel.dev}/vmlinux";
 
-  installPhase = ''
-    mv build/svc $out
-  '';
+  makeFlags = [ "prefix=$(out)" ];
+
+  dontInstall = true;
 
   enableParallelBuilding = true;