diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-05-25 22:46:41 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-05-31 10:27:33 +0000 |
commit | d0d7906e72b9c5fac792c56eae89a62b349164ba (patch) | |
tree | f1000376a09c07e74c01ba102f6c083d5b89602d | |
parent | 75a1ac3d62bf8c641e7145f46ebd6e9d01e6d3dc (diff) | |
download | spectrum-d0d7906e72b9c5fac792c56eae89a62b349164ba.tar spectrum-d0d7906e72b9c5fac792c56eae89a62b349164ba.tar.gz spectrum-d0d7906e72b9c5fac792c56eae89a62b349164ba.tar.bz2 spectrum-d0d7906e72b9c5fac792c56eae89a62b349164ba.tar.lz spectrum-d0d7906e72b9c5fac792c56eae89a62b349164ba.tar.xz spectrum-d0d7906e72b9c5fac792c56eae89a62b349164ba.tar.zst spectrum-d0d7906e72b9c5fac792c56eae89a62b349164ba.zip |
host/rootfs: switch to EROFS
Signed-off-by: Alyssa Ross <hi@alyssa.is>
-rw-r--r-- | host/initramfs/default.nix | 2 | ||||
-rwxr-xr-x | host/initramfs/etc/init | 2 | ||||
-rwxr-xr-x | host/initramfs/etc/probe | 5 | ||||
-rw-r--r-- | host/rootfs/Makefile | 19 | ||||
-rw-r--r-- | host/rootfs/default.nix | 21 | ||||
-rw-r--r-- | host/rootfs/etc/s6-rc/ext/up | 3 |
6 files changed, 27 insertions, 25 deletions
diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix index 899907e..fa11aef 100644 --- a/host/initramfs/default.nix +++ b/host/initramfs/default.nix @@ -21,7 +21,7 @@ let modules = makeModulesClosure { inherit (rootfs) firmware kernel; rootModules = with rootfs.nixosAllHardware.config.boot.initrd; - availableKernelModules ++ kernelModules ++ [ "dm-verity" "loop" ]; + availableKernelModules ++ kernelModules ++ [ "dm-verity" "erofs" "loop" ]; }; packages = [ diff --git a/host/initramfs/etc/init b/host/initramfs/etc/init index 5f347a5..2ec8d91 100755 --- a/host/initramfs/etc/init +++ b/host/initramfs/etc/init @@ -23,7 +23,7 @@ background { } importas -iu mdevd_pid ! -if { modprobe ext4 } +if { modprobe erofs } # Do a blocking read on the fifo to wait for mdevd to find the # partition. diff --git a/host/initramfs/etc/probe b/host/initramfs/etc/probe index 064b792..4cbd00d 100755 --- a/host/initramfs/etc/probe +++ b/host/initramfs/etc/probe @@ -10,7 +10,10 @@ if -n { backtick -E type { lsblk -lnpo PARTTYPE $mdev } test $type = 56a3bbc3-aefa-43d9-a64d-7b3fd59bbc4e } - if { modprobe loop } + if { + forx -pE module { ext4 loop } + modprobe $module + } backtick -E uuid { lsblk -lnpo PARTUUID $mdev } if { mkdir -p /mnt/${uuid} } if { mount $mdev /mnt/${uuid} } diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile index 73ac361..06384de 100644 --- a/host/rootfs/Makefile +++ b/host/rootfs/Makefile @@ -3,7 +3,7 @@ include ../../lib/common.mk -dest = build/rootfs.ext4 +dest = build/rootfs.erofs FILES = \ etc/fonts/fonts.conf \ @@ -41,21 +41,15 @@ LINKS = bin sbin BUILD_FILES = build/etc/mdev/modalias.sh build/etc/s6-rc -$(dest): build/rootfs.tar - $(TAR2EXT4) -i build/rootfs.tar -o $@ +$(dest): ../../scripts/make-erofs.sh $(FILES) $(BUILD_FILES) build/empty + ../../scripts/make-erofs.sh -- $@ $(PACKAGES) \ + $$(for file in $(FILES) $(LINKS); do printf '%s %s ' $$file $$file; done) \ + $$(for file in $(BUILD_FILES); do printf '%s %s ' $$file $${file#build/}; done) \ + $$(printf 'build/empty %s ' $(DIRS)) build/empty: mkdir -p $@ -build/rootfs.tar: build/empty $(PACKAGES_TAR) $(FILES) $(BUILD_FILES) - cp --no-preserve=mode -f $(PACKAGES_TAR) $@ - tar $(TARFLAGS) --append -f $@ $(FILES) $(LINKS) - echo $(BUILD_FILES) | cut -d/ -f2 | \ - tar $(TARFLAGS) --append -f $@ -C build -T - - for m in $(DIRS); do \ - tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," build/empty ; \ - done - build/etc/mdev/modules.map: scripts/modprobe/gen_modules.map.awk mkdir -p $$(dirname $@) awk -f scripts/modprobe/gen_modules.map.awk \ @@ -112,6 +106,7 @@ build/etc/s6-rc: $(S6_RC_FILES) exit=$$?; rm -r $$dir; exit $$exit clean: + chmod -R +w build rm -rf build .PHONY: clean diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix index 9d1dea7..db3cd77 100644 --- a/host/rootfs/default.nix +++ b/host/rootfs/default.nix @@ -15,7 +15,7 @@ in pkgs.pkgsStatic.callPackage ( -{ lib, stdenvNoCC, nixos, runCommand, writeReferencesToFile, s6-rc, tar2ext4 +{ lib, stdenvNoCC, nixos, runCommand, writeReferencesToFile, erofs-utils, s6-rc , busybox, cloud-hypervisor, cryptsetup, execline, e2fsprogs, jq, kmod , mdevd, s6, s6-linux-init, socat, util-linuxMinimal, virtiofsd, xorg }: @@ -118,12 +118,6 @@ let # https://lore.kernel.org/util-linux/87zgrl6ufb.fsf@alyssa.is/ ln -s ${util-linuxMinimal}/bin/{findfs,lsblk} $out/usr/bin ''; - - packagesTar = runCommand "packages.tar" {} '' - cd ${packagesSysroot} - tar -cf $out --sort=name --mtime=@0 --verbatim-files-from \ - -T ${writeReferencesToFile packagesSysroot} . - ''; in stdenvNoCC.mkDerivation { @@ -132,11 +126,20 @@ stdenvNoCC.mkDerivation { inherit src; sourceRoot = "source/host/rootfs"; - nativeBuildInputs = [ lseek s6-rc tar2ext4 ]; + nativeBuildInputs = [ erofs-utils lseek s6-rc ]; MODULES_ALIAS = "${kernel}/lib/modules/${kernel.modDirVersion}/modules.alias"; MODULES_ORDER = "${kernel}/lib/modules/${kernel.modDirVersion}/modules.order"; - PACKAGES_TAR = packagesTar; + + PACKAGES = [ packagesSysroot "/" ]; + + shellHook = '' + PACKAGES+=" $(sed p ${writeReferencesToFile packagesSysroot} | tr '\n' ' ')" + ''; + + preBuild = '' + runHook shellHook + ''; makeFlags = [ "dest=$(out)" ]; diff --git a/host/rootfs/etc/s6-rc/ext/up b/host/rootfs/etc/s6-rc/ext/up index 24a32ea..741f61f 100644 --- a/host/rootfs/etc/s6-rc/ext/up +++ b/host/rootfs/etc/s6-rc/ext/up @@ -1,6 +1,7 @@ # SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> +# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is> +if { modprobe ext4 } if { /etc/mdev/wait ext } foreground { fsck.ext4 -fp /dev/ext } foreground { resize2fs /dev/ext } |