forked from lix-project/lix-installer
d69f335703
* wip * Add dockerfile * Add readme bits * Fix logic inversion * Relax init detection error * Tidying heuristics * Fix doc tests * Mac supports start-daemon false * Get VM tests working * Add instructions * Some target_os flagging * More target flagging * Fix lints * Fixup more mac-only stuff * cfg flag examples too * Fix planner wording * More os specific lint fixing * More refinement on mac and the README * Add new CI jobs to test no-daemon * Use nix-installer-pr to point at branch * Tests with no-init * init/no-daemon are linux only * nix tests support a per-distro all attribute * Add working podman test * Expand docker tests * Add contributing notes * format * Support both podman and docker * Update contributing * Add Windows WSL test script for Ubuntu * format nix tests * More ignores to check-spelling * Add systemd based wsl test * We don't have root-only darwin * Reflect review nits * Reenable tests * Restore mac plan * Flag off os specific tests * Better cfg flagging * Remove dead comments * Rework readme to look better with new sections * Correct codeblock language * Remove some warnings
75 lines
2.5 KiB
PowerShell
75 lines
2.5 KiB
PowerShell
param([switch]$Systemd = $false)
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
# 22.04 https://cloud-images.ubuntu.com/wsl/jammy/current/
|
|
$url = "https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz"
|
|
$File = "ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz"
|
|
$Name = "ubuntu-jammy"
|
|
|
|
|
|
$TemporaryDirectory = "$HOME/nix-installer-wsl-tests-temp"
|
|
$Image = "$TemporaryDirectory\$File"
|
|
if (!(Test-Path -Path $Image)) {
|
|
Write-Output "Fetching $File to $Image..."
|
|
New-Item $TemporaryDirectory -ItemType Directory | Out-Null
|
|
Invoke-WebRequest -Uri "https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz" -OutFile $Image
|
|
} else {
|
|
Write-Output "Found existing $Image..."
|
|
}
|
|
|
|
$DistroName = "nix-installer-test-$Name"
|
|
$InstallRoot = "$TemporaryDirectory\wsl-$Name"
|
|
Write-Output "Creating WSL distribution $DistroName from $Image at $InstallRoot..."
|
|
wsl --import $DistroName $InstallRoot $Image
|
|
if ($LastExitCode -ne 0) {
|
|
exit $LastExitCode
|
|
}
|
|
|
|
Write-Output "Preparing $DistroName for nix-installer..."
|
|
wsl --distribution $DistroName bash --login -c "apt update --quiet"
|
|
if ($LastExitCode -ne 0) {
|
|
exit $LastExitCode
|
|
}
|
|
wsl --distribution $DistroName bash --login -c "apt install --quiet --yes curl build-essential"
|
|
if ($LastExitCode -ne 0) {
|
|
exit $LastExitCode
|
|
}
|
|
wsl --distribution $DistroName bash --login -c "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --quiet"
|
|
if ($LastExitCode -ne 0) {
|
|
exit $LastExitCode
|
|
}
|
|
|
|
if ($Systemd) {
|
|
$wslConf = "[boot]`nsystemd=true"
|
|
New-Item -Path "\\wsl$\$DistroName\etc\wsl.conf" -ItemType "file" -Value $wslConf
|
|
wsl --shutdown
|
|
if ($LastExitCode -ne 0) {
|
|
exit $LastExitCode
|
|
}
|
|
}
|
|
|
|
Write-Output "Building and runnings nix-installer in $DistroName..."
|
|
Copy-Item -Recurse "$PSScriptRoot\..\.." -Destination "\\wsl$\$DistroName\nix-installer"
|
|
$MaybeInitChoice = switch ($Systemd) {
|
|
$true { "" }
|
|
$false { "--init none" }
|
|
}
|
|
wsl --distribution $DistroName bash --login -c "/root/.cargo/bin/cargo run --quiet --manifest-path /nix-installer/Cargo.toml -- install linux-multi --no-confirm $MaybeInitChoice"
|
|
if ($LastExitCode -ne 0) {
|
|
exit $LastExitCode
|
|
}
|
|
|
|
Write-Output "Testing installed Nix on $DistroName..."
|
|
wsl --distribution $DistroName bash --login -c "nix run nixpkgs#hello"
|
|
if ($LastExitCode -ne 0) {
|
|
exit $LastExitCode
|
|
}
|
|
|
|
Write-Output "Unregistering $DistroName and removing $InstallRoot..."
|
|
wsl --unregister $DistroName
|
|
if ($LastExitCode -ne 0) {
|
|
exit $LastExitCode
|
|
}
|
|
Remove-Item $InstallRoot |