refactor: Fleet and sw behind mkIf guards

This commit is contained in:
UGA Innovation Factory
2026-01-27 16:11:36 -05:00
parent 85653e632f
commit 063336f736
5 changed files with 156 additions and 90 deletions

View File

@@ -5,44 +5,60 @@
# - Bootloader configuration (systemd-boot with Plymouth) # - Bootloader configuration (systemd-boot with Plymouth)
# - Timezone and locale settings # - Timezone and locale settings
# - Systemd sleep configuration # - Systemd sleep configuration
#
# Only applies to:
# - Linux systems (not Darwin/macOS)
# - Systems with actual boot hardware (not containers/WSL)
{ lib, ... }:
{ {
boot = { config,
loader.systemd-boot.enable = lib.mkDefault true; lib,
loader.efi.canTouchEfiVariables = lib.mkDefault true; pkgs,
plymouth.enable = lib.mkDefault true; ...
}:
# Enable "Silent boot" let
consoleLogLevel = 3; # Check if this is a bootable system (not container, not WSL)
initrd.verbose = false; isBootable = !(config.boot.isContainer or false) && (pkgs.stdenv.isLinux);
in
{
config = lib.mkIf isBootable {
boot = {
loader.systemd-boot.enable = lib.mkDefault true;
loader.efi.canTouchEfiVariables = lib.mkDefault true;
plymouth.enable = lib.mkDefault true;
# Hide the OS choice for bootloaders. # Enable "Silent boot"
# It's still possible to open the bootloader list by pressing any key consoleLogLevel = 3;
# It will just not appear on screen unless a key is pressed initrd.verbose = false;
loader.timeout = lib.mkDefault 0;
# Hide the OS choice for bootloaders.
# It's still possible to open the bootloader list by pressing any key
# It will just not appear on screen unless a key is pressed
loader.timeout = lib.mkDefault 0;
};
# Set your time zone.
time.timeZone = "America/New_York";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
systemd.sleep.extraConfig = ''
SuspendState=freeze
HibernateDelaySec=2h
'';
}; };
# Set your time zone.
time.timeZone = "America/New_York";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
systemd.sleep.extraConfig = ''
SuspendState=freeze
HibernateDelaySec=2h
'';
} }

View File

@@ -4,9 +4,17 @@
# This module defines: # This module defines:
# - Disko partition layout (EFI, swap, root) # - Disko partition layout (EFI, swap, root)
# - Filesystem options (device, swap size) # - Filesystem options (device, swap size)
#
# Only applies to systems with physical disk management needs
# (not containers, not WSL, not systems without a configured device)
{ config, lib, ... }: { config, lib, ... }:
let
cfg = config.athenix.host.filesystem;
# Only enable disk config if device is set and disko is enabled
hasDiskConfig = cfg.device != null && config.disko.enableConfig;
in
{ {
options.athenix = { options.athenix = {
host.filesystem = { host.filesystem = {
@@ -49,63 +57,67 @@
}; };
}; };
config = { config = lib.mkMerge [
# ========== Disk Partitioning (Disko) ========== {
disko.enableConfig = lib.mkDefault (config.athenix.host.filesystem.device != null); # ========== Disk Partitioning (Disko) ==========
disko.enableConfig = lib.mkDefault (cfg.device != null);
}
disko.devices = { (lib.mkIf hasDiskConfig {
disk.main = { disko.devices = {
type = "disk"; disk.main = {
device = config.athenix.host.filesystem.device; type = "disk";
content = { device = cfg.device;
type = "gpt"; content = {
partitions = { type = "gpt";
# EFI System Partition partitions = {
ESP = { # EFI System Partition
name = "ESP"; ESP = {
label = "BOOT"; name = "ESP";
size = "1G"; label = "BOOT";
type = "EF00"; size = "1G";
content = { type = "EF00";
type = "filesystem"; content = {
format = "vfat"; type = "filesystem";
mountpoint = "/boot"; format = "vfat";
mountOptions = [ "umask=0077" ]; mountpoint = "/boot";
extraArgs = [ mountOptions = [ "umask=0077" ];
"-n" extraArgs = [
"BOOT" "-n"
]; "BOOT"
];
};
}; };
};
# Swap Partition (size configurable per host) # Swap Partition (size configurable per host)
swap = lib.mkIf config.athenix.host.filesystem.useSwap { swap = lib.mkIf cfg.useSwap {
name = "swap"; name = "swap";
label = "swap"; label = "swap";
size = config.athenix.host.filesystem.swapSize; size = cfg.swapSize;
content = { content = {
type = "swap"; type = "swap";
};
}; };
};
# Root Partition (takes remaining space) # Root Partition (takes remaining space)
root = { root = {
name = "root"; name = "root";
label = "root"; label = "root";
size = "100%"; size = "100%";
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/"; mountpoint = "/";
extraArgs = [ extraArgs = [
"-L" "-L"
"ROOT" "ROOT"
]; ];
};
}; };
}; };
}; };
}; };
}; };
}; })
}; ];
} }

View File

@@ -1,4 +1,6 @@
{ {
config,
lib,
pkgs, pkgs,
... ...
}: }:
@@ -10,7 +12,11 @@
# It reconstructs the terminfo database from the provided definition and # It reconstructs the terminfo database from the provided definition and
# adds it to the system packages. # adds it to the system packages.
with lib;
let let
cfg = config.athenix.sw;
ghostty-terminfo = pkgs.runCommand "ghostty-terminfo" { } '' ghostty-terminfo = pkgs.runCommand "ghostty-terminfo" { } ''
mkdir -p $out/share/terminfo mkdir -p $out/share/terminfo
cat > ghostty.info <<'EOF' cat > ghostty.info <<'EOF'
@@ -99,5 +105,7 @@ let
''; '';
in in
{ {
environment.systemPackages = [ ghostty-terminfo ]; config = mkIf cfg.enable {
environment.systemPackages = [ ghostty-terminfo ];
};
} }

View File

@@ -18,10 +18,27 @@ let
cfg = config.athenix.sw.python; cfg = config.athenix.sw.python;
in in
{ {
options.athenix.sw.python = { options.athenix.sw.python = lib.mkOption {
enable = mkEnableOption "Python development tools (pixi, uv)" // { type = lib.types.submodule {
default = true; options = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enable Python development tools (pixi, uv).
Provides:
- pixi: Fast, cross-platform package manager for Python
- uv: Extremely fast Python package installer and resolver
These tools manage project-based dependencies rather than global
Python packages, avoiding conflicts and improving reproducibility.
'';
};
};
}; };
default = { };
description = "Python development environment configuration.";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {

View File

@@ -1,6 +1,18 @@
{ pkgs, ... }:
{ {
environment.systemPackages = with pkgs; [ config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.athenix.sw;
in
{
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
python3 python3
git git
(pkgs.writeShellScriptBin "update-ref" '' (pkgs.writeShellScriptBin "update-ref" ''
@@ -508,4 +520,5 @@
printf " rev = %s\n" "$CUR_REV" >&2 printf " rev = %s\n" "$CUR_REV" >&2
'') '')
]; ];
};
} }