Skip to content

Commit d5afeff

Browse files
cleanup, removals and polishing
Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
1 parent a082748 commit d5afeff

File tree

8 files changed

+8
-141
lines changed

8 files changed

+8
-141
lines changed

lib/global-config.nix

Lines changed: 2 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -342,52 +342,6 @@ rec {
342342
};
343343
in
344344
(feature.enable or false) && builtins.elem vmName (feature.targetVms or [ ]);
345-
346-
# Get all features enabled for a specific VM
347-
#
348-
# Usage:
349-
# lib.ghaf.features.forVm globalConfig "gui-vm"
350-
# # Returns: { fprint = true; yubikey = true; brightness = true; wifi = false; ... }
351-
#
352-
# Parameters:
353-
# globalConfig: The ghaf.global-config attribute set
354-
# vmName: Name of the VM to check
355-
#
356-
# Returns: attrset of featureName -> bool
357-
forVm =
358-
globalConfig: vmName:
359-
let
360-
featuresAttr = globalConfig.features or { };
361-
in
362-
lib.mapAttrs (
363-
_name: feature: (feature.enable or false) && builtins.elem vmName (feature.targetVms or [ ])
364-
) featuresAttr;
365-
366-
# List all available feature names
367-
#
368-
# Usage:
369-
# lib.ghaf.features.available globalConfig
370-
# # Returns: [ "fprint" "yubikey" "brightness" "wifi" "audio" "bluetooth" ]
371-
#
372-
available = globalConfig: builtins.attrNames (globalConfig.features or { });
373-
374-
# Get VMs that have a specific feature enabled
375-
#
376-
# Usage:
377-
# lib.ghaf.features.vmsWithFeature globalConfig "fprint"
378-
# # Returns: [ "gui-vm" ] (or whatever targetVms is set to)
379-
#
380-
vmsWithFeature =
381-
globalConfig: featureName:
382-
let
383-
featuresAttr = globalConfig.features or { };
384-
feature =
385-
featuresAttr.${featureName} or {
386-
enable = false;
387-
targetVms = [ ];
388-
};
389-
in
390-
if feature.enable or false then feature.targetVms or [ ] else [ ];
391345
};
392346

393347
# Predefined global config profiles
@@ -575,8 +529,8 @@ rec {
575529
# Functions:
576530
# lib.ghaf.vm.mkSpecialArgs - Create specialArgs for VM modules
577531
# lib.ghaf.vm.mkHostConfig - Extract host config for VM specialArgs
578-
# lib.ghaf.vm.extend - Extend a VM base with modules
579532
# lib.ghaf.vm.getConfig - Get inner NixOS config from microvm.vms entry
533+
# lib.ghaf.vm.applyVmConfig - Build modules list with vmConfig applied
580534
#
581535
# Usage Example:
582536
# guivmBase = lib.nixosSystem {
@@ -661,7 +615,7 @@ rec {
661615
enable = config.ghaf.microvm-boot.enable or false;
662616
};
663617

664-
# Hardware devices (for modules.nix)
618+
# Hardware devices
665619
hardware = {
666620
devices = config.ghaf.hardware.devices or { };
667621
};
@@ -699,37 +653,6 @@ rec {
699653
}
700654
// extraConfig;
701655

702-
# Extend a VM base with additional modules
703-
#
704-
# This function takes a base VM configuration (lib.nixosSystem result)
705-
# and extends it with additional modules for profile-specific functionality.
706-
#
707-
# Arguments:
708-
# vmBase - lib.nixosSystem result with .extendModules
709-
# extraModules - Additional modules to add
710-
# globalConfig - Global config value
711-
# hostConfig - Host-specific config
712-
# extraSpecialArgs - Optional additional specialArgs
713-
#
714-
# Returns: Extended NixOS system configuration
715-
#
716-
# See modules/profiles/laptop-x86.nix for canonical pattern.
717-
extend =
718-
{
719-
vmBase,
720-
extraModules ? [ ],
721-
globalConfig ? { },
722-
hostConfig ? { },
723-
extraSpecialArgs ? { },
724-
}:
725-
vmBase.extendModules {
726-
modules = extraModules;
727-
specialArgs = {
728-
inherit globalConfig hostConfig;
729-
}
730-
// extraSpecialArgs;
731-
};
732-
733656
# Get the inner NixOS config from a microvm.vms entry
734657
#
735658
# microvm.nix supports two ways to define VMs:
@@ -796,34 +719,5 @@ rec {
796719
// lib.optionalAttrs (vmCfg.vcpu or null != null) { microvm.vcpu = vmCfg.vcpu; };
797720
in
798721
[ resourceModule ] ++ hwModules ++ vmConfigModules;
799-
800-
# Build modules list with vmConfig applied for App VMs
801-
#
802-
# Similar to applyVmConfig but uses appvms namespace and
803-
# ramMb/cores naming convention for consistency with appvm definitions.
804-
#
805-
# Arguments:
806-
# config - Host configuration
807-
# appName - App VM name (e.g., "chromium", "comms")
808-
#
809-
# Returns: List of modules to add via extendModules
810-
applyAppVmConfig =
811-
{
812-
config,
813-
appName,
814-
}:
815-
let
816-
vmCfg = config.ghaf.virtualization.vmConfig.appvms.${appName} or { };
817-
vmConfigModules = vmCfg.extraModules or [ ];
818-
819-
# Resource allocation module (applies ramMb/cores as mem/vcpu)
820-
resourceModule =
821-
lib.optionalAttrs (vmCfg.ramMb or null != null) {
822-
# App VMs use balloon, so scale by balloon ratio
823-
microvm.mem = vmCfg.ramMb * 3; # Default balloon ratio is 2
824-
}
825-
// lib.optionalAttrs (vmCfg.cores or null != null) { microvm.vcpu = vmCfg.cores; };
826-
in
827-
[ resourceModule ] ++ vmConfigModules;
828722
};
829723
}

