diff --git a/lib/modules/i18n.nix b/lib/modules/i18n.nix index e4324fc78..327fd18aa 100644 --- a/lib/modules/i18n.nix +++ b/lib/modules/i18n.nix @@ -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 = {}; + }; }; }; }; diff --git a/lib/modules/partition/disks.nix b/lib/modules/partition/disks.nix index 87f702e6c..9a38e75b8 100644 --- a/lib/modules/partition/disks.nix +++ b/lib/modules/partition/disks.nix @@ -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 + ] + ); + }; }; }; } diff --git a/profiles/DerGeret/config.nix b/profiles/DerGeret/config.nix index e255ce9c4..1fa393d5b 100644 --- a/profiles/DerGeret/config.nix +++ b/profiles/DerGeret/config.nix @@ -4,7 +4,7 @@ ]; config = { - partition.os.partitions = { + valhalla.partition.os.partitions = { # Keep Windows' boot partition Boot.keepExisting = true; diff --git a/profiles/Generic/Arch/config.nix b/profiles/Generic/Arch/config.nix index 055d32854..98992698a 100644 --- a/profiles/Generic/Arch/config.nix +++ b/profiles/Generic/Arch/config.nix @@ -4,7 +4,7 @@ ]; config = { - partition.os.partitions = { + valhalla.partition.os.partitions = { OS.label = "Arch"; }; }; diff --git a/profiles/Generic/config.nix b/profiles/Generic/config.nix index 759a7d874..feaa924db 100644 --- a/profiles/Generic/config.nix +++ b/profiles/Generic/config.nix @@ -8,40 +8,42 @@ ]; config = { - partition = { - os = { - partitions = { - Boot = { - index = 1; - type = "uefi"; - size = "+1G"; - format = fs.fat32; - mountPoint = "/boot"; - }; + valhalla = { + partition = { + os = { + partitions = { + Boot = { + index = 1; + type = "uefi"; + size = "+1G"; + format = fs.fat32; + mountPoint = "/boot"; + }; - Swap = { - index = 2; - type = "swap"; - }; + Swap = { + index = 2; + type = "swap"; + }; - OS = { - index = 3; - type = "linux"; - format = fs.ext4; - mountPoint = "/"; + OS = { + index = 3; + type = "linux"; + format = fs.ext4; + mountPoint = "/"; + }; }; }; }; - }; - i18n = { - localeSettings = - let defaultLocale = "en_US.UTF-8"; - in { - LANG = "de_CH.UTF-8"; - LANGUAGE = defaultLocale; - LC_MESSAGE = defaultLocale; - }; + i18n = { + localeSettings = + let defaultLocale = "en_US.UTF-8"; + in { + LANG = "de_CH.UTF-8"; + LANGUAGE = defaultLocale; + LC_MESSAGE = defaultLocale; + }; + }; }; }; } diff --git a/profiles/ManuSurface/config.nix b/profiles/ManuSurface/config.nix index c092d2513..937f30764 100644 --- a/profiles/ManuSurface/config.nix +++ b/profiles/ManuSurface/config.nix @@ -4,6 +4,6 @@ ]; config = { - partition.os.deviceName = "nvme0n1"; + valhalla.partition.os.deviceName = "nvme0n1"; }; } diff --git a/scripts/Arch/OS/setup.fish b/scripts/Arch/OS/setup.fish index d60f7acab..a3d312431 100644 --- a/scripts/Arch/OS/setup.fish +++ b/scripts/Arch/OS/setup.fish @@ -6,7 +6,7 @@ begin set -q CONFIG_MODULE || set -l CONFIG_MODULE "$dir/config.nix" set -q ARCH_TIMEZONE || set -l ARCH_TIMEZONE "Europe/Zurich" - set -q ARCH_MOUNT_ROOT || set -l ARCH_MOUNT_ROOT (getConfig partition.rootDir --raw) + set -q ARCH_MOUNT_ROOT || set -l ARCH_MOUNT_ROOT (getConfig valhalla.partition.rootDir --raw) set -q ARCH_LANG || set -l ARCH_LANG en_US.UTF-8 set -q ARCH_KEYMAP || set -l ARCH_KEYMAP de_CH-latin1 set -q ARCH_X11_KEYMAP || set -l ARCH_X11_KEYMAP ch @@ -49,7 +49,7 @@ begin and arch-chroot "$ARCH_MOUNT_ROOT" hwclock --systohc and begin - getConfig i18n.localeSettings --json | \ + getConfig valhalla.i18n.localeSettings --json | \ jq --raw-output '[.[] | split(".") | .[0]] | unique | join("\\\\|")' end | begin read LOCALES @@ -57,7 +57,7 @@ begin end and begin - getConfig i18n.localeSettings --json | \ + getConfig valhalla.i18n.localeSettings --json | \ jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")' end | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/locale.conf > /dev/null diff --git a/scripts/Arch/OS/setup.sh b/scripts/Arch/OS/setup.sh index e6c7ef4c7..bc71614c9 100755 --- a/scripts/Arch/OS/setup.sh +++ b/scripts/Arch/OS/setup.sh @@ -5,7 +5,7 @@ pushd "${BASH_SOURCE%/*}" > /dev/null; CONFIG_MODULE="${CONFIG_MODULE:-"./config.nix"}"; ARCH_TIMEZONE="${ARCH_TIMEZONE:-"Europe/Zurich"}"; ARCH_HOSTNAME="${ARCH_HOSTNAME}"; -ARCH_MOUNT_ROOT="${ARCH_MOUNT_ROOT:-"$(../../eval-module.sh "$CONFIG_MODULE" partition.rootDir --raw)"}"; +ARCH_MOUNT_ROOT="${ARCH_MOUNT_ROOT:-"$(../../eval-module.sh "$CONFIG_MODULE" valhalla.partition.rootDir --raw)"}"; ARCH_LANG="${ARCH_LANG:-"en_US.UTF-8"}"; ARCH_KEYMAP="${ARCH_KEYMAP:-"de_CH-latin1"}"; ARCH_X11_KEYMAP="${ARCH_X11_KEYMAP:-"ch"}"; diff --git a/scripts/Common/OS/partition.sh b/scripts/Common/OS/partition.sh index 8a64620c5..d19aa9b71 100755 --- a/scripts/Common/OS/partition.sh +++ b/scripts/Common/OS/partition.sh @@ -1,2 +1,2 @@ #!/bin/bash -eval "$("${BASH_SOURCE%/*}/../../eval-module.sh" "$CONFIG_MODULE" partition.script --raw)"; +eval "$("${BASH_SOURCE%/*}/../../eval-module.sh" "$CONFIG_MODULE" valhalla.partition.script --raw)";