Skip to content

Commit 8e230be

Browse files
committed
Initial nix ad-hoc package installation
1 parent 10183d0 commit 8e230be

File tree

3 files changed

+32
-40
lines changed

3 files changed

+32
-40
lines changed

Diff for: flake.nix

+15-20
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,27 @@
1010
args = {
1111
inherit pkgs;
1212
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
2618
else null;
27-
runFile = pkgs.writeShellScript "run" run;
19+
runFile = pkgs.writeShellScript "run" buildRes.run;
2820
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 {};
3026
run = runFile;
3127
compile = compileFile;
32-
packageSupport = packages != null;
3328
};
29+
tests = if (builtins.length buildRes.tests) > 0 then
30+
buildRes.tests
31+
else abort "Language ${buildRes.language} doesn't provide any tests";
3432
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;
3934
};
4035
mkTest = {
4136
files,

Diff for: piston

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ case "$SUBCOMMAND" in
9494
-e PISTON_RUNTIME_SET=$runtime_set \
9595
-v "$SCRIPT_DIR":/piston/src \
9696
-v $DEV_VOLUME_NAME:/nix \
97-
-d "$IMAGE_NAME_DEV:$IMAGE_TAG" \
97+
"$IMAGE_NAME_DEV:$IMAGE_TAG" \
9898
bash -c "cd /piston/src/api && yarn run dev"
9999
;;
100100

Diff for: runtimes/python3.nix

+16-19
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
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 {
56
language = "python3";
6-
version = pkg.version;
7+
version = basePkg.version;
78

8-
aliases = [
9-
"py3"
10-
"py"
11-
"python"
12-
];
9+
aliases = [ "py3" "py" "python" ];
1310

1411
run = ''
15-
${pkg}/bin/python3 "$@"
12+
${pkg}/bin/python3 "$@"
1613
'';
1714

1815
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+
})
2623
];
27-
}
24+
})

0 commit comments

Comments
 (0)