Compare commits

...

7 commits

5 changed files with 60 additions and 6 deletions

View file

@ -1,9 +1,9 @@
#!/bin/pwsh
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Prerequisites.ps1";
. "$PSScriptRoot/../Scripts/Choco.ps1";
. "$PSScriptRoot/../Scripts/Config.ps1";
. "$PSScriptRoot/../Scripts/Hooks.ps1";
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
. "$PSScriptRoot/../Scripts/SetupConfig.ps1";
. "$PSScriptRoot/../Scripts/Update.ps1";
. "$PSScriptRoot/../Scripts/Context.ps1";
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
@ -35,6 +35,8 @@ function Start-InstallationLoop {
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
refreshenv;
};
continue;
}
if (-not (Test-ChocoSoftware "powershell-core")) {
@ -53,8 +55,16 @@ function Start-InstallationLoop {
if (Test-Path $env:PWSH_PATH) {
attrib "-R" "$env:PWSH_PATH\*" /S /D;
Remove-Item -Recurse -Force $env:PWSH_PATH;
continue;
}
if (-not (& { wsl --status; $?; })) {
wsl --install --no-launch;
Restart-Intermediate;
return;
} else {
Set-Stage ([SetupStage]::Install);
ubuntu install --root;
wsl -- sh `<`(curl -L https://nixos.org/nix/install`) --daemon --yes;
}
} else {
$null = Import-Module PSWindowsUpdate;

View file

@ -8,6 +8,7 @@ function Start-Setup {
$null = $env:WIN_COMPUTER_NAME;
$null = $env:SETUP_SCRIPT_NAME;
$null = $env:CONFIG_MODULE;
$env:WSLENV = "CONFIG_MODULE/p";
$valhallaConfig = ConvertFrom-Json (Get-Content "$env:CONFIG_MODULE.json");

View file

@ -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.

View file

@ -1,7 +1,7 @@
using namespace Microsoft.Win32;
. "$PSScriptRoot/Scripting.ps1";
$null = New-Module {
. "$PSScriptRoot/Scripting.ps1";
[RegistryKey] $key = $null;
$runOncePath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce";
$runOnceName = "PortValhalla";

View file

@ -23,12 +23,12 @@ function Update-WindowsInstallation {
Write-Information "A Reboot is Required!";
Write-Information "Windows will reboot now and the installation will be continued automatically.";
return;
}
} else {
Write-Information "Upgrading Windows finished successfully!";
Write-Information "Updating Windows finished successfully!";
return;
}
}
}
Start-UpdateLoop;
}