2019-09-22 05:41:33 +03:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
device_config = config.mobile.device;
|
|
|
|
device_name = device_config.name;
|
|
|
|
hardware_config = config.mobile.hardware;
|
|
|
|
rootfs = config.system.build.rootfs;
|
|
|
|
enabled = config.mobile.system.type == "kernel-initrd";
|
|
|
|
|
|
|
|
kernel-initrd = pkgs.callPackage ../../systems/kernel-initrd.nix {
|
|
|
|
inherit device_config hardware_config;
|
|
|
|
initrd = config.system.build.initrd;
|
|
|
|
};
|
|
|
|
|
|
|
|
system = pkgs.linkFarm "${device_config.name}-build" [
|
|
|
|
{
|
|
|
|
name = "kernel-initrd";
|
|
|
|
path = "kernel-initrd";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "system";
|
|
|
|
path = rootfs;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = lib.mkMerge [
|
|
|
|
{ mobile.system.types = [ "kernel-initrd" ]; }
|
|
|
|
|
|
|
|
(lib.mkIf enabled {
|
2020-03-14 01:23:23 +03:00
|
|
|
system.build = rec {
|
2019-09-22 05:41:33 +03:00
|
|
|
inherit system;
|
|
|
|
mobile-installer = system;
|
2020-03-14 01:23:23 +03:00
|
|
|
default = vm;
|
2019-09-22 05:41:33 +03:00
|
|
|
vm = pkgs.writeScript "run-vm-${device_name}" ''
|
|
|
|
#!${pkgs.runtimeShell}
|
|
|
|
PS4=" $ "
|
|
|
|
set -eux
|
|
|
|
|
|
|
|
cp -f ${rootfs}/*.img fs.img
|
|
|
|
chmod +rw fs.img
|
|
|
|
|
|
|
|
qemu-system-x86_64 \
|
|
|
|
-enable-kvm \
|
2019-10-05 09:44:02 +03:00
|
|
|
-L ${pkgs.mobile-nixos.virtualization.bios} \
|
2019-09-22 05:41:33 +03:00
|
|
|
-kernel "${kernel-initrd}/kernel" \
|
|
|
|
-initrd "${kernel-initrd}/initrd" \
|
|
|
|
-append "$(cat "${kernel-initrd}/cmdline.txt")" \
|
|
|
|
-m "$(cat "${kernel-initrd}/ram.txt")M" \
|
2019-10-05 09:49:10 +03:00
|
|
|
-serial "mon:stdio" \
|
2019-09-22 05:41:33 +03:00
|
|
|
-drive "file=fs.img,format=raw" \
|
|
|
|
-device "e1000,netdev=net0" \
|
2019-10-05 09:49:10 +03:00
|
|
|
-device usb-ehci -device usb-kbd \
|
|
|
|
-device "usb-tablet" \
|
2019-09-22 05:41:33 +03:00
|
|
|
-netdev "user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23,net=172.16.42.0/24,dhcpstart=172.16.42.1"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|