refactor: create glue/ and variants/ directories
- Add glue/ for fleet generation logic and common configuration - Add variants/ for hardware type modules - Improves separation of concerns and module organization
This commit is contained in:
29
variants/default.nix
Normal file
29
variants/default.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
# ============================================================================
|
||||
# Host Types Module
|
||||
# ============================================================================
|
||||
# This module exports all available host types as an attribute set.
|
||||
# Each type is a NixOS module function that takes { inputs } and returns
|
||||
# a module configuration.
|
||||
|
||||
{ inputs }:
|
||||
let
|
||||
inherit (builtins) readDir attrNames;
|
||||
lib = inputs.nixpkgs.lib;
|
||||
inherit (lib) filterAttrs removeSuffix genAttrs;
|
||||
|
||||
files = readDir ./.;
|
||||
|
||||
# Keep only regular *.nix files except default.nix
|
||||
nixFiles =
|
||||
filterAttrs
|
||||
(name: type:
|
||||
type == "regular"
|
||||
&& lib.hasSuffix ".nix" name
|
||||
&& name != "default.nix")
|
||||
files;
|
||||
|
||||
moduleNames = map (name: removeSuffix ".nix" name) (attrNames nixFiles);
|
||||
in
|
||||
genAttrs moduleNames
|
||||
(name:
|
||||
import ./${name}.nix { inherit inputs; })
|
||||
51
variants/nix-desktop.nix
Normal file
51
variants/nix-desktop.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
# ============================================================================
|
||||
# Desktop Configuration
|
||||
# ============================================================================
|
||||
# Hardware and boot configuration for standard desktop workstations.
|
||||
# Includes Intel CPU support and NVMe storage.
|
||||
|
||||
{ inputs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
# ========== Boot Configuration ==========
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"xhci_pci" # USB 3.0 support
|
||||
"nvme" # NVMe SSD support
|
||||
"usb_storage" # USB storage devices
|
||||
"sd_mod" # SD card support
|
||||
"sdhci_pci" # SD card host controller
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||
boot.extraModulePackages = [ ];
|
||||
boot.kernelParams = [
|
||||
"quiet" # Minimal boot messages
|
||||
"splash" # Show Plymouth boot splash
|
||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||
"udev.log_priority=3" # Reduce udev logging
|
||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||
];
|
||||
|
||||
# ========== Filesystem Configuration ==========
|
||||
athenix.host.filesystem.swapSize = lib.mkDefault "16G";
|
||||
athenix.host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
||||
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
|
||||
# ========== Hardware Configuration ==========
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
|
||||
# ========== Software Profile ==========
|
||||
athenix.sw.enable = lib.mkDefault true;
|
||||
athenix.sw.type = lib.mkDefault "desktop";
|
||||
}
|
||||
67
variants/nix-ephemeral.nix
Normal file
67
variants/nix-ephemeral.nix
Normal file
@@ -0,0 +1,67 @@
|
||||
# ============================================================================
|
||||
# Ephemeral/Diskless System Configuration
|
||||
# ============================================================================
|
||||
# Configuration for systems that run entirely from RAM without persistent storage.
|
||||
# Suitable for kiosks, netboot clients, and stateless workstations.
|
||||
# All data is lost on reboot.
|
||||
|
||||
{ inputs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
# ========== Boot Configuration ==========
|
||||
boot.initrd.availableKernelModules = [
|
||||
"xhci_pci" # USB 3.0 support
|
||||
"nvme" # NVMe support
|
||||
"usb_storage" # USB storage devices
|
||||
"sd_mod" # SD card support
|
||||
"sdhci_pci" # SD card host controller
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||
boot.extraModulePackages = [ ];
|
||||
boot.kernelParams = [
|
||||
"quiet" # Minimal boot messages
|
||||
"splash" # Show Plymouth boot splash
|
||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||
"udev.log_priority=3" # Reduce udev logging
|
||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||
];
|
||||
|
||||
# ========== Ephemeral Configuration ==========
|
||||
# No persistent storage - everything runs from RAM
|
||||
athenix.host.filesystem.swapSize = lib.mkForce "0G";
|
||||
athenix.host.filesystem.device = lib.mkForce "/dev/null"; # Dummy device
|
||||
athenix.host.buildMethods = lib.mkDefault [
|
||||
"iso" # Live ISO image
|
||||
"ipxe" # Network boot
|
||||
];
|
||||
|
||||
# Disable disk management for RAM-only systems
|
||||
disko.enableConfig = lib.mkForce false;
|
||||
|
||||
# Define tmpfs root filesystem
|
||||
fileSystems."/" = {
|
||||
device = "none";
|
||||
fsType = "tmpfs";
|
||||
options = [
|
||||
"defaults"
|
||||
"size=50%"
|
||||
"mode=755"
|
||||
];
|
||||
};
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
|
||||
athenix.sw.enable = lib.mkDefault true;
|
||||
athenix.sw.type = lib.mkDefault "stateless-kiosk";
|
||||
}
|
||||
64
variants/nix-laptop.nix
Normal file
64
variants/nix-laptop.nix
Normal file
@@ -0,0 +1,64 @@
|
||||
# ============================================================================
|
||||
# Laptop Configuration
|
||||
# ============================================================================
|
||||
# Hardware and boot configuration for laptop systems with mobile features.
|
||||
# Includes power management, lid switch handling, and Intel graphics fixes.
|
||||
|
||||
{ inputs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
# ========== Boot Configuration ==========
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"xhci_pci" # USB 3.0 support
|
||||
"thunderbolt" # Thunderbolt support
|
||||
"nvme" # NVMe SSD support
|
||||
"usb_storage" # USB storage devices
|
||||
"sd_mod" # SD card support
|
||||
"sdhci_pci" # SD card host controller
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||
boot.extraModulePackages = [ ];
|
||||
boot.kernelParams = [
|
||||
"quiet" # Minimal boot messages
|
||||
"splash" # Show Plymouth boot splash
|
||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||
"udev.log_priority=3" # Reduce udev logging
|
||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||
"i915.enable_psr=0" # Disable Panel Self Refresh (stability)
|
||||
"i915.enable_dc=0" # Disable display power saving
|
||||
"i915.enable_fbc=0" # Disable framebuffer compression
|
||||
];
|
||||
|
||||
# ========== Hardware Configuration ==========
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
|
||||
# ========== Filesystem Configuration ==========
|
||||
athenix.host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
||||
athenix.host.filesystem.swapSize = lib.mkDefault "34G"; # Larger swap for hibernation
|
||||
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
|
||||
# ========== Power Management ==========
|
||||
services.upower.enable = lib.mkDefault true;
|
||||
services.logind.settings = {
|
||||
Login = {
|
||||
HandleLidSwitch = "suspend";
|
||||
HandleLidSwitchExternalPower = "suspend";
|
||||
HandleLidSwitchDocked = "ignore";
|
||||
};
|
||||
};
|
||||
|
||||
athenix.sw.enable = lib.mkDefault true;
|
||||
athenix.sw.type = lib.mkDefault "desktop";
|
||||
}
|
||||
61
variants/nix-lxc.nix
Normal file
61
variants/nix-lxc.nix
Normal file
@@ -0,0 +1,61 @@
|
||||
# ============================================================================
|
||||
# Proxmox LXC Container Configuration
|
||||
# ============================================================================
|
||||
# Configuration for lightweight Linux containers running in Proxmox.
|
||||
# Disables boot/disk management and enables remote development support.
|
||||
|
||||
{ inputs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
inputs.vscode-server.nixosModules.default
|
||||
"${modulesPath}/virtualisation/proxmox-lxc.nix"
|
||||
];
|
||||
|
||||
# ========== Nix Configuration ==========
|
||||
nix.settings.trusted-users = [
|
||||
"root"
|
||||
"engr-ugaif"
|
||||
];
|
||||
nix.settings.experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
|
||||
# ========== Container-Specific Configuration ==========
|
||||
boot.isContainer = true;
|
||||
boot.loader.systemd-boot.enable = lib.mkForce false; # No bootloader in container
|
||||
disko.enableConfig = lib.mkForce false; # No disk management in container
|
||||
console.enable = true;
|
||||
|
||||
# Allow getty to work in containers
|
||||
systemd.services."getty@".unitConfig.ConditionPathExists = [
|
||||
""
|
||||
"/dev/%I"
|
||||
];
|
||||
|
||||
# Suppress unnecessary systemd units for containers
|
||||
systemd.suppressedSystemUnits = [
|
||||
"dev-mqueue.mount"
|
||||
"sys-kernel-debug.mount"
|
||||
"sys-fs-fuse-connections.mount"
|
||||
];
|
||||
|
||||
# ========== Remote Development ==========
|
||||
services.vscode-server.enable = true;
|
||||
|
||||
# ========== System Configuration ==========
|
||||
system.stateVersion = "25.11";
|
||||
athenix.host.buildMethods = lib.mkDefault [
|
||||
"lxc" # LXC container tarball
|
||||
"proxmox" # Proxmox VMA archive
|
||||
];
|
||||
|
||||
athenix.sw.enable = lib.mkDefault true;
|
||||
athenix.sw.type = lib.mkDefault "headless";
|
||||
}
|
||||
69
variants/nix-surface.nix
Normal file
69
variants/nix-surface.nix
Normal file
@@ -0,0 +1,69 @@
|
||||
# ============================================================================
|
||||
# Microsoft Surface Tablet Configuration
|
||||
# ============================================================================
|
||||
# Hardware configuration for Surface Go tablets in kiosk mode.
|
||||
# Uses nixos-hardware module and older kernel for Surface-specific drivers.
|
||||
|
||||
{ inputs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# Use older kernel version for better Surface Go compatibility
|
||||
refSystem = inputs.nixpkgs-old-kernel.lib.nixosSystem {
|
||||
system = pkgs.stdenv.hostPlatform.system;
|
||||
modules = [ inputs.nixos-hardware.nixosModules.microsoft-surface-go ];
|
||||
};
|
||||
refKernelPackages = refSystem.config.boot.kernelPackages;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
inputs.nixos-hardware.nixosModules.microsoft-surface-go
|
||||
];
|
||||
|
||||
# ========== Boot Configuration ==========
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"xhci_pci" # USB 3.0 support
|
||||
"nvme" # NVMe support (though Surface uses eMMC)
|
||||
"usb_storage" # USB storage devices
|
||||
"sd_mod" # SD card support
|
||||
"sdhci_pci" # SD card host controller
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||
boot.extraModulePackages = [ ];
|
||||
boot.kernelParams = [
|
||||
"quiet" # Minimal boot messages
|
||||
"splash" # Show Plymouth boot splash
|
||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||
"udev.log_priority=3" # Reduce udev logging
|
||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||
"intel_ipu3_imgu" # Intel camera image processing
|
||||
"intel_ipu3_isys" # Intel camera sensor interface
|
||||
"fbcon=map:1" # Framebuffer console mapping
|
||||
"i915.enable_psr=0" # Disable Panel Self Refresh (breaks resume)
|
||||
"i915.enable_dc=0" # Disable display power saving
|
||||
];
|
||||
|
||||
# Use older kernel for better Surface hardware support
|
||||
boot.kernelPackages = lib.mkForce refKernelPackages;
|
||||
|
||||
# ========== Filesystem Configuration ==========
|
||||
athenix.host.filesystem.swapSize = lib.mkDefault "8G";
|
||||
athenix.host.filesystem.device = lib.mkDefault "/dev/mmcblk0"; # eMMC storage # eMMC storage
|
||||
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
|
||||
# ========== Hardware Configuration ==========
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
|
||||
# ========== Software Profile ==========
|
||||
athenix.sw.enable = lib.mkDefault true;
|
||||
athenix.sw.type = lib.mkDefault "tablet-kiosk"; # Touch-optimized kiosk mode
|
||||
}
|
||||
53
variants/nix-wsl.nix
Normal file
53
variants/nix-wsl.nix
Normal file
@@ -0,0 +1,53 @@
|
||||
# ============================================================================
|
||||
# Windows Subsystem for Linux (WSL) Configuration
|
||||
# ============================================================================
|
||||
# Configuration for NixOS running in WSL2 on Windows.
|
||||
# Integrates with nixos-wsl for WSL-specific functionality.
|
||||
|
||||
{ inputs, ... }:
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
inputs.nixos-wsl.nixosModules.default
|
||||
inputs.vscode-server.nixosModules.default
|
||||
];
|
||||
|
||||
# ========== Options ==========
|
||||
options.athenix.host.wsl.user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "engr-ugaif";
|
||||
description = "The default user to log in as in WSL.";
|
||||
};
|
||||
|
||||
config = {
|
||||
# ========== WSL Configuration ==========
|
||||
wsl.enable = true;
|
||||
# Use forUser if set, otherwise fall back to wsl.user option
|
||||
wsl.defaultUser =
|
||||
if config.athenix.forUser != null then config.athenix.forUser else config.athenix.host.wsl.user;
|
||||
|
||||
# ========== Software Profile ==========
|
||||
athenix.sw.enable = lib.mkDefault true;
|
||||
athenix.sw.type = lib.mkDefault "headless";
|
||||
|
||||
# ========== Remote Development ==========
|
||||
services.vscode-server.enable = true;
|
||||
|
||||
# ========== Disable Irrelevant Systems ==========
|
||||
# WSL doesn't use traditional boot or disk management
|
||||
disko.enableConfig = lib.mkForce false;
|
||||
boot.loader.systemd-boot.enable = lib.mkForce false;
|
||||
boot.loader.grub.enable = lib.mkForce false;
|
||||
|
||||
# WSL manages its own networking
|
||||
systemd.network.enable = lib.mkForce false;
|
||||
|
||||
# Provide dummy values for required options from boot.nix
|
||||
athenix.host.filesystem.device = "/dev/null";
|
||||
athenix.host.filesystem.swapSize = "0G";
|
||||
};
|
||||
}
|
||||
50
variants/nix-zima.nix
Normal file
50
variants/nix-zima.nix
Normal file
@@ -0,0 +1,50 @@
|
||||
# ============================================================================
|
||||
# Desktop Configuration
|
||||
# ============================================================================
|
||||
# Hardware and boot configuration for standard desktop workstations.
|
||||
# Includes Intel CPU support and NVMe storage.
|
||||
|
||||
{ inputs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
# ========== Boot Configuration ==========
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"xhci_pci" # USB 3.0 support
|
||||
"usb_storage" # USB storage devices
|
||||
"sd_mod" # SD card support
|
||||
"sdhci_pci" # SD card host controller
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||
boot.extraModulePackages = [ ];
|
||||
boot.kernelParams = [
|
||||
"quiet" # Minimal boot messages
|
||||
"splash" # Show Plymouth boot splash
|
||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||
"udev.log_priority=3" # Reduce udev logging
|
||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||
];
|
||||
|
||||
# ========== Filesystem Configuration ==========
|
||||
athenix.host.filesystem.useSwap = lib.mkDefault false;
|
||||
athenix.host.filesystem.device = lib.mkDefault "/dev/mmcblk0";
|
||||
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
|
||||
# ========== Hardware Configuration ==========
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
|
||||
# ========== Software Profile ==========
|
||||
athenix.sw.enable = lib.mkDefault true;
|
||||
athenix.sw.type = lib.mkDefault "desktop";
|
||||
}
|
||||
Reference in New Issue
Block a user