mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-26 01:13:37 +03:00
Adds back kernel-initrd (for qemu)
This commit is contained in:
parent
327fda2329
commit
b8c4bcda18
@ -12,6 +12,7 @@ in
|
||||
{
|
||||
imports = [
|
||||
../systems/rootfs.nix
|
||||
./system-types/kernel-initrd.nix
|
||||
];
|
||||
|
||||
options.mobile = {
|
||||
|
56
modules/system-types/kernel-initrd.nix
Normal file
56
modules/system-types/kernel-initrd.nix
Normal file
@ -0,0 +1,56 @@
|
||||
{ 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 {
|
||||
system.build = {
|
||||
inherit system;
|
||||
mobile-installer = system;
|
||||
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 \
|
||||
-kernel "${kernel-initrd}/kernel" \
|
||||
-initrd "${kernel-initrd}/initrd" \
|
||||
-append "$(cat "${kernel-initrd}/cmdline.txt")" \
|
||||
-m "$(cat "${kernel-initrd}/ram.txt")M" \
|
||||
-serial "stdio" \
|
||||
-drive "file=fs.img,format=raw" \
|
||||
-device "e1000,netdev=net0" \
|
||||
-netdev "user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23,net=172.16.42.0/24,dhcpstart=172.16.42.1"
|
||||
'';
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
Loading…
Reference in New Issue
Block a user