migrate powershell to nix

This commit is contained in:
Dan Vargas 2022-02-06 19:39:36 -07:00
parent f16eb5fa42
commit f35d3f910f
7 changed files with 59 additions and 21 deletions

View File

@ -1,6 +0,0 @@
#!/bin/bash
curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-linux-x64.tar.gz -o powershell.tar.gz
tar zxf powershell.tar.gz
rm powershell.tar.gz
chmod +x pwsh

View File

@ -1 +0,0 @@
export PATH=$PWD:$PATH

View File

@ -1,10 +0,0 @@
{
"language": "pwsh",
"version": "7.1.4",
"provides": [
{
"language": "powershell",
"aliases": ["ps", "pwsh", "ps1"]
}
]
}

View File

@ -1,3 +0,0 @@
#!/bin/bash
pwsh "$@"

View File

@ -1 +0,0 @@
echo "OK"

View File

@ -23,4 +23,5 @@ args: {
"rscript" = import ./rscript.nix args;
"raku" = import ./raku.nix args;
"racket" = import ./racket.nix args;
"powershell" = import ./powershell.nix args;
}

58
runtimes/powershell.nix Normal file
View File

@ -0,0 +1,58 @@
{pkgs, piston, ...}:
let
pkg = pkgs.powershell;
in piston.mkRuntime {
language = "powershell";
version = pkg.version;
aliases = [
"pwsh"
"ps"
"ps1"
];
run = ''
${pkg}/bin/pwsh "$@"
'';
tests = [
# test different file extension
(piston.mkTest {
files = {
"test.code" = ''
echo "OK"
'';
};
args = [];
stdin = "";
packages = [];
main = "test.code";
})
# test argv
(piston.mkTest {
files = {
"test.pwsh" = ''
foreach ($s in $args) {
Write-Host $s
}
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.pwsh";
})
# test stdin
(piston.mkTest {
files = {
"test.pwsh" = ''
$s = Read-Host
'';
};
args = [];
stdin = "OK";
packages = [];
main = "test.pwsh";
})
];
}