diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-01-20 16:50:24 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2022-02-14 12:21:49 +0000 |
commit | e1264c309f534af2f9ce81a7d7f056faff6e0787 (patch) | |
tree | cc57edb473b19267f1c2affc572fd71364bac36c | |
parent | 2ae30ffe993f314898d75c2bbeede32312e55f82 (diff) | |
download | spectrum-e1264c309f534af2f9ce81a7d7f056faff6e0787.tar spectrum-e1264c309f534af2f9ce81a7d7f056faff6e0787.tar.gz spectrum-e1264c309f534af2f9ce81a7d7f056faff6e0787.tar.bz2 spectrum-e1264c309f534af2f9ce81a7d7f056faff6e0787.tar.lz spectrum-e1264c309f534af2f9ce81a7d7f056faff6e0787.tar.xz spectrum-e1264c309f534af2f9ce81a7d7f056faff6e0787.tar.zst spectrum-e1264c309f534af2f9ce81a7d7f056faff6e0787.zip |
img/installer: separate from combined image
This way, we don't need to a build a whole huge image to test changes to the installer system. In fact, we don't need to build an image for it at all — we can just run it in a VM with root on 9p.
-rw-r--r-- | img/combined/default.nix (renamed from installer/default.nix) | 69 | ||||
-rw-r--r-- | img/combined/eosimages.nix | 18 | ||||
-rw-r--r-- | img/combined/grub.cfg.in (renamed from installer/grub.cfg.in) | 0 | ||||
-rw-r--r-- | img/combined/run-vm.nix (renamed from installer/run-vm.nix) | 0 | ||||
-rw-r--r-- | img/installer/app/0001-gpt-disable-gpt-partition-attribute-55-check.patch (renamed from installer/app/0001-gpt-disable-gpt-partition-attribute-55-check.patch) | 0 | ||||
-rw-r--r-- | img/installer/app/0002-gpt-disable-partition-table-CRC-check.patch (renamed from installer/app/0002-gpt-disable-partition-table-CRC-check.patch) | 0 | ||||
-rw-r--r-- | img/installer/app/0003-install-remove-Endless-OS-ad.patch (renamed from installer/app/0003-install-remove-Endless-OS-ad.patch) | 0 | ||||
-rw-r--r-- | img/installer/app/0004-finished-don-t-run-eos-diagnostics.patch (renamed from installer/app/0004-finished-don-t-run-eos-diagnostics.patch) | 0 | ||||
-rw-r--r-- | img/installer/app/0005-finished-promote-spectrum-not-the-Endless-forum.patch (renamed from installer/app/0005-finished-promote-spectrum-not-the-Endless-forum.patch) | 0 | ||||
-rw-r--r-- | img/installer/app/default.nix (renamed from installer/app/default.nix) | 0 | ||||
-rw-r--r-- | img/installer/app/vendor-customer-support.ini (renamed from installer/app/vendor-customer-support.ini) | 0 | ||||
-rw-r--r-- | img/installer/configuration.nix (renamed from installer/configuration.nix) | 4 | ||||
-rw-r--r-- | img/installer/default.nix | 24 | ||||
-rw-r--r-- | img/installer/run-vm.nix | 44 | ||||
-rw-r--r-- | img/installer/seat.rules (renamed from installer/seat.rules) | 0 | ||||
-rw-r--r-- | img/live/Makefile (renamed from live/Makefile) | 0 | ||||
-rw-r--r-- | img/live/default.nix (renamed from live/default.nix) | 8 | ||||
-rw-r--r-- | img/live/etc/os-release (renamed from live/etc/os-release) | 0 | ||||
-rw-r--r-- | img/live/shell.nix (renamed from live/shell.nix) | 0 |
19 files changed, 121 insertions, 46 deletions
diff --git a/installer/default.nix b/img/combined/default.nix index 0818091..55d7869 100644 --- a/installer/default.nix +++ b/img/combined/default.nix @@ -1,25 +1,43 @@ # SPDX-License-Identifier: MIT -# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is> +# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> # SPDX-FileCopyrightText: 2021 Yureka <yuka@yuka.dev> { pkgs ? import <nixpkgs> {} }: with pkgs; let - inherit (builtins) head match storeDir; + inherit (builtins) storeDir; inherit (pkgs.lib) removePrefix; - inherit (nixos ./configuration.nix) config; - image = import ../live { inherit pkgs; }; + eosimages = import ./eosimages.nix { inherit pkgs; }; + + installerPartUuid = "6e23b026-9f1e-479d-8a58-a0cda382e1ce"; + installer = import ../installer { + inherit pkgs; + + extraConfig = { + boot.initrd.availableKernelModules = [ "squashfs" ]; + + fileSystems.${storeDir} = { + device = "/dev/disk/by-partuuid/${installerPartUuid}"; + }; + }; + }; + + rootfs = runCommand "installer.img" { + nativeBuildInputs = [ squashfs-tools-ng ]; + } '' + sed 's,^${storeDir}/,,' ${writeReferencesToFile installer.store} | + tar -C ${storeDir} -c --verbatim-files-from -T - \ + --owner 0 --group 0 | tar2sqfs $out + ''; grub = grub2_efi; grubCfg = substituteAll { src = ./grub.cfg.in; - linux = removePrefix storeDir "${config.boot.kernelPackages.kernel}/${config.system.boot.loader.kernelFile}"; - initrd = removePrefix storeDir "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}"; - kernelParams = toString ([ - "init=${config.system.build.toplevel}/init" - ] ++ config.boot.kernelParams); + linux = removePrefix storeDir installer.kernel; + initrd = removePrefix storeDir installer.initramfs; + inherit (installer) kernelParams; }; esp = runCommand "esp.img" { @@ -50,35 +68,10 @@ let fsck.vfat -n $out ''; - - installer = runCommand "installer.img" { - nativeBuildInputs = [ squashfs-tools-ng ]; - } '' - sed 's,^${storeDir}/,,' ${writeReferencesToFile config.system.build.toplevel} | - tar -C ${storeDir} -c --verbatim-files-from -T - \ - --owner 0 --group 0 | tar2sqfs $out - ''; - - storeDev = config.fileSystems."/nix/store".device; - installerUuid = head (match "/dev/disk/by-partuuid/(.*)" storeDev); - - eosimages = runCommand "eosimages.img" { - nativeBuildInputs = [ e2fsprogs tar2ext4 ]; - imageName = "Spectrum-0.0-x86_64-generic.0.Live.img"; - passthru = { inherit image; }; - } '' - mkdir dir - cd dir - ln -s ${image} Spectrum-0.0-x86_64-generic.0.Live.img - sha256sum $imageName > $imageName.sha256 - tar -chf $NIX_BUILD_TOP/eosimages.tar * - tar2ext4 -i $NIX_BUILD_TOP/eosimages.tar -o $out - e2label $out eosimages - ''; in runCommand "spectrum-installer" { - nativeBuildInputs = [ dosfstools grub jq kmod util-linux systemdMinimal ]; + nativeBuildInputs = [ grub jq util-linux systemdMinimal ]; passthru = { inherit esp installer eosimages; }; } '' blockSize() { @@ -92,18 +85,18 @@ runCommand "spectrum-installer" { } espSize="$(blockSize ${esp})" - installerSize="$(blockSize ${installer})" + installerSize="$(blockSize ${rootfs})" eosimagesSize="$(blockSize ${eosimages})" truncate -s $(((3 * 2048 + $espSize + $installerSize + $eosimagesSize) * 512)) $out sfdisk $out <<EOF label: gpt size=$espSize, type=U - size=$installerSize, type=L, uuid=${installerUuid} + size=$installerSize, type=L, uuid=${installerPartUuid} size=$eosimagesSize, type=56a3bbc3-aefa-43d9-a64d-7b3fd59bbc4e EOF fillPartition $out 0 ${esp} - fillPartition $out 1 ${installer} + fillPartition $out 1 ${rootfs} fillPartition $out 2 ${eosimages} '' diff --git a/img/combined/eosimages.nix b/img/combined/eosimages.nix new file mode 100644 index 0000000..4ec28e5 --- /dev/null +++ b/img/combined/eosimages.nix @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> + +{ pkgs ? import <nixpkgs> {} }: with pkgs; + +runCommand "eosimages.img" { + nativeBuildInputs = [ e2fsprogs tar2ext4 ]; + imageName = "Spectrum-0.0-x86_64-generic.0.Live.img"; + image = import ../live { inherit pkgs; }; +} '' + mkdir dir + cd dir + ln -s $image Spectrum-0.0-x86_64-generic.0.Live.img + sha256sum $imageName > $imageName.sha256 + tar -chf $NIX_BUILD_TOP/eosimages.tar * + tar2ext4 -i $NIX_BUILD_TOP/eosimages.tar -o $out + e2label $out eosimages +'' diff --git a/installer/grub.cfg.in b/img/combined/grub.cfg.in index 1a91a75..1a91a75 100644 --- a/installer/grub.cfg.in +++ b/img/combined/grub.cfg.in diff --git a/installer/run-vm.nix b/img/combined/run-vm.nix index 3d6b0eb..3d6b0eb 100644 --- a/installer/run-vm.nix +++ b/img/combined/run-vm.nix diff --git a/installer/app/0001-gpt-disable-gpt-partition-attribute-55-check.patch b/img/installer/app/0001-gpt-disable-gpt-partition-attribute-55-check.patch index 2e37268..2e37268 100644 --- a/installer/app/0001-gpt-disable-gpt-partition-attribute-55-check.patch +++ b/img/installer/app/0001-gpt-disable-gpt-partition-attribute-55-check.patch diff --git a/installer/app/0002-gpt-disable-partition-table-CRC-check.patch b/img/installer/app/0002-gpt-disable-partition-table-CRC-check.patch index 2075067..2075067 100644 --- a/installer/app/0002-gpt-disable-partition-table-CRC-check.patch +++ b/img/installer/app/0002-gpt-disable-partition-table-CRC-check.patch diff --git a/installer/app/0003-install-remove-Endless-OS-ad.patch b/img/installer/app/0003-install-remove-Endless-OS-ad.patch index 33abd60..33abd60 100644 --- a/installer/app/0003-install-remove-Endless-OS-ad.patch +++ b/img/installer/app/0003-install-remove-Endless-OS-ad.patch diff --git a/installer/app/0004-finished-don-t-run-eos-diagnostics.patch b/img/installer/app/0004-finished-don-t-run-eos-diagnostics.patch index a4827ba..a4827ba 100644 --- a/installer/app/0004-finished-don-t-run-eos-diagnostics.patch +++ b/img/installer/app/0004-finished-don-t-run-eos-diagnostics.patch diff --git a/installer/app/0005-finished-promote-spectrum-not-the-Endless-forum.patch b/img/installer/app/0005-finished-promote-spectrum-not-the-Endless-forum.patch index 590635d..590635d 100644 --- a/installer/app/0005-finished-promote-spectrum-not-the-Endless-forum.patch +++ b/img/installer/app/0005-finished-promote-spectrum-not-the-Endless-forum.patch diff --git a/installer/app/default.nix b/img/installer/app/default.nix index 26f0b81..26f0b81 100644 --- a/installer/app/default.nix +++ b/img/installer/app/default.nix diff --git a/installer/app/vendor-customer-support.ini b/img/installer/app/vendor-customer-support.ini index 4c4e650..4c4e650 100644 --- a/installer/app/vendor-customer-support.ini +++ b/img/installer/app/vendor-customer-support.ini diff --git a/installer/configuration.nix b/img/installer/configuration.nix index 2be22cc..b7abc42 100644 --- a/installer/configuration.nix +++ b/img/installer/configuration.nix @@ -12,7 +12,6 @@ in boot.consoleLogLevel = 2; boot.kernelParams = [ "udev.log_priority=5" ]; - boot.initrd.availableKernelModules = [ "squashfs" ]; boot.initrd.verbose = false; boot.plymouth.enable = true; @@ -30,9 +29,6 @@ in ) {}; fileSystems."/" = { fsType = "tmpfs"; }; - fileSystems."/nix/store" = { - device = "/dev/disk/by-partuuid/6e23b026-9f1e-479d-8a58-a0cda382e1ce"; - }; services.cage.enable = true; services.cage.program = "gnome-image-installer"; diff --git a/img/installer/default.nix b/img/installer/default.nix new file mode 100644 index 0000000..ba97a53 --- /dev/null +++ b/img/installer/default.nix @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> + +{ pkgs ? import <nixpkgs> {}, extraConfig ? {} }: with pkgs; + +let + inherit (builtins) head match storeDir; + inherit (nixos { + imports = [ ./configuration.nix extraConfig ]; + }) config; +in + +{ + kernel = "${config.boot.kernelPackages.kernel}/${config.system.boot.loader.kernelFile}"; + + initramfs = "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}"; + + kernelParams = toString ([ + "init=${config.system.build.toplevel}/init" + ] ++ config.boot.kernelParams); + + store = writeReferencesToFile config.system.build.toplevel; +} + diff --git a/img/installer/run-vm.nix b/img/installer/run-vm.nix new file mode 100644 index 0000000..5ec7fee --- /dev/null +++ b/img/installer/run-vm.nix @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is> + +{ pkgs ? import <nixpkgs> {} }: + +let + inherit (builtins) storeDir; + inherit (pkgs) OVMF qemu_kvm writeShellScript; + inherit (pkgs.lib) escapeShellArg; + + eosimages = import ../combined/eosimages.nix { inherit pkgs; }; + + installer = import ./. { + inherit pkgs; + + extraConfig = { + boot.initrd.availableKernelModules = [ "9p" "9pnet_virtio" ]; + + fileSystems.${storeDir} = { + fsType = "9p"; + device = "store"; + # This can be removed when running Linux ≥5.15. + options = [ "msize=131072" ]; + }; + }; + }; +in + +writeShellScript "run-spectrum-installer-vm.sh" '' + img="$(mktemp spectrum-installer-target.XXXXXXXXXX.img)" + truncate -s 10G "$img" + exec 3<>"$img" + rm -f "$img" + exec ${qemu_kvm}/bin/.qemu-system-x86_64-wrapped -enable-kvm -cpu host -m 4G -machine q35 -snapshot \ + -display gtk,gl=on \ + -device virtio-vga-gl \ + -virtfs local,mount_tag=store,path=/nix/store,security_model=none,readonly=true \ + -drive file=${eosimages},format=raw,if=virtio,readonly=true \ + -drive file=/proc/self/fd/3,format=raw,if=virtio \ + -bios ${OVMF.fd}/FV/OVMF.fd \ + -kernel ${installer.kernel} \ + -initrd ${installer.initramfs} \ + -append ${escapeShellArg installer.kernelParams} +'' diff --git a/installer/seat.rules b/img/installer/seat.rules index b368068..b368068 100644 --- a/installer/seat.rules +++ b/img/installer/seat.rules diff --git a/live/Makefile b/img/live/Makefile index 8b06a17..8b06a17 100644 --- a/live/Makefile +++ b/img/live/Makefile diff --git a/live/default.nix b/img/live/default.nix index 9a9f575..c9cd354 100644 --- a/live/default.nix +++ b/img/live/default.nix @@ -6,12 +6,12 @@ let inherit (pkgs.lib) cleanSource cleanSourceWith; - extfs = pkgs.pkgsStatic.callPackage ../host/initramfs/extfs.nix { + extfs = pkgs.pkgsStatic.callPackage ../../host/initramfs/extfs.nix { inherit pkgs; }; - rootfs = import ../host/rootfs { inherit pkgs; }; - scripts = import ../scripts { inherit pkgs; }; - initramfs = import ../host/initramfs { inherit pkgs rootfs; }; + rootfs = import ../../host/rootfs { inherit pkgs; }; + scripts = import ../../scripts { inherit pkgs; }; + initramfs = import ../../host/initramfs { inherit pkgs rootfs; }; in with pkgs; diff --git a/live/etc/os-release b/img/live/etc/os-release index 7980810..7980810 100644 --- a/live/etc/os-release +++ b/img/live/etc/os-release diff --git a/live/shell.nix b/img/live/shell.nix index 66d273e..66d273e 100644 --- a/live/shell.nix +++ b/img/live/shell.nix |