File tree 3 files changed +32
-40
lines changed
3 files changed +32
-40
lines changed Original file line number Diff line number Diff line change 10
10
args = {
11
11
inherit pkgs ;
12
12
piston = {
13
- mkRuntime = {
14
- language ,
15
- version ,
16
- runtime ? null ,
17
- run ,
18
- compile ? null ,
19
- packages ? null ,
20
- aliases ? [ ] ,
21
- limitOverrides ? { } ,
22
- tests
23
- } : let
24
- compileFile = if compile != null then
25
- pkgs . writeShellScript "compile" compile
13
+ mkRuntime = builderFn : let
14
+ languagePackagesFn = packages : with packages ; [ ] ;
15
+ buildRes = builderFn languagePackagesFn ;
16
+ compileFile = if builtins . hasAttr "compile" buildRes then
17
+ pkgs . writeShellScript "compile" buildRes . compile
26
18
else null ;
27
- runFile = pkgs . writeShellScript "run" run ;
19
+ runFile = pkgs . writeShellScript "run" buildRes . run ;
28
20
metadata = {
29
- inherit language version runtime aliases limitOverrides ;
21
+ language = buildRes . language ;
22
+ version = buildRes . version ;
23
+ runtime = buildRes . runtime or null ;
24
+ aliases = buildRes . aliases or [ ] ;
25
+ limitOverrides = buildRes . limitOverrides or { } ;
30
26
run = runFile ;
31
27
compile = compileFile ;
32
- packageSupport = packages != null ;
33
28
} ;
29
+ tests = if ( builtins . length buildRes . tests ) > 0 then
30
+ buildRes . tests
31
+ else abort "Language ${ buildRes . language } doesn't provide any tests" ;
34
32
in {
35
- inherit packages metadata ;
36
- tests = if ( builtins . length tests ) > 0 then
37
- tests
38
- else abort "Language ${ language } doesn't provide any tests" ;
33
+ inherit metadata tests ;
39
34
} ;
40
35
mkTest = {
41
36
files ,
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ case "$SUBCOMMAND" in
94
94
-e PISTON_RUNTIME_SET=$runtime_set \
95
95
-v " $SCRIPT_DIR " :/piston/src \
96
96
-v $DEV_VOLUME_NAME :/nix \
97
- -d " $IMAGE_NAME_DEV :$IMAGE_TAG " \
97
+ " $IMAGE_NAME_DEV :$IMAGE_TAG " \
98
98
bash -c " cd /piston/src/api && yarn run dev"
99
99
;;
100
100
Original file line number Diff line number Diff line change 1
- { pkgs , piston , ...} :
2
- let
3
- pkg = pkgs . python3 ;
4
- in piston . mkRuntime {
1
+ { pkgs , piston , ... } :
2
+ let basePkg = pkgs . python3 ;
3
+ in piston . mkRuntime ( libraries :
4
+ let pkg = basePkg . withPackages libraries ;
5
+ in {
5
6
language = "python3" ;
6
- version = pkg . version ;
7
+ version = basePkg . version ;
7
8
8
- aliases = [
9
- "py3"
10
- "py"
11
- "python"
12
- ] ;
9
+ aliases = [ "py3" "py" "python" ] ;
13
10
14
11
run = ''
15
- ${ pkg } /bin/python3 "$@"
12
+ ${ pkg } /bin/python3 "$@"
16
13
'' ;
17
14
18
15
tests = [
19
- ( piston . mkTest {
20
- files = {
21
- "test.py" = ''
22
- print("OK")
23
- '' ;
24
- } ;
25
- } )
16
+ ( piston . mkTest {
17
+ files = {
18
+ "test.py" = ''
19
+ print("OK")
20
+ '' ;
21
+ } ;
22
+ } )
26
23
] ;
27
- }
24
+ } )
You can’t perform that action at this time.
0 commit comments