refactor: Module to ugaif and readme update
This commit is contained in:
committed by
Hunter Halloran
parent
c46b0aa685
commit
205f03337a
@@ -8,11 +8,11 @@
|
||||
# Boot & Storage Configuration
|
||||
# ============================================================================
|
||||
# This module defines the Disko partition layout and bootloader settings.
|
||||
# It exposes 'host.filesystem' options to allow per-host overrides of
|
||||
# It exposes 'ugaif.host.filesystem' options to allow per-host overrides of
|
||||
# the target device and swap size.
|
||||
|
||||
{
|
||||
options.host = {
|
||||
options.ugaif.host = {
|
||||
filesystem = {
|
||||
device = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
@@ -45,7 +45,7 @@
|
||||
disko.devices = {
|
||||
disk.main = {
|
||||
type = "disk";
|
||||
device = config.host.filesystem.device;
|
||||
device = config.ugaif.host.filesystem.device;
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
@@ -71,7 +71,7 @@
|
||||
swap = {
|
||||
name = "swap";
|
||||
label = "swap";
|
||||
size = config.host.filesystem.swapSize;
|
||||
size = config.ugaif.host.filesystem.swapSize;
|
||||
content = {
|
||||
type = "swap";
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ let
|
||||
# We use legacyPackages to evaluate the simple data structure of users.nix
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
usersData = import ../users.nix { inherit pkgs; };
|
||||
accounts = usersData.modules.users.accounts or { };
|
||||
accounts = usersData.ugaif.users.accounts or { };
|
||||
|
||||
# Extract flakeUrls and convert to modules
|
||||
userFlakeModules = lib.mapAttrsToList (
|
||||
@@ -70,6 +70,14 @@ let
|
||||
else
|
||||
{ }
|
||||
) accounts;
|
||||
|
||||
allModules =
|
||||
commonModules
|
||||
++ userFlakeModules
|
||||
++ extraModules
|
||||
++ [
|
||||
{ networking.hostName = hostName; }
|
||||
];
|
||||
in
|
||||
{
|
||||
system = lib.nixosSystem {
|
||||
@@ -77,21 +85,9 @@ let
|
||||
|
||||
specialArgs = { inherit inputs; };
|
||||
|
||||
modules =
|
||||
commonModules
|
||||
++ userFlakeModules
|
||||
++ extraModules
|
||||
++ [
|
||||
{ networking.hostName = hostName; }
|
||||
];
|
||||
modules = allModules;
|
||||
};
|
||||
modules =
|
||||
commonModules
|
||||
++ userFlakeModules
|
||||
++ extraModules
|
||||
++ [
|
||||
{ networking.hostName = hostName; }
|
||||
];
|
||||
modules = allModules;
|
||||
};
|
||||
|
||||
# Function to generate a set of hosts based on inventory count and overrides
|
||||
@@ -127,27 +123,22 @@ let
|
||||
overrideModule =
|
||||
{ ... }:
|
||||
let
|
||||
# Remove special keys for filesystem overrides, keep other config attrs
|
||||
fsConf = builtins.removeAttrs devConf [
|
||||
# Extract device-specific config, removing special keys that need custom handling
|
||||
baseConfig = lib.removeAttrs devConf [
|
||||
"extraUsers"
|
||||
"flakeUrl"
|
||||
"hostname"
|
||||
"modules"
|
||||
"buildMethods"
|
||||
"wslUser"
|
||||
];
|
||||
extraConfig = lib.removeAttrs devConf [
|
||||
"extraUsers"
|
||||
"flakeUrl"
|
||||
"hostname"
|
||||
"buildMethods"
|
||||
"wslUser"
|
||||
# Handle special keys that map to specific ugaif options
|
||||
specialConfig = lib.mkMerge [
|
||||
(lib.optionalAttrs (devConf ? extraUsers) { ugaif.users.enabledUsers = devConf.extraUsers; })
|
||||
(lib.optionalAttrs (devConf ? buildMethods) { ugaif.host.buildMethods = devConf.buildMethods; })
|
||||
(lib.optionalAttrs (devConf ? wslUser) { ugaif.host.wsl.user = devConf.wslUser; })
|
||||
];
|
||||
in
|
||||
lib.mkIf hasOverride (lib.recursiveUpdate (lib.recursiveUpdate {
|
||||
host.filesystem = fsConf;
|
||||
modules.users.enabledUsers = devConf.extraUsers or [ ];
|
||||
} (lib.optionalAttrs (devConf ? buildMethods) { host.buildMethods = devConf.buildMethods; } // lib.optionalAttrs (devConf ? wslUser) { host.wsl.user = devConf.wslUser; })) extraConfig);
|
||||
lib.mkIf hasOverride (lib.recursiveUpdate baseConfig specialConfig);
|
||||
|
||||
config = mkHost {
|
||||
hostName = hostName;
|
||||
|
||||
@@ -28,16 +28,16 @@
|
||||
"rd.systemd.show_status=auto"
|
||||
];
|
||||
|
||||
host.filesystem.swapSize = lib.mkDefault "16G";
|
||||
host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
||||
host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
ugaif.host.filesystem.swapSize = lib.mkDefault "16G";
|
||||
ugaif.host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
||||
ugaif.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
}
|
||||
)
|
||||
{
|
||||
modules.sw.enable = true;
|
||||
modules.sw.type = "desktop";
|
||||
ugaif.sw.enable = true;
|
||||
ugaif.sw.type = "desktop";
|
||||
}
|
||||
]
|
||||
|
||||
@@ -31,10 +31,13 @@
|
||||
];
|
||||
|
||||
# Ephemeral setup: No swap, no disk
|
||||
host.filesystem.swapSize = lib.mkForce "0G";
|
||||
host.filesystem.device = lib.mkForce "/dev/null"; # Dummy device
|
||||
host.buildMethods = lib.mkDefault [ "iso" "ipxe" ];
|
||||
|
||||
ugaif.host.filesystem.swapSize = lib.mkForce "0G";
|
||||
ugaif.host.filesystem.device = lib.mkForce "/dev/null"; # Dummy device
|
||||
ugaif.host.buildMethods = lib.mkDefault [
|
||||
"iso"
|
||||
"ipxe"
|
||||
];
|
||||
|
||||
# Disable Disko config since we are running from RAM/ISO
|
||||
disko.enableConfig = lib.mkForce false;
|
||||
|
||||
@@ -42,7 +45,11 @@
|
||||
fileSystems."/" = {
|
||||
device = "none";
|
||||
fsType = "tmpfs";
|
||||
options = [ "defaults" "size=50%" "mode=755" ];
|
||||
options = [
|
||||
"defaults"
|
||||
"size=50%"
|
||||
"mode=755"
|
||||
];
|
||||
};
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
@@ -50,7 +57,7 @@
|
||||
}
|
||||
)
|
||||
{
|
||||
modules.sw.enable = true;
|
||||
modules.sw.type = "stateless-kiosk";
|
||||
ugaif.sw.enable = true;
|
||||
ugaif.sw.type = "stateless-kiosk";
|
||||
}
|
||||
]
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
|
||||
host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
||||
host.filesystem.swapSize = lib.mkDefault "34G";
|
||||
host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
ugaif.host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
||||
ugaif.host.filesystem.swapSize = lib.mkDefault "34G";
|
||||
ugaif.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
|
||||
# Suspend / logind behavior
|
||||
services.upower.enable = lib.mkDefault true;
|
||||
@@ -51,7 +51,7 @@
|
||||
}
|
||||
)
|
||||
{
|
||||
modules.sw.enable = true;
|
||||
modules.sw.type = "desktop";
|
||||
ugaif.sw.enable = true;
|
||||
ugaif.sw.type = "desktop";
|
||||
}
|
||||
]
|
||||
|
||||
@@ -35,11 +35,14 @@
|
||||
];
|
||||
services.vscode-server.enable = true;
|
||||
system.stateVersion = "25.11";
|
||||
host.buildMethods = lib.mkDefault [ "lxc" "proxmox" ];
|
||||
ugaif.host.buildMethods = lib.mkDefault [
|
||||
"lxc"
|
||||
"proxmox"
|
||||
];
|
||||
}
|
||||
)
|
||||
{
|
||||
modules.sw.enable = true;
|
||||
modules.sw.type = "headless";
|
||||
ugaif.sw.enable = true;
|
||||
ugaif.sw.type = "headless";
|
||||
}
|
||||
]
|
||||
|
||||
@@ -43,9 +43,9 @@
|
||||
|
||||
boot.kernelPackages = lib.mkForce refKernelPackages;
|
||||
|
||||
host.filesystem.swapSize = lib.mkDefault "8G";
|
||||
host.filesystem.device = lib.mkDefault "/dev/mmcblk0";
|
||||
host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
ugaif.host.filesystem.swapSize = lib.mkDefault "8G";
|
||||
ugaif.host.filesystem.device = lib.mkDefault "/dev/mmcblk0";
|
||||
ugaif.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
@@ -53,7 +53,7 @@
|
||||
)
|
||||
inputs.nixos-hardware.nixosModules.microsoft-surface-go
|
||||
{
|
||||
modules.sw.enable = true;
|
||||
modules.sw.type = "tablet-kiosk";
|
||||
ugaif.sw.enable = true;
|
||||
ugaif.sw.type = "tablet-kiosk";
|
||||
}
|
||||
]
|
||||
|
||||
@@ -2,35 +2,38 @@
|
||||
[
|
||||
inputs.nixos-wsl.nixosModules.default
|
||||
inputs.vscode-server.nixosModules.default
|
||||
({ lib, config, ... }: {
|
||||
options.host.wsl.user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "engr-ugaif";
|
||||
description = "The default user to log in as in WSL.";
|
||||
};
|
||||
(
|
||||
{ lib, config, ... }:
|
||||
{
|
||||
options.ugaif.host.wsl.user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "engr-ugaif";
|
||||
description = "The default user to log in as in WSL.";
|
||||
};
|
||||
|
||||
config = {
|
||||
wsl.enable = true;
|
||||
wsl.defaultUser = config.host.wsl.user;
|
||||
|
||||
# Enable the headless software profile
|
||||
modules.sw.enable = true;
|
||||
modules.sw.type = "headless";
|
||||
config = {
|
||||
wsl.enable = true;
|
||||
wsl.defaultUser = config.ugaif.host.wsl.user;
|
||||
|
||||
# Fix for VS Code Server in WSL if needed, though vscode-server input exists
|
||||
services.vscode-server.enable = true;
|
||||
# Enable the headless software profile
|
||||
ugaif.sw.enable = true;
|
||||
ugaif.sw.type = "headless";
|
||||
|
||||
# Disable Disko and Bootloader for WSL
|
||||
disko.enableConfig = lib.mkForce false;
|
||||
boot.loader.systemd-boot.enable = lib.mkForce false;
|
||||
boot.loader.grub.enable = lib.mkForce false;
|
||||
# Fix for VS Code Server in WSL if needed, though vscode-server input exists
|
||||
services.vscode-server.enable = true;
|
||||
|
||||
# Disable networking for wsl (it manages its own networking)
|
||||
systemd.network.enable = lib.mkForce false;
|
||||
|
||||
# Provide dummy values for required options from boot.nix
|
||||
host.filesystem.device = "/dev/null";
|
||||
host.filesystem.swapSize = "0G";
|
||||
};
|
||||
})
|
||||
# Disable Disko and Bootloader for WSL
|
||||
disko.enableConfig = lib.mkForce false;
|
||||
boot.loader.systemd-boot.enable = lib.mkForce false;
|
||||
boot.loader.grub.enable = lib.mkForce false;
|
||||
|
||||
# Disable networking for wsl (it manages its own networking)
|
||||
systemd.network.enable = lib.mkForce false;
|
||||
|
||||
# Provide dummy values for required options from boot.nix
|
||||
ugaif.host.filesystem.device = "/dev/null";
|
||||
ugaif.host.filesystem.swapSize = "0G";
|
||||
};
|
||||
}
|
||||
)
|
||||
]
|
||||
|
||||
@@ -77,7 +77,7 @@ let
|
||||
};
|
||||
in
|
||||
{
|
||||
options.modules.users = {
|
||||
options.ugaif.users = {
|
||||
shell = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = pkgs.bash;
|
||||
@@ -97,7 +97,7 @@ in
|
||||
|
||||
config = {
|
||||
# Default enabled users (always present)
|
||||
modules.users.enabledUsers = [
|
||||
ugaif.users.enabledUsers = [
|
||||
"root"
|
||||
"engr-ugaif"
|
||||
];
|
||||
@@ -106,8 +106,8 @@ in
|
||||
users.users =
|
||||
let
|
||||
enabledAccounts = lib.filterAttrs (
|
||||
name: _: lib.elem name config.modules.users.enabledUsers
|
||||
) config.modules.users.accounts;
|
||||
name: _: lib.elem name config.ugaif.users.enabledUsers
|
||||
) config.ugaif.users.accounts;
|
||||
in
|
||||
lib.mapAttrs (
|
||||
name: user:
|
||||
@@ -121,7 +121,7 @@ in
|
||||
description = if user.description != null then user.description else lib.mkDefault "";
|
||||
openssh.authorizedKeys.keys = user.opensshKeys;
|
||||
packages = finalPackages;
|
||||
shell = if user.shell != null then user.shell else config.modules.users.shell;
|
||||
shell = if user.shell != null then user.shell else config.ugaif.users.shell;
|
||||
}
|
||||
) enabledAccounts;
|
||||
|
||||
@@ -136,8 +136,8 @@ in
|
||||
users =
|
||||
let
|
||||
enabledAccounts = lib.filterAttrs (
|
||||
name: _: lib.elem name config.modules.users.enabledUsers
|
||||
) config.modules.users.accounts;
|
||||
name: _: lib.elem name config.ugaif.users.enabledUsers
|
||||
) config.ugaif.users.accounts;
|
||||
in
|
||||
lib.mapAttrs (
|
||||
name: user:
|
||||
|
||||
Reference in New Issue
Block a user