2024-12-07 11:24:10 +00:00
|
|
|
{ lib, config, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib) types mkOption;
|
2024-12-07 16:35:31 +00:00
|
|
|
cfg = config.valhalla.fileSystems;
|
2024-12-07 11:24:10 +00:00
|
|
|
in {
|
|
|
|
imports = [
|
2024-12-07 17:36:19 +00:00
|
|
|
./fileSystems/disks.nix
|
2024-12-07 11:24:10 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
valhalla = {
|
|
|
|
fileSystems = {
|
|
|
|
script = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "The script for preparing the system's mounts.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
valhalla = {
|
|
|
|
fileSystems = {
|
2024-12-07 16:35:31 +00:00
|
|
|
script = let
|
2024-12-07 16:43:53 +00:00
|
|
|
devices = (builtins.attrValues cfg.diskSetup.devices);
|
2024-12-07 16:35:31 +00:00
|
|
|
in ''
|
|
|
|
#!/bin/bash
|
|
|
|
set -o errexit
|
|
|
|
${cfg.diskSetup.scripts.init}
|
2024-12-07 16:43:53 +00:00
|
|
|
${lib.strings.concatLines (lib.optionals ((builtins.length devices) > 0) [
|
2024-12-07 16:35:31 +00:00
|
|
|
''echo "$(tput setaf 3)=== WARNING ====$(tput sgr0)"''
|
|
|
|
(''echo "Continuing this script will alter the partitions of ''
|
2024-12-07 16:43:53 +00:00
|
|
|
+ (lib.strings.concatStringsSep ", " (builtins.map (_: "${_.deviceVariable}") (lib.lists.init devices)))
|
|
|
|
+ (if (builtins.length devices) > 1 then " and " else "") + (lib.lists.last devices).deviceVariable + ''"'')
|
2024-12-07 16:35:31 +00:00
|
|
|
''
|
2024-12-07 17:36:19 +00:00
|
|
|
if ! fish ${./fileSystems/confirm.fish} "Are you sure you want to continue?" "n"; then
|
2024-12-07 16:35:31 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
''
|
|
|
|
])}
|
|
|
|
${cfg.diskSetup.scripts.partition}
|
|
|
|
${cfg.diskSetup.scripts.mount}
|
|
|
|
'';
|
2024-12-07 11:24:10 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|