112 lines
3.2 KiB
Nix
112 lines
3.2 KiB
Nix
# ============================================================================
|
|
# FS & Storage Configuration
|
|
# ============================================================================
|
|
# This module defines:
|
|
# - Disko partition layout (EFI, swap, root)
|
|
# - Filesystem options (device, swap size)
|
|
|
|
{ config, lib, ... }:
|
|
|
|
{
|
|
options.athenix = {
|
|
host.filesystem = {
|
|
device = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
description = ''
|
|
The main disk device to use for automated partitioning and installation.
|
|
|
|
When set, enables disko for declarative disk management with:
|
|
- 1GB EFI boot partition
|
|
- Optional swap partition (see swapSize)
|
|
- Root partition using remaining space
|
|
|
|
Leave null for systems that don't need disk partitioning (containers, WSL).
|
|
'';
|
|
example = "/dev/nvme0n1";
|
|
};
|
|
useSwap = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = ''
|
|
Whether to create and use a swap partition.
|
|
Disable for systems with ample RAM or SSDs where swap is undesirable.
|
|
'';
|
|
};
|
|
swapSize = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
description = ''
|
|
Size of the swap partition (e.g., "16G", "32G").
|
|
|
|
Recommended sizes:
|
|
- 8-16GB for desktops with 16GB+ RAM
|
|
- 32GB for laptops (enables hibernation)
|
|
- Match RAM size for systems <8GB RAM
|
|
'';
|
|
example = "32G";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = {
|
|
# ========== Disk Partitioning (Disko) ==========
|
|
disko.enableConfig = lib.mkDefault (config.athenix.host.filesystem.device != null);
|
|
|
|
disko.devices = {
|
|
disk.main = {
|
|
type = "disk";
|
|
device = config.athenix.host.filesystem.device;
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
# EFI System Partition
|
|
ESP = {
|
|
name = "ESP";
|
|
label = "BOOT";
|
|
size = "1G";
|
|
type = "EF00";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = "/boot";
|
|
mountOptions = [ "umask=0077" ];
|
|
extraArgs = [
|
|
"-n"
|
|
"BOOT"
|
|
];
|
|
};
|
|
};
|
|
|
|
# Swap Partition (size configurable per host)
|
|
swap = lib.mkIf config.athenix.host.filesystem.useSwap {
|
|
name = "swap";
|
|
label = "swap";
|
|
size = config.athenix.host.filesystem.swapSize;
|
|
content = {
|
|
type = "swap";
|
|
};
|
|
};
|
|
|
|
# Root Partition (takes remaining space)
|
|
root = {
|
|
name = "root";
|
|
label = "root";
|
|
size = "100%";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "ext4";
|
|
mountpoint = "/";
|
|
extraArgs = [
|
|
"-L"
|
|
"ROOT"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|