Restructure partition config

This commit is contained in:
Manuel Thalmann 2024-12-07 12:24:10 +01:00
parent 77d8c350b7
commit ce13e03ef1
6 changed files with 53 additions and 22 deletions

View file

@ -0,0 +1,27 @@
{ lib, config, ... }:
let
inherit (lib) types mkOption;
in {
imports = [
./partition/disks.nix
];
options = {
valhalla = {
fileSystems = {
script = mkOption {
type = types.str;
description = "The script for preparing the system's mounts.";
};
};
};
};
config = {
valhalla = {
fileSystems = {
script = config.valhalla.fileSystems.diskSetup.script;
};
};
};
}

View file

@ -291,27 +291,29 @@ in
{ {
options = { options = {
valhalla = { valhalla = {
partition = { fileSystems = {
rootDir = mkOption { rootDir = mkOption {
type = types.str; type = types.str;
description = "The root of the installation directory to mount disks into."; description = "The root of the installation directory to mount disks into.";
default = "/mnt"; default = "/mnt";
}; };
os = mkOption { diskSetup = {
type = mkDiskType true; osDisk = mkOption {
description = "The partition layout of the OS disk."; type = mkDiskType true;
}; description = "The partition layout of the OS disk.";
};
disks = mkOption { disks = mkOption {
type = types.attrsOf (mkDiskType false); type = types.attrsOf (mkDiskType false);
description = "The additional disks to format."; description = "The additional disks to format.";
default = { }; default = { };
}; };
script = mkOption { script = mkOption {
type = types.str; type = types.str;
description = "The script for partitioning the system's disks."; description = "The script for partitioning the system's disks.";
};
}; };
}; };
}; };
@ -319,14 +321,15 @@ in
config = { config = {
valhalla = { valhalla = {
partition = { fileSystems.diskSetup = {
script = lib.mkDefault ( script = lib.mkDefault (
let let
cfg = config.valhalla.partition; cfg = config.valhalla.fileSystems;
inherit (cfg) os rootDir; inherit (cfg) rootDir;
inherit (cfg.diskSetup) osDisk;
inherit (lib.strings) normalizePath; inherit (lib.strings) normalizePath;
partPath = part: "/dev/disk/by-label/${part.label}"; partPath = part: "/dev/disk/by-label/${part.label}";
disks = ([ os ] ++ (builtins.attrValues cfg.disks)); disks = ([ osDisk ] ++ (builtins.attrValues cfg.diskSetup.disks));
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks); partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
mountScript = lib.strings.concatLines (builtins.concatMap mountScript = lib.strings.concatLines (builtins.concatMap

View file

@ -2,6 +2,7 @@
let inherit (lib) mkOption types; let inherit (lib) mkOption types;
in { in {
imports = [ imports = [
./fileSystems.nix
./hardware.nix ./hardware.nix
./i18n.nix ./i18n.nix
./os.nix ./os.nix

View file

@ -25,7 +25,7 @@
}; };
}; };
partition.os.partitions = { fileSystems.diskSetup.osDisk.partitions = {
# Keep Windows' boot partition # Keep Windows' boot partition
Boot.keepExisting = true; Boot.keepExisting = true;

View file

@ -5,8 +5,8 @@ in {
config = { config = {
valhalla = { valhalla = {
partition = { fileSystems.diskSetup = {
os = { osDisk = {
partitions = { partitions = {
Boot = { Boot = {
index = 1; index = 1;

View file

@ -5,8 +5,8 @@ in {
config = { config = {
valhalla = { valhalla = {
partition = { fileSystems.diskSetup = {
os = { osDisk = {
partitions = { partitions = {
Boot = { Boot = {
index = 1; index = 1;