From c350a9c26b70e78aa437dfd234d4ee54445db391 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Sun, 25 Aug 2024 03:58:28 +0200
Subject: [PATCH] Fix recursive configuration

---
 lib/modules/os.nix           | 16 +++++++++++++++-
 scripts/Windows/OS/Setup.ps1 |  2 +-
 winiso/deploy.fish           |  2 +-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/modules/os.nix b/lib/modules/os.nix
index e855a74a..d5ed8e54 100644
--- a/lib/modules/os.nix
+++ b/lib/modules/os.nix
@@ -10,7 +10,21 @@
         type = types.submodule (
           { extendModules, ... }:
             let
-              osVariant = extendModules { };
+              osVariant = extendModules {
+                modules = [
+                  ({ config, ... }: {
+                    options = {
+                      config = mkOption {
+                        type = types.attrs;
+                        description = "The configuration of the Operating System.";
+                        default = builtins.removeAttrs config ["_module" "config" "linux" "windows"];
+                        visible = false;
+                      };
+                    };
+                  })
+                ];
+              };
+
               linuxVariant = osVariant.extendModules { };
               windowsVariant = osVariant.extendModules { };
             in {
diff --git a/scripts/Windows/OS/Setup.ps1 b/scripts/Windows/OS/Setup.ps1
index 6ecefd79..b2b6f99b 100644
--- a/scripts/Windows/OS/Setup.ps1
+++ b/scripts/Windows/OS/Setup.ps1
@@ -224,7 +224,7 @@ function Start-Setup {
     foreach ($xpath in @("./ua:AutoLogon/ua:Username",
                          "./ua:UserAccounts/ua:LocalAccounts/ua:LocalAccount/ua:Name",
                          "./ua:UserAccounts/ua:LocalAccounts/ua:LocalAccount/ua:DisplayName")) {
-        $oobeSettings.SelectSingleNode($xpath, $namespace).InnerText = $valhallaConfig.setupUser;
+        $oobeSettings.SelectSingleNode($xpath, $namespace).InnerText = $valhallaConfig.setupUser.name;
     }
 
     Add-StartupCommand `
diff --git a/winiso/deploy.fish b/winiso/deploy.fish
index c3ceab6f..0b829bd0 100755
--- a/winiso/deploy.fish
+++ b/winiso/deploy.fish
@@ -202,7 +202,7 @@ begin
 
             find "$projectPath/profiles" -type f -name "*.nix" | while read -l file
                 set -l CONFIG_MODULE "$file"
-                getConfig "valhalla.windows" --json > "$file.json"
+                getConfig "valhalla.windows.config" --json > "$file.json"
             end
         end