From 40b0bafcaca8cc7be1a76d16e3dfaef7dd025e78 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Sun, 28 Jul 2024 12:16:01 +0200
Subject: [PATCH] Make nix config accessible in scripts

---
 profiles/Generic/Windows/Setup.ps1 | 1 +
 scripts/Windows/OS/Setup.ps1       | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/profiles/Generic/Windows/Setup.ps1 b/profiles/Generic/Windows/Setup.ps1
index 78d0f3e8..258e57e6 100644
--- a/profiles/Generic/Windows/Setup.ps1
+++ b/profiles/Generic/Windows/Setup.ps1
@@ -1,5 +1,6 @@
 #!/bin/pwsh
 $env:WIN_COMPUTER_NAME ??= "win11";
 $env:SETUP_SCRIPT_NAME ??= "$PSScriptRoot/Install.ps1";
+$env:CONFIG_MODULE ??= "$PSScriptRoot/../config.nix";
 
 . "$PSScriptRoot/../../../scripts/Windows/OS/Setup.ps1";
diff --git a/scripts/Windows/OS/Setup.ps1 b/scripts/Windows/OS/Setup.ps1
index 28578a26..395e0413 100644
--- a/scripts/Windows/OS/Setup.ps1
+++ b/scripts/Windows/OS/Setup.ps1
@@ -3,6 +3,9 @@ $Global:InformationPreference = "Continue";
 $Global:ErrorActionPreference = "Inquire";
 $null = $env:WIN_COMPUTER_NAME;
 $null = $env:SETUP_SCRIPT_NAME;
+$null = $env:CONFIG_MODULE;
+
+$config = ConvertFrom-Json (Get-Content "$env:CONFIG_MODULE.json");
 
 [xml]$unattendedConfig = [xml]::new();
 $unattendedConfig.PreserveWhitespace = $true;
@@ -51,6 +54,7 @@ function Get-ScriptPathInjection($path) {
 $newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = `
     "powershell -Command " + `
     "`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" + `
+    "`$env:CONFIG_MODULE = $(Get-ScriptPathInjection $env:CONFIG_MODULE);" + `
     "Invoke-Expression $(Get-ScriptPathInjection "$PSScriptRoot/InitialBoot.ps1");";
 
 $orderElement = $newCommand.SelectSingleNode("./ua:Order", $namespace);