1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9 serialDevice = if pkgs.stdenv.hostPlatform.isx86 then "ttyS0" else "ttyAMA0"; # aarch64
10in
11{
12 imports = [
13 ./lxc-instance-common.nix
14
15 ../profiles/qemu-guest.nix
16 ];
17
18 config = {
19 system.build.qemuImage = import ../../lib/make-disk-image.nix {
20 inherit pkgs lib config;
21
22 partitionTableType = "efi";
23 format = "qcow2-compressed";
24 copyChannel = true;
25 };
26
27 fileSystems = {
28 "/" = {
29 device = "/dev/disk/by-label/nixos";
30 autoResize = true;
31 fsType = "ext4";
32 };
33 "/boot" = {
34 device = "/dev/disk/by-label/ESP";
35 fsType = "vfat";
36 };
37 };
38
39 boot.growPartition = true;
40 boot.loader.systemd-boot.enable = true;
41
42 # image building needs to know what device to install bootloader on
43 boot.loader.grub.device = "/dev/vda";
44
45 boot.kernelParams = [
46 "console=tty1"
47 "console=${serialDevice}"
48 ];
49
50 services.udev.extraRules = ''
51 SUBSYSTEM=="cpu", CONST{arch}=="x86-64", TEST=="online", ATTR{online}=="0", ATTR{online}="1"
52 '';
53
54 virtualisation.lxd.agent.enable = lib.mkDefault true;
55 };
56}