diff --git a/lib/image-builder/default.nix b/lib/image-builder/default.nix deleted file mode 100644 index cae1f18a..00000000 --- a/lib/image-builder/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ lib, newScope }: - -let - inherit (lib) makeScope; -in -makeScope newScope (self: - let - inherit (self) callPackage; - in - # Note: Prefer using `self.something.deep` rather than making `something` a - # recursive set. Otherwise it won't override as expected. - { - makeFilesystem = callPackage ./makeFilesystem.nix {}; - - # All known supported filesystems for image generation. - # Use stand-alone (outside of a disk image) is supported. - fileSystem = { - makeExt4 = callPackage ./makeExt4.nix {}; - makeBtrfs = callPackage ./makeBtrfs.nix {}; - makeFAT32 = callPackage ./makeFAT32.nix {}; - # Specialization of `makeFAT32` with (1) filesystemType showing as ESP, - # and (2) the name defaults to ESP. - makeESP = args: self.fileSystem.makeFAT32 ({ name = "ESP"; filesystemType = "ESP"; } // args); - }; - - gap = length: { - inherit length; - isGap = true; - }; - - # All supported disk formats for image generation. - diskImage = { - makeMBR = callPackage ./makeMBR.nix {}; - makeGPT = callPackage ./makeGPT.nix {}; - }; - - # Don't do maths yourselves, just use the helpers. - # Yes, this is the bibytes family of units. - # (This is fine as rec; it won't be overriden.) - size = rec { - TiB = x: 1024 * (GiB x); - GiB = x: 1024 * (MiB x); - MiB = x: 1024 * (KiB x); - KiB = x: 1024 * x; - }; - } -) diff --git a/lib/image-builder/in-depth-tests/README.md b/lib/image-builder/in-depth-tests/README.md deleted file mode 100644 index 09a6af11..00000000 --- a/lib/image-builder/in-depth-tests/README.md +++ /dev/null @@ -1,19 +0,0 @@ -In-depth tests -============== - -Those are rather bulky integration-type tests. They are not ran by default, but -should be used to better test the image builder infrastructure. - -Changes to the infra should be passed through this test suite in addition to the -slimmer usual tests suite. - -> **Tip:** -> -> From the image-builder infra directory, run the following. -> -> ``` -> nix-build in-depth-tests/[...].nix -I nixpkgs-overlays=$PWD/lib/tests/test-overlay.nix -> ``` -> -> This allows you to track the bigger builds more easily. - diff --git a/lib/image-builder/in-depth-tests/raspi-like.nix b/lib/image-builder/in-depth-tests/raspi-like.nix deleted file mode 100644 index 429a6272..00000000 --- a/lib/image-builder/in-depth-tests/raspi-like.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ pkgs ? import {} }: - -let - inherit (pkgs) imageBuilder ubootTools; - - configTxt = pkgs.writeText "config.txt" '' - kernel=u-boot-rpi3.bin - - # Boot in 64-bit mode. - arm_control=0x200 - - # Prevent the firmware from smashing the framebuffer setup done by the mainline kernel - # when attempting to show low-voltage or overtemperature warnings. - avoid_warnings=1 - ''; - - scrTxt = pkgs.writeText "uboot.scr.txt" '' - echo - echo - echo - echo - - echo " **" - echo " ** Image Builder sanity checks!" - echo " ** This will appear to freeze since the kernel is not built with the VC4 kernel built-in." - echo " ** Stay assured, the kernel should be panicking anyway since there is no initrd, no init, and no useful FS." - echo " **" - - echo - - load $devtype $devnum:$distro_bootpart $kernel_addr_r boot/kernel - booti $kernel_addr_r - ''; - - scr = pkgs.runCommand "uboot-script" {} '' - mkdir -p $out - ${ubootTools}/bin/mkimage \ - -A arm64 \ - -O linux \ - -T script \ - -C none \ - -n ${scrTxt} -d ${scrTxt} \ - $out/boot.scr - ''; - - # Here, we built a fictitious system cloning the AArch64 sd-image setup. - # The chosen derivations are known to build fully when cross-compiled. - pkgsAArch64 = (if pkgs.stdenv.isAarch64 then pkgs else pkgs.pkgsCross.aarch64-multiplatform); - - # The kernel for the device. - kernel = pkgsAArch64.linux_rpi; - - # TODO: for completeness' sake an initrd with the vc4 driver should be built - # to show that this works as a self-contained demo. -in - -with imageBuilder; - -/** - * This disk image is built to be functionally compatible with the usual `sd_image` - * from NixOS, but *it is not* an actual `sd_image` compatible system. - * - * The main thing it aims to do is *minimally* create a bootable system. - */ -diskImage.makeMBR { - name = "diskimage"; - diskID = "01234567"; - - partitions = [ - (gap (size.MiB 10)) - (fileSystem.makeFAT32 { - # Size-less - name = "FIRMWARE"; - partitionID = "ABADF00D"; - extraPadding = size.MiB 10; - populateCommands = '' - ( - src=${pkgsAArch64.raspberrypifw}/share/raspberrypi/boot - cp $src/bootcode.bin $src/fixup*.dat $src/start*.elf ./ - cp ${pkgsAArch64.ubootRaspberryPi3_64bit}/u-boot.bin ./u-boot-rpi3.bin - cp ${configTxt} ./config.txt - ) - ''; - }) - (fileSystem.makeExt4 { - bootable = true; - name = "NIXOS"; - partitionID = "44444444-4444-4444-8888-888888888888"; - populateCommands = '' - mkdir -p ./boot - cp ${kernel}/Image ./boot/kernel - cp ${scr}/boot.scr ./boot/boot.scr - ''; - }) - ]; -} diff --git a/lib/image-builder/in-depth-tests/size/ext4.nix b/lib/image-builder/in-depth-tests/size/ext4.nix deleted file mode 100644 index 14906c56..00000000 --- a/lib/image-builder/in-depth-tests/size/ext4.nix +++ /dev/null @@ -1,87 +0,0 @@ -# Ensures we can fit stuff in an ext4 image. -{ pkgs ? import {} }: - -let - inherit (pkgs) imageBuilder; - makeNull = size: let - filename = "null.img"; - filesystemType = "FAT32"; # meh, good enough - in - '' - mkdir -p $out - dd if=/dev/zero of=./${toString size}.img bs=${toString size} count=1 - ''; -in - -with imageBuilder; - -{ - eight = fileSystem.makeExt4 { - name = "eight"; - partitionID = "44444444-4444-4444-0000-000000000008"; - populateCommands = '' - ${makeNull (imageBuilder.size.MiB 8)} - ''; - }; - - eleven = fileSystem.makeExt4 { - name = "eleven"; - partitionID = "44444444-4444-4444-0000-000000000011"; - populateCommands = '' - ${makeNull (imageBuilder.size.MiB 11)} - ''; - }; - - sixteen = fileSystem.makeExt4 { - name = "sixteen"; - partitionID = "44444444-4444-4444-0000-000000000016"; - populateCommands = '' - ${makeNull (imageBuilder.size.MiB 16)} - ''; - }; - - one_twenty_eight = fileSystem.makeExt4 { - name = "one_twenty_eight"; - partitionID = "44444444-4444-4444-0000-000000000128"; - populateCommands = '' - ${makeNull (imageBuilder.size.MiB 128)} - ''; - }; - - two_fifty_six = fileSystem.makeExt4 { - name = "two_fifty_six"; - partitionID = "44444444-4444-4444-0000-000000000256"; - populateCommands = '' - ${makeNull (imageBuilder.size.MiB 256)} - ''; - }; - - five_twelve = fileSystem.makeExt4 { - name = "five_twelve"; - partitionID = "44444444-4444-4444-0000-000000000512"; - populateCommands = '' - ${makeNull (imageBuilder.size.MiB 512)} - ''; - }; - - with_space = fileSystem.makeExt4 { - name = "with_space"; - partitionID = "44444444-4444-4444-0000-000000000005"; - populateCommands = '' - ${makeNull (imageBuilder.size.MiB 5)} - ''; - extraPadding = size.MiB 10; - }; - - # Fills 512 MiB (the downard slump in the high fudge factor) with 512 1MiB - # files so we ensure the filesystem overhead is accounted for. - multiple-files = fileSystem.makeExt4 { - name = "multiple-files"; - partitionID = "44444444-4444-4444-0000-000000000512"; - populateCommands = '' - for i in {1..512}; do - dd if=/dev/zero of=./$i.img bs=${toString (imageBuilder.size.MiB 1)} count=1 - done - ''; - }; -} diff --git a/lib/image-builder/lib/overlay.nix b/lib/image-builder/lib/overlay.nix deleted file mode 100644 index 7fd57631..00000000 --- a/lib/image-builder/lib/overlay.nix +++ /dev/null @@ -1,5 +0,0 @@ -[ - (self: super: { imageBuilder = self.callPackage ../. {}; }) - # All the software will be upstreamed with NixOS when upstreaming the library. - (import ../../../overlay/overlay.nix) -] diff --git a/lib/image-builder/lib/tests/test-overlay.nix b/lib/image-builder/lib/tests/test-overlay.nix deleted file mode 100644 index 9825b09c..00000000 --- a/lib/image-builder/lib/tests/test-overlay.nix +++ /dev/null @@ -1,18 +0,0 @@ -# Adds the imageBuilder overlay. -(import ../overlay.nix) ++ -[ - # Makes the imageBuilder build impure to force rebuilds to more easily test - # reproducibility of outputs. - (self: super: - let - inherit (self.lib.attrsets) mapAttrs; - in - { - imageBuilder = super.imageBuilder.overrideScope'(self: super: { - makeFilesystem = args: super.makeFilesystem (args // { - REBUILD = "# ${toString builtins.currentTime}"; - }); - }); - } - ) -] diff --git a/lib/image-builder/lib/tests/verify.rb b/lib/image-builder/lib/tests/verify.rb deleted file mode 100755 index fc110dba..00000000 --- a/lib/image-builder/lib/tests/verify.rb +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env ruby - -require "shellwords" -require "open3" - -# Test harness to validate results of a `nix-build`. -# This script will `#load()` the given script. - -if ARGV.length < 2 then - abort "Usage: verify.rb