diff --git a/scripts/Windows/Scripts/Config.ps1 b/scripts/Windows/Scripts/Config.ps1 index d720961e..a4bcf477 100644 --- a/scripts/Windows/Scripts/Config.ps1 +++ b/scripts/Windows/Scripts/Config.ps1 @@ -13,6 +13,28 @@ $null = New-Module { [string] $finishedOption = "Finished"; [RegistryKey] $key = $null; + <# + .SYNOPSIS + Converts the specified path to linux and escapes it for the use in a script. + + .PARAMETER Path + The path to convert. + #> + function ConvertTo-LinuxPath { + param( + [string] $Path + ) + + $job = Start-Job { + $env:Value = Resolve-Path $Using:Path; + $env:WSLENV = "Value/p"; + $result = wsl -- bash -c 'echo "$Value"'; + wsl -e printf "%q" "$result"; + }; + + Receive-Job -Wait $job; + } + <# .SYNOPSIS Gets the registry key containing options related to the setup. @@ -38,6 +60,27 @@ $null = New-Module { return $key; } + <# + .SYNOPSIS + Gets a configuration option. + + .PARAMETER Name + The name of the option to get. + #> + function Get-Config { + param( + [string] $Name + ) + + $scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish"; + + function fish { + wsl -- nix --extra-experimental-features "nix-command flakes" nixpkgs`#fish $args + } + + fish -c ". $(ConvertTo-LinuxPath $scriptPath); getConfig $Name --json" | ConvertFrom-Json; + } + <# .SYNOPSIS Gets the value of an option related to the setup.