- Add glue/ for fleet generation logic and common configuration - Add variants/ for hardware type modules - Improves separation of concerns and module organization
100 lines
3.0 KiB
Nix
100 lines
3.0 KiB
Nix
# ============================================================================
|
|
# Common Host Module
|
|
# ============================================================================
|
|
# This module contains all the common configuration shared by all host types.
|
|
# It is automatically imported by the fleet generator for every host.
|
|
|
|
{ inputs }:
|
|
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
{
|
|
imports = [
|
|
./boot.nix
|
|
./user-config.nix
|
|
../sw
|
|
../users.nix
|
|
inputs.home-manager.nixosModules.home-manager
|
|
inputs.agenix.nixosModules.default
|
|
inputs.disko.nixosModules.disko
|
|
];
|
|
|
|
# Define garbage collection options here since they're consumed in this module
|
|
options.athenix = {
|
|
forUser = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
description = ''
|
|
Convenience option to configure a host for a specific user.
|
|
Automatically enables the user (sets athenix.users.username.enable = true).
|
|
Value should be a username from athenix.users.accounts.
|
|
'';
|
|
};
|
|
|
|
system.gc = {
|
|
enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Whether to enable automatic garbage collection.";
|
|
};
|
|
frequency = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "weekly";
|
|
description = "How often to run garbage collection (systemd timer format).";
|
|
};
|
|
retentionDays = lib.mkOption {
|
|
type = lib.types.int;
|
|
default = 30;
|
|
description = "Number of days to keep old generations before deletion.";
|
|
};
|
|
optimise = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Whether to automatically optimize the Nix store.";
|
|
};
|
|
};
|
|
|
|
host.buildMethods = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ "installer-iso" ];
|
|
description = ''
|
|
List of allowed build methods for this host (used by installer/artifacts.nix).
|
|
Supported methods:
|
|
- "installer-iso": Generates an auto-install ISO that installs this configuration to disk.
|
|
- "iso": Generates a live ISO (using nixos-generators).
|
|
- "ipxe": Generates iPXE netboot artifacts (kernel, initrd, script).
|
|
- "lxc": Generates an LXC container tarball.
|
|
- "proxmox": Generates a Proxmox VMA archive.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkMerge [
|
|
# Enable forUser if specified
|
|
(lib.mkIf (config.athenix.forUser != null) {
|
|
athenix.users.${config.athenix.forUser}.enable = true;
|
|
})
|
|
|
|
{
|
|
system.stateVersion = "25.11";
|
|
|
|
nix.settings.experimental-features = [
|
|
"nix-command"
|
|
"flakes"
|
|
];
|
|
|
|
# Automatic Garbage Collection
|
|
nix.gc = lib.mkIf config.athenix.system.gc.enable {
|
|
automatic = true;
|
|
dates = config.athenix.system.gc.frequency;
|
|
options = "--delete-older-than ${toString config.athenix.system.gc.retentionDays}d";
|
|
};
|
|
|
|
# Optimize storage
|
|
nix.optimise.automatic = config.athenix.system.gc.optimise;
|
|
}
|
|
];
|
|
}
|