Prefix valhalla related settings
This commit is contained in:
parent
2ca85d797b
commit
42c7d24198
9 changed files with 113 additions and 104 deletions
|
@ -6,11 +6,13 @@
|
|||
;
|
||||
in {
|
||||
options = {
|
||||
i18n = {
|
||||
localeSettings = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
description = "The system wide locale settings";
|
||||
default = {};
|
||||
valhalla = {
|
||||
i18n = {
|
||||
localeSettings = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
description = "The system wide locale settings";
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -286,80 +286,85 @@
|
|||
);
|
||||
in {
|
||||
options = {
|
||||
partition = {
|
||||
rootDir = mkOption {
|
||||
type = types.str;
|
||||
description = "The root of the installation directory to mount disks into.";
|
||||
default = "/mnt";
|
||||
};
|
||||
valhalla = {
|
||||
partition = {
|
||||
rootDir = mkOption {
|
||||
type = types.str;
|
||||
description = "The root of the installation directory to mount disks into.";
|
||||
default = "/mnt";
|
||||
};
|
||||
|
||||
os = mkOption {
|
||||
type = mkDiskType true;
|
||||
description = "The partition layout of the OS disk.";
|
||||
};
|
||||
os = mkOption {
|
||||
type = mkDiskType true;
|
||||
description = "The partition layout of the OS disk.";
|
||||
};
|
||||
|
||||
disks = mkOption {
|
||||
type = types.attrsOf (mkDiskType false);
|
||||
description = "The additional disks to format.";
|
||||
default = {};
|
||||
};
|
||||
disks = mkOption {
|
||||
type = types.attrsOf (mkDiskType false);
|
||||
description = "The additional disks to format.";
|
||||
default = {};
|
||||
};
|
||||
|
||||
script = mkOption {
|
||||
type = types.lines;
|
||||
description = "The script for partitioning the system's disks.";
|
||||
internal = true;
|
||||
script = mkOption {
|
||||
type = types.lines;
|
||||
description = "The script for partitioning the system's disks.";
|
||||
internal = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
partition = {
|
||||
script =
|
||||
let
|
||||
inherit (config.partition) os rootDir;
|
||||
inherit (lib.strings) normalizePath;
|
||||
valhalla = {
|
||||
partition = {
|
||||
script =
|
||||
let
|
||||
cfg = config.valhalla.partition;
|
||||
inherit (cfg) os rootDir;
|
||||
inherit (lib.strings) normalizePath;
|
||||
|
||||
partPath = part: "/dev/disk/by-label/${part.label}";
|
||||
disks = ([os] ++ (builtins.attrValues config.partition.disks));
|
||||
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
||||
partPath = part: "/dev/disk/by-label/${part.label}";
|
||||
disks = ([os] ++ (builtins.attrValues cfg.disks));
|
||||
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
||||
|
||||
mountScript = lib.strings.concatLines (
|
||||
builtins.map
|
||||
(_: builtins.concatStringsSep " " [
|
||||
"sudo"
|
||||
"mount"
|
||||
"--mkdir"
|
||||
(builtins.concatStringsSep " " (builtins.map (_: "-o ${_}") _.mountOptions))
|
||||
(partPath _)
|
||||
(normalizePath "/${rootDir}/${_.mountPoint}")
|
||||
])
|
||||
(lib.lists.sortOn
|
||||
(_: normalizePath "/${_.mountPoint}")
|
||||
(builtins.filter (_: _.mountPoint != null) partitions)));
|
||||
mountScript = lib.strings.concatLines (
|
||||
builtins.map
|
||||
(_: builtins.concatStringsSep " " [
|
||||
"sudo"
|
||||
"mount"
|
||||
"--mkdir"
|
||||
(builtins.concatStringsSep " " (builtins.map (_: "-o ${_}") _.mountOptions))
|
||||
(partPath _)
|
||||
(normalizePath "/${rootDir}/${_.mountPoint}")
|
||||
])
|
||||
(lib.lists.sortOn
|
||||
(_: normalizePath "/${_.mountPoint}")
|
||||
(builtins.filter (_: _.mountPoint != null) partitions)));
|
||||
|
||||
swapScript = lib.strings.concatLines (
|
||||
builtins.map
|
||||
(_: "sudo swapon ${partPath _}")
|
||||
(builtins.filter (_: _.useSwap) partitions));
|
||||
in lib.strings.concatLines (
|
||||
(builtins.map (_: _.deviceScript) disks) ++ lib.optionals ((builtins.length disks) > 0) [
|
||||
". ${./../../../scripts/Common/Scripts/is-truthy.sh}"
|
||||
''echo "$(tput setaf 3)==== WARNING ====$(tput sgr0)"''
|
||||
(''echo "Continuing this script will wipe the contents of '' + (
|
||||
lib.strings.concatStringsSep ", " (builtins.map (_: "${_.deviceVariable}") (lib.lists.init disks))
|
||||
) + (if (builtins.length disks) > 1 then " and " else "") + (lib.lists.last disks).deviceVariable + ''"'')
|
||||
''read -p "Are you sure you want to continue? [y/n] " answer''
|
||||
''
|
||||
if ! isTruthy "$answer"; then
|
||||
exit 1
|
||||
fi
|
||||
''
|
||||
] ++
|
||||
(builtins.map (_: _.script) disks) ++ [
|
||||
mountScript
|
||||
swapScript
|
||||
]
|
||||
);
|
||||
swapScript = lib.strings.concatLines (
|
||||
builtins.map
|
||||
(_: "sudo swapon ${partPath _}")
|
||||
(builtins.filter (_: _.useSwap) partitions));
|
||||
in lib.strings.concatLines (
|
||||
(builtins.map (_: _.deviceScript) disks) ++ lib.optionals ((builtins.length disks) > 0) [
|
||||
". ${./../../../scripts/Common/Scripts/is-truthy.sh}"
|
||||
''echo "$(tput setaf 3)==== WARNING ====$(tput sgr0)"''
|
||||
(''echo "Continuing this script will wipe the contents of '' + (
|
||||
lib.strings.concatStringsSep ", " (builtins.map (_: "${_.deviceVariable}") (lib.lists.init disks))
|
||||
) + (if (builtins.length disks) > 1 then " and " else "") + (lib.lists.last disks).deviceVariable + ''"'')
|
||||
''read -p "Are you sure you want to continue? [y/n] " answer''
|
||||
''
|
||||
if ! isTruthy "$answer"; then
|
||||
exit 1
|
||||
fi
|
||||
''
|
||||
] ++
|
||||
(builtins.map (_: _.script) disks) ++ [
|
||||
mountScript
|
||||
swapScript
|
||||
]
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue