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