diff --git a/lib/modules/fileSystems.nix b/lib/modules/fileSystems.nix index c036abcd..1bd50144 100644 --- a/lib/modules/fileSystems.nix +++ b/lib/modules/fileSystems.nix @@ -1,6 +1,7 @@ { lib, config, ... }: let inherit (lib) types mkOption; + cfg = config.valhalla.fileSystems; in { imports = [ ./partition/disks.nix @@ -20,7 +21,26 @@ in { config = { valhalla = { fileSystems = { - script = config.valhalla.fileSystems.diskSetup.script; + script = let + disks = (builtins.attrValues cfg.diskSetup.disks); + in '' + #!/bin/bash + set -o errexit + ${cfg.diskSetup.scripts.init} + ${lib.strings.concatLines (lib.optionals ((builtins.length disks) > 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 disks))) + + (if (builtins.length disks) > 1 then " and " else "") + (lib.lists.last disks).deviceVariable + ''"'') + '' + if ! fish ${./partition/confirm.fish} "Are you sure you want to continue?" "n"; then + exit 1 + fi + '' + ])} + ${cfg.diskSetup.scripts.partition} + ${cfg.diskSetup.scripts.mount} + ''; }; }; }; diff --git a/lib/modules/partition/disks.nix b/lib/modules/partition/disks.nix index 17b5561f..b629df83 100644 --- a/lib/modules/partition/disks.nix +++ b/lib/modules/partition/disks.nix @@ -314,35 +314,6 @@ in description = "The script for mounting the partitioned disks."; }; }; - - script = mkOption { - type = types.str; - description = "The script for partitioning the system's disks."; - default = - let - cfg = config.valhalla.fileSystems.diskSetup; - inherit (cfg) scripts; - disks = (builtins.attrValues cfg.disks); - in - '' - #!/bin/bash - set -o errexit - ${scripts.init} - ${lib.strings.concatLines (lib.optionals ((builtins.length disks) > 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 disks))) - + (if (builtins.length disks) > 1 then " and " else "") + (lib.lists.last disks).deviceVariable + ''"'') - '' - if ! fish ${./confirm.fish} "Are you sure you want to continue?" "n"; then - exit 1 - fi - '' - ])} - ${scripts.partition} - ${scripts.mount} - ''; - }; }; }; };