modules/microvm/audiovm-features/xpadneo.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ in
2222
_file = ./xpadneo.nix;
2323

2424
config = lib.mkIf audioEnabled {
25-
# Xpadneo is currently disabled (matches modules.nix behavior)
25+
# Xpadneo is currently disabled
2626
ghaf.services.xpadneo.enable = false;
2727
};
2828
}

modules/microvm/flake-module.nix

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ _: {
1818
./sysvms/audiovm.nix
1919
./sysvms/idsvm/idsvm.nix
2020
./common/microvm-store-mode.nix
21-
./modules.nix
2221
./vm-config.nix
2322
];
2423

@@ -66,9 +65,7 @@ _: {
6665
audiovm-base = ./sysvms/audiovm-base.nix;
6766

6867
# Audio VM feature modules (bluetooth, xpadneo, hardware passthrough)
69-
# Currently not used - hardware passthrough handled via hardware.definition.audiovm.extraModules
70-
# TODO: Revisit in future phase with proper hostConfig structure
71-
# audiovm-features = ./audiovm-features;
68+
audiovm-features = ./audiovm-features;
7269

7370
# Net VM base module for layered composition
7471
# Use with extendModules pattern:

modules/microvm/modules.nix

Lines changed: 0 additions & 22 deletions
This file was deleted.

modules/microvm/sysvms/netvm.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
# - Host-specific settings (networking.hosts) come via hostConfig specialArg
99
#
1010
# The VM configuration is self-contained and does not reference `configHost`.
11-
#
12-
# NOTE: As of Phase 3.85, the legacy inline configuration path has been removed.
1311
# All platforms must use the evaluatedConfig pattern with a profile's netvmBase.
12+
#
1413
{
1514
config,
1615
lib,

targets/generic-x86_64/flake-module.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ let
5959
...
6060
}:
6161
let
62-
# Create globalConfig for the netvm
63-
globalConfig = lib.ghaf.mkGlobalConfig config;
62+
# Get globalConfig from host configuration
63+
globalConfig = config.ghaf.global-config;
6464

6565
# Create inline netvmBase (following laptop-x86 pattern)
6666
netvmBase = lib.nixosSystem {

targets/laptop/flake-module.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44
# Configuration for laptop devices based on the hardware and usecase profile
5-
# Migrated to mkGhafConfiguration (Phase 4.3.7)
5+
#
66
{
77
lib,
88
self,

targets/nvidia-jetson-orin/flake-module.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44
# Configuration for NVIDIA Jetson Orin AGX/NX
5-
# Migrated to mkGhafConfiguration (Phase 4.3.8)
65
#
76
{
87
lib,

0 commit comments

Comments
 (0)