mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-21 12:36:28 +02:00
migrate rscript to nix
This commit is contained in:
parent
2758f95228
commit
a8c23ecd99
7 changed files with 60 additions and 25 deletions
|
@ -20,4 +20,5 @@ args: {
|
|||
"swift" = import ./swift.nix args;
|
||||
"node-typescript" = import ./node-typescript.nix args;
|
||||
"sqlite3" = import ./sqlite3.nix args;
|
||||
"rscript" = import ./rscript.nix args;
|
||||
}
|
||||
|
|
59
runtimes/rscript.nix
Normal file
59
runtimes/rscript.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
{pkgs, piston, ...}:
|
||||
let
|
||||
pkg = pkgs.rWrapper;
|
||||
in piston.mkRuntime {
|
||||
language = "rscript";
|
||||
version = "4.1.2-wrapper";
|
||||
|
||||
aliases = [
|
||||
"r"
|
||||
];
|
||||
|
||||
run = ''
|
||||
${pkg}/bin/Rscript "$@"
|
||||
'';
|
||||
|
||||
tests = [
|
||||
# test different extension
|
||||
(piston.mkTest {
|
||||
files = {
|
||||
"file.code" = ''
|
||||
cat('OK')
|
||||
'';
|
||||
};
|
||||
args = [];
|
||||
stdin = "";
|
||||
packages = [];
|
||||
main = "file.code";
|
||||
})
|
||||
# test argv
|
||||
(piston.mkTest {
|
||||
files = {
|
||||
"test.r" = ''
|
||||
cat(commandArgs(trailingOnly=TRUE))
|
||||
'';
|
||||
};
|
||||
args = ["OK"];
|
||||
stdin = "";
|
||||
packages = [];
|
||||
main = "test.r";
|
||||
})
|
||||
# test stdin
|
||||
(piston.mkTest {
|
||||
files = {
|
||||
"test.r" = ''
|
||||
f <- file("stdin")
|
||||
open(f)
|
||||
while(length(line <- readLines(f,n=1)) > 0) {
|
||||
write(line, stderr())
|
||||
cat(line)
|
||||
}
|
||||
'';
|
||||
};
|
||||
args = [];
|
||||
stdin = "OK";
|
||||
packages = [];
|
||||
main = "test.r";
|
||||
})
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue