-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
. $PSScriptRoot/lib/lib.ps1 | ||
|
||
$id = WSL-Install | ||
|
||
try { | ||
WSL-Launch $id "nixos-version" | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to run nixos-version inside the container" | ||
} | ||
|
||
# TODO: WSL-Shutdown | ||
} | ||
finally { | ||
WSL-Uninstall($id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
if ($IsWindows) { | ||
. $PSScriptRoot/lib_windows.ps1 | ||
} else { | ||
. $PSScriptRoot/lib_linux.ps1 | ||
. $PSScriptRoot/lib_windows.ps1 | ||
} | ||
else { | ||
. $PSScriptRoot/lib_linux.ps1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
function WSL-Install() { | ||
$id = [guid]::NewGuid().ToString() | ||
$id = [guid]::NewGuid().ToString() | ||
|
||
# Build docker image from the provided tarball | ||
$tmpdir = $(mktemp -d) | ||
Copy-Item $PSScriptRoot/Dockerfile $tmpdir | ||
Copy-Item nixos-wsl-installer.tar.gz $tmpdir | ||
docker build -t nixos-wsl:$id $tmpdir | Write-Host | ||
Remove-Item $tmpdir -Recurse -Force | ||
# Build docker image from the provided tarball | ||
$tmpdir = $(mktemp -d) | ||
Copy-Item $PSScriptRoot/Dockerfile $tmpdir | ||
Copy-Item nixos-wsl-installer.tar.gz $tmpdir | ||
docker build -t nixos-wsl:$id $tmpdir | Write-Host | ||
Remove-Item $tmpdir -Recurse -Force | ||
|
||
# Spawn a new docker container | ||
docker run -di --privileged --init --name $id nixos-wsl:$id /bin/sh | Out-Null | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to launch container" | ||
} | ||
# Spawn a new docker container | ||
docker run -di --privileged --init --name $id nixos-wsl:$id /bin/sh | Out-Null | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to launch container" | ||
} | ||
|
||
return $id | ||
return $id | ||
} | ||
|
||
function WSL-Launch([string]$id, [string]$command) { | ||
docker exec -t $id /nix/nixos-wsl/entrypoint -c "$command" | ||
docker exec -t $id /nix/nixos-wsl/entrypoint -c "$command" | ||
} | ||
|
||
# TODO: WSL-CopyFile | ||
|
||
function WSL-Shutdown([string]$id) { | ||
docker stop $id | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to stop container" | ||
} | ||
docker stop $id | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to stop container" | ||
} | ||
} | ||
|
||
function WSL-Uninstall([string]$id) { | ||
docker rm -f $id | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to remove container" | ||
} | ||
docker rmi nixos-wsl:$id | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to remove image" | ||
} | ||
docker rm -f $id | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to remove container" | ||
} | ||
docker rmi nixos-wsl:$id | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to remove image" | ||
} | ||
} |