refactor: define options where they are used
This commit is contained in:
@@ -5,29 +5,18 @@
|
|||||||
# - Disko partition layout (EFI, swap, root)
|
# - Disko partition layout (EFI, swap, root)
|
||||||
# - Bootloader configuration (systemd-boot with Plymouth)
|
# - Bootloader configuration (systemd-boot with Plymouth)
|
||||||
# - Filesystem options (device, swap size)
|
# - Filesystem options (device, swap size)
|
||||||
# - Build method options (ISO, iPXE, LXC, Proxmox)
|
# - Build method options (used by installer/artifacts.nix)
|
||||||
# - Garbage collection settings
|
|
||||||
# - Convenience options (forUser, useHostPrefix)
|
# - Convenience options (forUser, useHostPrefix)
|
||||||
|
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
options.athenix = {
|
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.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
host = {
|
host = {
|
||||||
useHostPrefix = lib.mkOption {
|
useHostPrefix = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether to prepend the host prefix to the hostname (used in inventory).";
|
description = "Whether to prepend the host prefix to the hostname (used in inventory and hosts/default.nix).";
|
||||||
};
|
};
|
||||||
filesystem = {
|
filesystem = {
|
||||||
device = lib.mkOption {
|
device = lib.mkOption {
|
||||||
@@ -44,53 +33,10 @@
|
|||||||
description = "The size of the swap partition.";
|
description = "The size of the swap partition.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
buildMethods = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.str;
|
|
||||||
default = [ "installer-iso" ];
|
|
||||||
description = ''
|
|
||||||
List of allowed build methods for this host.
|
|
||||||
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.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
system.gc = {
|
config = {
|
||||||
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.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkMerge [
|
|
||||||
# Enable forUser if specified
|
|
||||||
(lib.mkIf (config.athenix.forUser != null) {
|
|
||||||
athenix.users.${config.athenix.forUser}.enable = true;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Main configuration
|
|
||||||
{
|
|
||||||
# ========== Disk Partitioning (Disko) ==========
|
# ========== Disk Partitioning (Disko) ==========
|
||||||
disko.enableConfig = lib.mkDefault true;
|
disko.enableConfig = lib.mkDefault true;
|
||||||
|
|
||||||
@@ -187,8 +133,5 @@
|
|||||||
SuspendState=freeze
|
SuspendState=freeze
|
||||||
HibernateDelaySec=2h
|
HibernateDelaySec=2h
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
system.stateVersion = "25.11"; # Did you read the comment?
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,63 @@
|
|||||||
inputs.disko.nixosModules.disko
|
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";
|
system.stateVersion = "25.11";
|
||||||
|
|
||||||
nix.settings.experimental-features = [
|
nix.settings.experimental-features = [
|
||||||
@@ -45,3 +102,5 @@
|
|||||||
# Optimize storage
|
# Optimize storage
|
||||||
nix.optimise.automatic = config.athenix.system.gc.optimise;
|
nix.optimise.automatic = config.athenix.system.gc.optimise;
|
||||||
}
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ let
|
|||||||
allModules =
|
allModules =
|
||||||
userNixosModules
|
userNixosModules
|
||||||
++ [
|
++ [
|
||||||
|
(import ./common.nix { inherit inputs; })
|
||||||
typeModule
|
typeModule
|
||||||
overrideModule
|
overrideModule
|
||||||
{ networking.hostName = hostName; }
|
{ networking.hostName = hostName; }
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(import ../common.nix { inherit inputs; })
|
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(import ../common.nix { inherit inputs; })
|
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(import ../common.nix { inherit inputs; })
|
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(import ../common.nix { inherit inputs; })
|
|
||||||
inputs.vscode-server.nixosModules.default
|
inputs.vscode-server.nixosModules.default
|
||||||
"${modulesPath}/virtualisation/proxmox-lxc.nix"
|
"${modulesPath}/virtualisation/proxmox-lxc.nix"
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(import ../common.nix { inherit inputs; })
|
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
inputs.nixos-hardware.nixosModules.microsoft-surface-go
|
inputs.nixos-hardware.nixosModules.microsoft-surface-go
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(import ../common.nix { inherit inputs; })
|
|
||||||
inputs.nixos-wsl.nixosModules.default
|
inputs.nixos-wsl.nixosModules.default
|
||||||
inputs.vscode-server.nixosModules.default
|
inputs.vscode-server.nixosModules.default
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(import ../common.nix { inherit inputs; })
|
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user