refactor: Make hw definitions modules with mkIf guards
Some checks failed
CI / Flake Check (push) Has been cancelled
CI / Evaluate Key Configurations (nix-builder) (push) Has been cancelled
CI / Evaluate Key Configurations (nix-desktop1) (push) Has been cancelled
CI / Evaluate Key Configurations (nix-laptop1) (push) Has been cancelled
CI / Evaluate Artifacts (installer-iso-nix-laptop1) (push) Has been cancelled
CI / Evaluate Artifacts (lxc-nix-builder) (push) Has been cancelled
CI / Build and Publish Documentation (push) Has been cancelled
CI / Format Check (push) Has been cancelled
Some checks failed
CI / Flake Check (push) Has been cancelled
CI / Evaluate Key Configurations (nix-builder) (push) Has been cancelled
CI / Evaluate Key Configurations (nix-desktop1) (push) Has been cancelled
CI / Evaluate Key Configurations (nix-laptop1) (push) Has been cancelled
CI / Evaluate Artifacts (installer-iso-nix-laptop1) (push) Has been cancelled
CI / Evaluate Artifacts (lxc-nix-builder) (push) Has been cancelled
CI / Build and Publish Documentation (push) Has been cancelled
CI / Format Check (push) Has been cancelled
This commit is contained in:
@@ -7,8 +7,14 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
# Import all hardware modules so they're available for enabling
|
||||||
|
hwTypes = import ../hw { inherit inputs; };
|
||||||
|
hwModules = lib.attrValues hwTypes;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./fs.nix
|
./fs.nix
|
||||||
@@ -16,7 +22,9 @@
|
|||||||
./user-config.nix
|
./user-config.nix
|
||||||
./fleet-option.nix
|
./fleet-option.nix
|
||||||
../sw
|
../sw
|
||||||
];
|
inputs.vscode-server.nixosModules.default
|
||||||
|
inputs.nixos-wsl.nixosModules.default
|
||||||
|
] ++ hwModules;
|
||||||
|
|
||||||
options.athenix = {
|
options.athenix = {
|
||||||
forUser = lib.mkOption {
|
forUser = lib.mkOption {
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ let
|
|||||||
# Import fleet-option.nix (defines athenix.fleet) and inventory.nix (sets values)
|
# Import fleet-option.nix (defines athenix.fleet) and inventory.nix (sets values)
|
||||||
# We use a minimal module here to avoid circular dependencies from common.nix's imports
|
# We use a minimal module here to avoid circular dependencies from common.nix's imports
|
||||||
|
|
||||||
hostTypes = config.athenix.hwTypes;
|
|
||||||
|
|
||||||
# Helper to create a single NixOS system configuration
|
# Helper to create a single NixOS system configuration
|
||||||
mkHost =
|
mkHost =
|
||||||
{
|
{
|
||||||
@@ -123,11 +121,6 @@ let
|
|||||||
}
|
}
|
||||||
) userNixosModulePaths;
|
) userNixosModulePaths;
|
||||||
|
|
||||||
# Get the host type module from the hostTypes attribute set
|
|
||||||
typeModule =
|
|
||||||
hostTypes.${hostType}
|
|
||||||
or (throw "Host type '${hostType}' not found. Available types: ${lib.concatStringsSep ", " (lib.attrNames hostTypes)}");
|
|
||||||
|
|
||||||
# External module from fetchGit/fetchurl
|
# External module from fetchGit/fetchurl
|
||||||
externalPathModule =
|
externalPathModule =
|
||||||
if externalModulePath != null then import externalModulePath { inherit inputs; } else { };
|
if externalModulePath != null then import externalModulePath { inherit inputs; } else { };
|
||||||
@@ -155,18 +148,24 @@ let
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Hardware-specific external modules
|
||||||
|
hwSpecificModules =
|
||||||
|
lib.optional (hostType == "nix-lxc") "${inputs.nixpkgs.legacyPackages.${system}.path}/nixos/modules/virtualisation/proxmox-lxc.nix";
|
||||||
|
|
||||||
allModules =
|
allModules =
|
||||||
userNixosModules
|
userNixosModules
|
||||||
++ [
|
++ [
|
||||||
./common.nix
|
./common.nix
|
||||||
typeModule
|
|
||||||
overrideModule
|
overrideModule
|
||||||
{ networking.hostName = hostName; }
|
{ networking.hostName = hostName; }
|
||||||
{
|
{
|
||||||
# Inject user definitions from flake-parts level
|
# Inject user definitions from flake-parts level
|
||||||
config.athenix.users = lib.mapAttrs (_: user: lib.mapAttrs (_: lib.mkDefault) user) users;
|
config.athenix.users = lib.mapAttrs (_: user: lib.mapAttrs (_: lib.mkDefault) user) users;
|
||||||
}
|
}
|
||||||
|
# Enable the appropriate hardware module based on hostType
|
||||||
|
{ config.athenix.hw.${hostType}.enable = lib.mkDefault true; }
|
||||||
]
|
]
|
||||||
|
++ hwSpecificModules
|
||||||
++ lib.optional (externalModulePath != null) externalPathModule;
|
++ lib.optional (externalModulePath != null) externalPathModule;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,11 +10,33 @@
|
|||||||
modulesPath,
|
modulesPath,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.athenix.hw.nix-desktop;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
options.athenix.hw.nix-desktop = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable desktop workstation hardware configuration.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = "Desktop workstation hardware type configuration.";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
# ========== Boot Configuration ==========
|
# ========== Boot Configuration ==========
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
boot.initrd.availableKernelModules = [
|
||||||
@@ -47,4 +69,5 @@
|
|||||||
# ========== Software Profile ==========
|
# ========== Software Profile ==========
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
athenix.sw.desktop.enable = lib.mkDefault true;
|
athenix.sw.desktop.enable = lib.mkDefault true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,32 @@
|
|||||||
modulesPath,
|
modulesPath,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.athenix.hw.nix-ephemeral;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
options.athenix.hw.nix-ephemeral = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable ephemeral/diskless system hardware configuration.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = "Ephemeral hardware type configuration.";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
# ========== Boot Configuration ==========
|
# ========== Boot Configuration ==========
|
||||||
boot.initrd.availableKernelModules = [
|
boot.initrd.availableKernelModules = [
|
||||||
"xhci_pci" # USB 3.0 support
|
"xhci_pci" # USB 3.0 support
|
||||||
@@ -63,4 +84,5 @@
|
|||||||
|
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
athenix.sw.stateless-kiosk.enable = lib.mkDefault true;
|
athenix.sw.stateless-kiosk.enable = lib.mkDefault true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,32 @@
|
|||||||
modulesPath,
|
modulesPath,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.athenix.hw.nix-laptop;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
options.athenix.hw.nix-laptop = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable laptop hardware configuration with power management.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = "Laptop hardware type configuration.";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
# ========== Boot Configuration ==========
|
# ========== Boot Configuration ==========
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
boot.initrd.availableKernelModules = [
|
||||||
@@ -60,4 +81,5 @@
|
|||||||
|
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
athenix.sw.desktop.enable = lib.mkDefault true;
|
athenix.sw.desktop.enable = lib.mkDefault true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,32 @@
|
|||||||
# Disables boot/disk management and enables remote development support.
|
# Disables boot/disk management and enables remote development support.
|
||||||
|
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
lib,
|
lib,
|
||||||
modulesPath,
|
|
||||||
inputs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
inputs.vscode-server.nixosModules.default
|
|
||||||
"${modulesPath}/virtualisation/proxmox-lxc.nix"
|
|
||||||
];
|
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.athenix.hw.nix-lxc;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.athenix.hw.nix-lxc = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable Proxmox LXC container hardware configuration.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = "Proxmox LXC hardware type configuration.";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
# ========== Nix Configuration ==========
|
# ========== Nix Configuration ==========
|
||||||
nix.settings.trusted-users = [
|
nix.settings.trusted-users = [
|
||||||
"root"
|
"root"
|
||||||
@@ -57,4 +72,5 @@
|
|||||||
|
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
athenix.sw.headless.enable = lib.mkDefault true;
|
athenix.sw.headless.enable = lib.mkDefault true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,11 @@
|
|||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
cfg = config.athenix.hw.nix-surface;
|
||||||
# Use older kernel version for better Surface Go compatibility
|
# Use older kernel version for better Surface Go compatibility
|
||||||
refSystem = inputs.nixpkgs-old-kernel.lib.nixosSystem {
|
refSystem = inputs.nixpkgs-old-kernel.lib.nixosSystem {
|
||||||
system = pkgs.stdenv.hostPlatform.system;
|
system = pkgs.stdenv.hostPlatform.system;
|
||||||
@@ -26,6 +30,21 @@ in
|
|||||||
inputs.nixos-hardware.nixosModules.microsoft-surface-go
|
inputs.nixos-hardware.nixosModules.microsoft-surface-go
|
||||||
];
|
];
|
||||||
|
|
||||||
|
options.athenix.hw.nix-surface = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable Microsoft Surface tablet hardware configuration.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = "Microsoft Surface hardware type configuration.";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
# ========== Boot Configuration ==========
|
# ========== Boot Configuration ==========
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
boot.initrd.availableKernelModules = [
|
||||||
@@ -66,4 +85,5 @@ in
|
|||||||
# ========== Software Profile ==========
|
# ========== Software Profile ==========
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
athenix.sw.tablet-kiosk.enable = lib.mkDefault true; # Touch-optimized kiosk mode
|
athenix.sw.tablet-kiosk.enable = lib.mkDefault true; # Touch-optimized kiosk mode
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,16 +7,30 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
inputs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
inputs.nixos-wsl.nixosModules.default
|
|
||||||
inputs.vscode-server.nixosModules.default
|
|
||||||
];
|
|
||||||
|
|
||||||
# ========== Options ==========
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.athenix.hw.nix-wsl;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.athenix.hw.nix-wsl = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable Windows Subsystem for Linux hardware configuration.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = "WSL hardware type configuration.";
|
||||||
|
};
|
||||||
|
|
||||||
|
# WSL user option (at module level, not inside config)
|
||||||
options.athenix.host.wsl.user = lib.mkOption {
|
options.athenix.host.wsl.user = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "engr-ugaif";
|
default = "engr-ugaif";
|
||||||
@@ -29,7 +43,7 @@
|
|||||||
example = "alice";
|
example = "alice";
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = mkIf cfg.enable {
|
||||||
# ========== WSL Configuration ==========
|
# ========== WSL Configuration ==========
|
||||||
wsl.enable = true;
|
wsl.enable = true;
|
||||||
# Use forUser if set, otherwise fall back to wsl.user option
|
# Use forUser if set, otherwise fall back to wsl.user option
|
||||||
@@ -55,5 +69,8 @@
|
|||||||
# Provide dummy values for required options from boot.nix
|
# Provide dummy values for required options from boot.nix
|
||||||
athenix.host.filesystem.device = "/dev/null";
|
athenix.host.filesystem.device = "/dev/null";
|
||||||
athenix.host.filesystem.swapSize = "0G";
|
athenix.host.filesystem.swapSize = "0G";
|
||||||
|
|
||||||
|
# WSL doesn't use installer ISOs
|
||||||
|
athenix.host.buildMethods = lib.mkDefault [ ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,32 @@
|
|||||||
modulesPath,
|
modulesPath,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.athenix.hw.nix-zima;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
options.athenix.hw.nix-zima = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable Zima-specific hardware configuration.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = "Zima hardware type configuration.";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
# ========== Boot Configuration ==========
|
# ========== Boot Configuration ==========
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
boot.initrd.availableKernelModules = [
|
||||||
@@ -46,4 +67,5 @@
|
|||||||
# ========== Software Profile ==========
|
# ========== Software Profile ==========
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
athenix.sw.desktop.enable = lib.mkDefault true;
|
athenix.sw.desktop.enable = lib.mkDefault true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user