Move unix related functions to the WSL
script
This commit is contained in:
parent
df86ea2980
commit
3022ee9f41
|
@ -4,6 +4,7 @@ using namespace System.Management.Automation.Host;
|
|||
$null = New-Module {
|
||||
. "$PSScriptRoot/SoftwareManagement.ps1";
|
||||
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
|
||||
. "$PSScriptRoot/../../Windows/Scripts/WSL.ps1";
|
||||
. "$PSScriptRoot/../../Windows/Types/WindowsInstallerAction.ps1";
|
||||
|
||||
<#
|
||||
|
@ -67,7 +68,6 @@ $null = New-Module {
|
|||
[string] $Script
|
||||
)
|
||||
|
||||
. "$PSScriptRoot/../../Windows/Scripts/WSL.ps1";
|
||||
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
|
||||
|
||||
if ($env:CONFIG_NAME -or ($Script -eq "getProfiles")) {
|
||||
|
@ -80,10 +80,6 @@ $null = New-Module {
|
|||
$projectRoot = "$PSScriptRoot/../../..";
|
||||
$archisoDir = "$projectRoot/archiso";
|
||||
|
||||
function fish {
|
||||
wsl --shell-type login -- nix --extra-experimental-features "nix-command flakes" run nixpkgs`#fish -- $args
|
||||
}
|
||||
|
||||
if (Test-Path -PathType Container "$archisoDir") {
|
||||
$git = {
|
||||
git -C "$projectRoot" -c safe.directory="$("$(Resolve-Path $projectRoot)".Replace("\", "/"))" @args;
|
||||
|
@ -93,7 +89,7 @@ $null = New-Module {
|
|||
$cleanup = { & $git restore --staged "$archisoDir" };
|
||||
}
|
||||
|
||||
$output = fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script";
|
||||
$output = Invoke-Fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script";
|
||||
|
||||
if (-not $?) {
|
||||
Write-Error "The configuration could not be retrieved!";
|
||||
|
|
|
@ -243,9 +243,8 @@ $null = New-Module {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (-not (wsl --shell-type login type -t nix)) {
|
||||
wsl -- sh `<`(curl -L https://nixos.org/nix/install`) --daemon --yes;
|
||||
wsl --shutdown;
|
||||
if (-not (Test-Nix)) {
|
||||
Install-Nix;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,6 +126,39 @@ function Unregister-WslDistribution {
|
|||
Move-Item $tempDisk $wslDisk;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks whether `nix` is installed in WSL.
|
||||
#>
|
||||
function Test-Nix {
|
||||
wsl --shell-type login type -t nix;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Installs `nix` in WSL.
|
||||
#>
|
||||
function Install-Nix {
|
||||
wsl -- sh `<`(curl -L https://nixos.org/nix/install`) --daemon --yes;
|
||||
wsl --shutdown;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Execute a `nix` command in WSL.
|
||||
#>
|
||||
function Invoke-Nix {
|
||||
wsl --shell-type login nix --extra-experimental-features "nix-command flakes" @args;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Execute a `fish` command in WSL.
|
||||
#>
|
||||
function Invoke-Fish {
|
||||
Invoke-Nix run nixpkgs`#fish `-- @args;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Converts the specified path to linux and escapes it for the use in a script.
|
||||
|
|
Loading…
Reference in a new issue