|
1 | 1 | { lib, config, pkgs, modulesPath, ... }: { |
2 | 2 | imports = [ "${toString modulesPath}/profiles/qemu-guest.nix" ]; |
| 3 | + |
| 4 | + formatAttr = lib.mkForce "qcow"; |
| 5 | + |
| 6 | + system.build.qcow = lib.mkForce |
| 7 | + (import "${pkgs.path}/nixos/lib/make-disk-image.nix" { |
| 8 | + inherit lib config pkgs; |
| 9 | + diskSize = "auto"; |
| 10 | + memSize = "2048"; |
| 11 | + format = "qcow2"; |
| 12 | + partitionTableType = "legacy"; |
| 13 | + additionalSpace = "256M"; |
| 14 | + copyChannel = false; |
| 15 | + |
| 16 | + postVM = '' |
| 17 | + echo "Compressing final image with zstd..." |
| 18 | + ${pkgs.qemu-utils}/bin/qemu-img convert -c -O qcow2 -o compression_type=zstd "$diskImage" "$out/nixos-minimal.qcow2" |
| 19 | + rm "$diskImage" |
| 20 | + ''; |
| 21 | + }); |
| 22 | + |
| 23 | + # Standard minimal ext4 filesystem |
3 | 24 | fileSystems."/" = { |
4 | 25 | device = "/dev/disk/by-label/nixos"; |
5 | 26 | autoResize = true; |
6 | 27 | fsType = "ext4"; |
7 | 28 | }; |
8 | | - boot.growPartition = true; |
9 | | - environment.systemPackages = [ pkgs.cloud-utils ]; |
10 | 29 |
|
11 | | - system.build.qcow2 = import "${modulesPath}/../lib/make-disk-image.nix" { |
12 | | - inherit lib config pkgs; |
13 | | - diskSize = "auto"; |
14 | | - additionalSpace = "512M"; |
15 | | - format = "qcow2-compressed"; |
16 | | - partitionTableType = "hybrid"; |
| 30 | + # Simplest bootloader for a "legacy" partition table |
| 31 | + boot.loader.grub = { |
| 32 | + enable = lib.mkForce true; |
| 33 | + device = "/dev/vda"; |
| 34 | + efiSupport = lib.mkForce false; |
17 | 35 | }; |
18 | 36 |
|
19 | | - boot = { |
20 | | - kernelParams = [ "console=ttyS0" ]; |
21 | | - loader = { |
22 | | - grub = { |
23 | | - device = lib.mkDefault "/dev/vda"; |
24 | | - efiInstallAsRemovable = true; |
25 | | - efiSupport = true; |
26 | | - }; |
27 | | - efi.canTouchEfiVariables = lib.mkForce false; |
28 | | - }; |
| 37 | + hardware.enableRedistributableFirmware = false; |
| 38 | + fonts.fontconfig.enable = false; |
| 39 | + systemd.network.wait-online.enable = false; |
| 40 | + systemd.services.NetworkManager-wait-online.enable = false; |
| 41 | + networking = { |
| 42 | + usePredictableInterfaceNames = false; |
| 43 | + interfaces.eth0.useDHCP = true; |
| 44 | + dhcpcd.wait = "background"; |
29 | 45 | }; |
| 46 | + boot.initrd.availableKernelModules = |
| 47 | + [ "virtio_net" "virtio_pci" "virtio_mmio" "virtio_ring" ]; |
| 48 | + |
| 49 | + # Minimize closure size |
| 50 | + documentation.enable = false; |
| 51 | + environment.defaultPackages = lib.mkForce [ ]; |
| 52 | + programs.command-not-found.enable = false; |
30 | 53 | } |
0 commit comments