|
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 | # |
4 | 4 | # Generic x86_64 computer -target |
| 5 | +# |
| 6 | +# This is a minimal target that runs GUI on the HOST with netvm for networking. |
| 7 | +# It uses an inline netvmBase instead of the full laptop-x86 profile. |
5 | 8 | { |
6 | 9 | inputs, |
7 | 10 | lib, |
|
55 | 58 | modulesPath, |
56 | 59 | ... |
57 | 60 | }: |
| 61 | + let |
| 62 | + # Create globalConfig for the netvm |
| 63 | + globalConfig = lib.ghaf.mkGlobalConfig config; |
| 64 | + |
| 65 | + # Create inline netvmBase (following laptop-x86 pattern) |
| 66 | + netvmBase = lib.nixosSystem { |
| 67 | + inherit (inputs.nixpkgs.legacyPackages.x86_64-linux) system; |
| 68 | + modules = [ |
| 69 | + inputs.microvm.nixosModules.microvm |
| 70 | + inputs.self.nixosModules.netvm-base |
| 71 | + # Import nixpkgs config for overlays |
| 72 | + { |
| 73 | + nixpkgs.overlays = config.nixpkgs.overlays; |
| 74 | + nixpkgs.config = config.nixpkgs.config; |
| 75 | + } |
| 76 | + ]; |
| 77 | + specialArgs = lib.ghaf.vm.mkSpecialArgs { |
| 78 | + inherit lib inputs globalConfig; |
| 79 | + hostConfig = |
| 80 | + lib.ghaf.vm.mkHostConfig { |
| 81 | + inherit config; |
| 82 | + vmName = "net-vm"; |
| 83 | + } |
| 84 | + // { |
| 85 | + netvm = { |
| 86 | + wifi = config.ghaf.virtualization.microvm.netvm.wifi or false; |
| 87 | + }; |
| 88 | + }; |
| 89 | + }; |
| 90 | + }; |
| 91 | + in |
58 | 92 | { |
59 | 93 | # https://github.com/nix-community/nixos-generators/blob/master/formats/raw-efi.nix#L24-L29 |
60 | 94 | system.build.raw = lib.mkOverride 98 ( |
|
66 | 100 | postVM = "${pkgs.zstd}/bin/zstd --compress --rm $out/nixos.img"; |
67 | 101 | } |
68 | 102 | ); |
| 103 | + |
| 104 | + # Wire up netvm using inline netvmBase |
| 105 | + ghaf.virtualization.microvm.netvm.evaluatedConfig = netvmBase.extendModules { |
| 106 | + modules = config.ghaf.hardware.definition.netvm.extraModules or [ ]; |
| 107 | + }; |
69 | 108 | } |
70 | 109 | ) |
71 | 110 |
|
72 | 111 | { |
73 | 112 | ghaf = { |
74 | 113 | hardware.x86_64.common.enable = true; |
75 | 114 |
|
| 115 | + # Hardware passthrough for netvm (WiFi device) |
| 116 | + hardware.definition.netvm.extraModules = netvmExtraModules; |
| 117 | + |
76 | 118 | virtualization = { |
77 | 119 | microvm-host = { |
78 | 120 | enable = true; |
79 | 121 | networkSupport = true; |
80 | 122 | }; |
81 | 123 |
|
82 | | - microvm.netvm = { |
83 | | - enable = true; |
84 | | - extraModules = netvmExtraModules; |
85 | | - }; |
| 124 | + microvm.netvm.enable = true; |
86 | 125 | }; |
87 | 126 |
|
88 | 127 | host.networking.enable = true; |
|
0 commit comments