2023-12-18 23:42:29 +01:00
|
|
|
{ config, pkgs, lib, lim, ... } :
|
|
|
|
let
|
|
|
|
inherit (pkgs.pseudofile) dir symlink;
|
|
|
|
dts = pkgs.runCommand "qemu.dts" {
|
|
|
|
nativeBuildInputs = with pkgs.pkgsBuildBuild; [ dtc qemu ];
|
|
|
|
} ''
|
2023-12-19 13:12:12 +01:00
|
|
|
qemu-system-${pkgs.stdenv.hostPlatform.qemuArch} \
|
|
|
|
-machine virt -machine dumpdtb=tmp.dtb
|
2023-12-18 23:42:29 +01:00
|
|
|
dtc -I dtb -O dts -o $out tmp.dtb
|
2023-12-19 13:12:12 +01:00
|
|
|
# https://stackoverflow.com/a/69890137,
|
|
|
|
# XXX try fdtput $out -p -t s /pl061@9030000 status disabled
|
|
|
|
# instead of using sed
|
|
|
|
sed -i $out -e 's/compatible = "arm,pl061.*/status = "disabled";/g'
|
2023-12-18 23:42:29 +01:00
|
|
|
'';
|
|
|
|
in {
|
|
|
|
imports = [
|
|
|
|
../../modules/outputs/ext4fs.nix
|
|
|
|
../../modules/outputs/tftpboot.nix
|
|
|
|
];
|
|
|
|
config = {
|
2023-12-21 20:17:14 +01:00
|
|
|
# use extracted dts if it was null in the device
|
|
|
|
# definition, use actual dts if provided
|
|
|
|
hardware.dts.src = lib.mkOverride 500 dts;
|
2023-12-18 23:42:29 +01:00
|
|
|
boot.tftp = {
|
2023-12-21 20:17:14 +01:00
|
|
|
loadAddress =
|
|
|
|
let offsets = {
|
|
|
|
mips = "0x88000000";
|
|
|
|
arm = "0x44000000";
|
|
|
|
aarch64 = "0x44000000";
|
|
|
|
};
|
|
|
|
in lim.parseInt offsets.${pkgs.stdenv.hostPlatform.qemuArch} ;
|
2023-12-18 23:42:29 +01:00
|
|
|
serverip = "10.0.2.2";
|
|
|
|
ipaddr = "10.0.2.15";
|
|
|
|
};
|
|
|
|
boot.imageFormat = "fit";
|
|
|
|
rootfsType = "ext4";
|
|
|
|
filesystem = dir {
|
|
|
|
hello = {
|
|
|
|
type = "f";
|
|
|
|
uid = 7;
|
|
|
|
gid = 24;
|
|
|
|
file = "hello world";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|