Skip to content

Commit 988eed7

Browse files
generic-x86: migrate to the new composition model
Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
1 parent 3f962cd commit 988eed7

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

targets/generic-x86_64/flake-module.nix

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44
# 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.
58
{
69
inputs,
710
lib,
@@ -55,6 +58,37 @@ let
5558
modulesPath,
5659
...
5760
}:
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
5892
{
5993
# https://github.com/nix-community/nixos-generators/blob/master/formats/raw-efi.nix#L24-L29
6094
system.build.raw = lib.mkOverride 98 (
@@ -66,23 +100,28 @@ let
66100
postVM = "${pkgs.zstd}/bin/zstd --compress --rm $out/nixos.img";
67101
}
68102
);
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+
};
69108
}
70109
)
71110

72111
{
73112
ghaf = {
74113
hardware.x86_64.common.enable = true;
75114

115+
# Hardware passthrough for netvm (WiFi device)
116+
hardware.definition.netvm.extraModules = netvmExtraModules;
117+
76118
virtualization = {
77119
microvm-host = {
78120
enable = true;
79121
networkSupport = true;
80122
};
81123

82-
microvm.netvm = {
83-
enable = true;
84-
extraModules = netvmExtraModules;
85-
};
124+
microvm.netvm.enable = true;
86125
};
87126

88127
host.networking.enable = true;

0 commit comments

Comments
 (0)