Add a function for retrieving nix
options
This commit is contained in:
parent
50951b31ff
commit
c7d19102cf
1 changed files with 43 additions and 0 deletions
|
@ -13,6 +13,28 @@ $null = New-Module {
|
||||||
[string] $finishedOption = "Finished";
|
[string] $finishedOption = "Finished";
|
||||||
[RegistryKey] $key = $null;
|
[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
|
.SYNOPSIS
|
||||||
Gets the registry key containing options related to the setup.
|
Gets the registry key containing options related to the setup.
|
||||||
|
@ -38,6 +60,27 @@ $null = New-Module {
|
||||||
return $key;
|
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
|
.SYNOPSIS
|
||||||
Gets the value of an option related to the setup.
|
Gets the value of an option related to the setup.
|
||||||
|
|
Loading…
Reference in a new issue