diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-02-22 18:34:47 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-02-22 18:39:09 +0000 |
commit | c3fbeca89c23270314d1a24017160ff6fe7cc497 (patch) | |
tree | c5cc8a914335524cb34d28e40cd010a9faae0549 /vm | |
parent | 136428bf5b46f69ee85d579531b92299f964ba52 (diff) | |
download | spectrum-c3fbeca89c23270314d1a24017160ff6fe7cc497.tar spectrum-c3fbeca89c23270314d1a24017160ff6fe7cc497.tar.gz spectrum-c3fbeca89c23270314d1a24017160ff6fe7cc497.tar.bz2 spectrum-c3fbeca89c23270314d1a24017160ff6fe7cc497.tar.lz spectrum-c3fbeca89c23270314d1a24017160ff6fe7cc497.tar.xz spectrum-c3fbeca89c23270314d1a24017160ff6fe7cc497.tar.zst spectrum-c3fbeca89c23270314d1a24017160ff6fe7cc497.zip |
lib/common.mk: init
We can simplify our Makefiles a bit by moving some things into a library file. So far, I've done this for non-component-specific macros, and inference rules. Some tar2ext4 rules used a temporary file for the tar2ext4 invocation, and then moved the file into place when it was done, to prevent a half-built image sticking around if tar2ext4 died. According to POSIX, make should clean up any targets that didn't finish building if it's interrupted, so we should only end up with a half-built image if tar2ext4 crashes, e.g. due to running out of disk space. I think we should just ignore that possibility, since otherwise we'd have to write annoying make rules using temporary file names for every target, and if it does happen recovery is just a make clean away. With this, I've also made a small reorganisation. I got rid of the "nix" directory and created a "lib" directory, where I put eval-config.nix and the new common.mk file, since both are library code. checks.nix isn't really a library though, so I moved it into the "release" directory, since the only reference to it is in release.nix. Signed-off-by: Alyssa Ross <hi@alyssa.is>
Diffstat (limited to 'vm')
-rw-r--r-- | vm/app/catgirl.nix | 2 | ||||
-rw-r--r-- | vm/app/lynx.nix | 2 | ||||
-rw-r--r-- | vm/make-vm.nix | 2 | ||||
-rw-r--r-- | vm/sys/net/Makefile | 13 | ||||
-rw-r--r-- | vm/sys/net/default.nix | 2 | ||||
-rw-r--r-- | vm/sys/net/shell.nix | 2 |
6 files changed, 6 insertions, 17 deletions
diff --git a/vm/app/catgirl.nix b/vm/app/catgirl.nix index f74acc9..7cd76a9 100644 --- a/vm/app/catgirl.nix +++ b/vm/app/catgirl.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> -import ../../nix/eval-config.nix ({ config, ... }: +import ../../lib/eval-config.nix ({ config, ... }: import ../make-vm.nix { inherit config; } { providers.net = [ "netvm" ]; diff --git a/vm/app/lynx.nix b/vm/app/lynx.nix index d0b36a0..21cb56e 100644 --- a/vm/app/lynx.nix +++ b/vm/app/lynx.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> -import ../../nix/eval-config.nix ({ config, ... }: +import ../../lib/eval-config.nix ({ config, ... }: import ../make-vm.nix { inherit config; } { providers.net = [ "netvm" ]; diff --git a/vm/make-vm.nix b/vm/make-vm.nix index da3bdf7..d33cedd 100644 --- a/vm/make-vm.nix +++ b/vm/make-vm.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is> -import ../nix/eval-config.nix ({ config, ... }: +import ../lib/eval-config.nix ({ config, ... }: import ../vm-lib/make-vm.nix { inherit (config) pkgs; diff --git a/vm/sys/net/Makefile b/vm/sys/net/Makefile index 076e991..cb294a4 100644 --- a/vm/sys/net/Makefile +++ b/vm/sys/net/Makefile @@ -1,11 +1,7 @@ # SPDX-License-Identifier: EUPL-1.2+ # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> -# qemu-kvm is non-standard, but is present in at least Fedora and -# Nixpkgs. If you don't have qemu-kvm, you'll need to set e.g. -# QEMU_KVM = qemu-system-x86_64 -enable-kvm. -QEMU_KVM = qemu-kvm -CLOUD_HYPERVISOR = cloud-hypervisor +include ../../../lib/common.mk VMM = qemu @@ -36,13 +32,6 @@ build/host/data/netvm/blk/root.img: ../../../scripts/make-gpt.sh ../../../script build/rootfs.ext4:4f68bce3-e8cd-4db1-96e7-fbcaf984b709:ea21da27-0391-48da-9235-9d2ab2ca7844:root mv $@.tmp $@ -# tar2ext4 will leave half a filesystem behind if it's interrupted -# half way through. -build/rootfs.ext4: build/rootfs.tar - mkdir -p $$(dirname $@) - tar2ext4 -i build/rootfs.tar -o $@.tmp - mv $@.tmp $@ - VM_FILES = \ etc/dbus-1/system.conf \ etc/fstab \ diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix index a30f5f5..a7f6cc0 100644 --- a/vm/sys/net/default.nix +++ b/vm/sys/net/default.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> -import ../../../nix/eval-config.nix ( +import ../../../lib/eval-config.nix ( { config, src, terminfo ? config.pkgs.foot.terminfo, ... }: config.pkgs.pkgsStatic.callPackage ( diff --git a/vm/sys/net/shell.nix b/vm/sys/net/shell.nix index f298431..c0771e8 100644 --- a/vm/sys/net/shell.nix +++ b/vm/sys/net/shell.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is> -import ../../../nix/eval-config.nix ({ config, ... }: with config.pkgs; +import ../../../lib/eval-config.nix ({ config, ... }: with config.pkgs; (import ./. { inherit config; }).overrideAttrs ( { passthru ? {}, nativeBuildInputs ? [], ... }: |