-
Notifications
You must be signed in to change notification settings - Fork 11
/
qemu.nix
110 lines (99 loc) · 2.77 KB
/
qemu.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
config,
pkgs,
lib,
...
}:
{
boot = {
loader.grub.enable = false;
kernelPackages = pkgs.linuxPackages_latest;
kernelParams = [
"console=ttyS0"
"earlycon"
];
initrd.availableKernelModules = [
"pci_host_generic"
"virtio_pci"
"9p"
"9pnet_virtio"
];
};
fileSystems = lib.mkForce {
"/" = {
device = "none";
fsType = "tmpfs";
options = [
"defaults"
"mode=755"
];
};
"/nix/store" = {
device = "nix-store";
fsType = "9p";
options = [
"ro"
"trans=virtio"
"version=9p2000.L"
"msize=1M"
];
};
};
system.stateVersion = "21.11";
networking.firewall.enable = false;
systemd.services."autotty@hvc0".enable = false;
services.getty.autologinUser = "root";
systemd.services.mount-pstore.enable = false;
services.xserver.desktopManager.gnome.enable = true;
services.xserver.displayManager.gdm.enable = true;
services.displayManager.enable = true;
services.gnome.core-utilities.enable = lib.mkForce false;
services.gnome.core-developer-tools.enable = lib.mkForce false;
services.gnome.gnome-user-share.enable = false;
services.power-profiles-daemon.enable = false;
services.gnome.gnome-initial-setup.enable = false;
services.gnome.evolution-data-server.enable = lib.mkForce false;
services.gnome.gnome-browser-connector.enable = false;
networking.networkmanager.enable = false;
networking.wireless.enable = false;
xdg.portal.enable = lib.mkForce false;
fonts.packages = lib.mkForce [ ];
environment.gnome.excludePackages = [
pkgs.gnome-control-center
pkgs.gnome-tour
pkgs.orca
];
services.displayManager.autoLogin = {
enable = true;
user = "alice";
};
environment.systemPackages = [
pkgs.xterm
pkgs.firefox
];
users.users.alice = {
isNormalUser = true;
description = "Alice Foobar";
password = "foobar";
uid = 1000;
};
system.build.vm =
let
qemu-path = "${pkgs.pkgsBuildBuild.qemu}/bin/qemu-system-${pkgs.targetPlatform.qemuArch}";
closure = config.system.build.toplevel;
in
pkgs.writeShellScriptBin "vm" ''
exec ${qemu-path} -M virt \
-m 8G -smp 4 \
-kernel ${closure}/kernel \
-initrd ${closure}/initrd \
-append "$(cat ${closure}/kernel-params) init=${closure}/init" \
-device virtio-rng-pci \
-netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
-fsdev local,security_model=passthrough,id=nix-store,path=/nix/store,readonly=on \
-device virtio-9p-pci,id=nix-store,fsdev=nix-store,mount_tag=nix-store \
-device virtio-gpu-gl \
-device qemu-xhci -usb -device usb-kbd -device usb-tablet \
-display gtk,gl=on,show-cursor=on
'';
}