diff --git a/modules/ext4fs.nix b/modules/ext4fs.nix index e31dcce..db3fd0f 100644 --- a/modules/ext4fs.nix +++ b/modules/ext4fs.nix @@ -30,7 +30,7 @@ in } '' cp -a ${o.rootfsFiles} tmp ${if config.boot.loader.extlinux.enable - then "(cd tmp && ln -s ${o.extlinux} boot)" + then "(cd tmp && chmod -R +w . && rmdir boot && cp -a ${o.extlinux} boot)" else "" } size=$(du -s --apparent-size --block-size 1024 tmp |cut -f1) diff --git a/modules/outputs/diskimage.nix b/modules/outputs/diskimage.nix new file mode 100644 index 0000000..a29db92 --- /dev/null +++ b/modules/outputs/diskimage.nix @@ -0,0 +1,52 @@ +{ + config +, pkgs +, lib +, ... +}: +let + inherit (lib) mkOption types concatStringsSep; + o = config.system.outputs; + phram_address = lib.toHexString (config.hardware.ram.startAddress + 256 * 1024 * 1024); +in { +# imports = [ ./flashimage.nix ]; + options.system.outputs = { + diskimage = mkOption { + type = types.package; + description = '' + diskimage + ********* + + This creates a disk image file with a partition table containing + the contents of ``outputs.rootfs`` as its only partition. + ''; + }; + vmdisk = mkOption { type = types.package; }; + }; + + config = { + system.outputs = { + diskimage = + let + o = config.system.outputs; + in pkgs.runCommand "diskimage" { + depsBuildBuild = [ pkgs.pkgsBuildBuild.util-linux ]; + } '' + # leave 4 sectors at start for partition table + # and alignment to 2048 bytes (does that help?) + dd if=${o.rootfs} of=$out bs=512 seek=4 conv=sync + echo '4,-,L,*' | sfdisk $out + ''; + vmdisk = pkgs.runCommand "vmdisk" {} '' + mkdir $out + cd $out + ln -s ${o.diskimage} ./diskimage + cat > run.sh < kernel.gz - cat > extlinux.conf << _EOF + mkdir extlinux + cat > extlinux/extlinux.conf << _EOF menu title Liminix timeout 100 label Liminix - kernel kernel.gz - initrd initramfs - fdt dtb + kernel /boot/kernel.gz + initrd /boot/initramfs append ${cmdline} + # fdt /boot/dtb _EOF ''; }; diff --git a/overlay.nix b/overlay.nix index 8a89071..4bea4ac 100644 --- a/overlay.nix +++ b/overlay.nix @@ -210,6 +210,8 @@ extraPkgs // { extraConfig = '' CONFIG_CMD_UBI=y CONFIG_CMD_UBIFS=y + CONFIG_BOOTSTD=y + CONFIG_BOOTMETH_DISTRO=y ''; }; } diff --git a/pkgs/run-liminix-vm/run-liminix-vm.fnl b/pkgs/run-liminix-vm/run-liminix-vm.fnl index 50be230..9d059cf 100644 --- a/pkgs/run-liminix-vm/run-liminix-vm.fnl +++ b/pkgs/run-liminix-vm/run-liminix-vm.fnl @@ -36,7 +36,9 @@ (match args ["--background" dir & rest] (assoc (parse-args rest) :background dir) ["--u-boot" bin & rest] - (assoc (parse-args rest) :u-boot (pad-file bin (* 4 1024) "\xff")) + (assoc (parse-args rest) :u-boot (pad-file bin (* 64 1024) "\xff")) + ["--disk-image" image & rest ] (assoc (parse-args rest) + :disk-image (pad-file image 1024)) ["--arch" arch & rest] (assoc (parse-args rest) :arch arch) ["--phram-address" addr & rest] (assoc (parse-args rest) :phram-address addr) ["--lan" spec & rest] (assoc (parse-args rest) :lan spec) @@ -73,9 +75,12 @@ ]) -(fn bootable [cmdline uboot] +(fn bootable [cmdline uboot disk] (if uboot - ["-drive" (.. "if=pflash,format=raw,file=" uboot )] + ["-drive" (.. "if=pflash,format=raw,file=" uboot ) + "-drive" (.. "if=none,format=raw,id=hd0,file=" disk) + "-device" "virtio-blk-device,drive=hd0" + ] (let [cmdline (.. cmdline " mem=256M liminix mtdparts=phram0:16M(rootfs) phram.phram=phram0," options.phram-address ",16Mi,65536 root=/dev/mtdblock0")] ["-kernel" options.kernel "-append" cmdline]))) @@ -94,13 +99,13 @@ "-echr" "16" "-device" (.. "loader,file=" options.rootfs ",addr=" options.phram-address) - ]) (appendm (if options.background (background options.background) ["-serial" "mon:stdio"])) - (appendm (bootable (or options.command-line "") options.u-boot)) + (appendm (bootable (or options.command-line "") + options.u-boot options.disk-image)) (appendm (access-net)) (appendm (local-net options.lan)) (appendm ["-display" "none"]))) @@ -113,3 +118,4 @@ (if options.rootfs (unlink options.rootfs)) (if options.u-boot (unlink options.u-boot)) +(if options.disk-image (unlink options.disk-image))