Initial nix ad-hoc package installation

This commit is contained in:
Omar Brikaa 2022-08-28 15:00:28 +02:00
parent 10183d0638
commit 8e230befce
3 changed files with 32 additions and 40 deletions

View File

@ -10,32 +10,27 @@
args = {
inherit pkgs;
piston = {
mkRuntime = {
language,
version,
runtime? null,
run,
compile? null,
packages? null,
aliases? [],
limitOverrides? {},
tests
}: let
compileFile = if compile != null then
pkgs.writeShellScript "compile" compile
mkRuntime = builderFn: let
languagePackagesFn = packages: with packages; [ ];
buildRes = builderFn languagePackagesFn;
compileFile = if builtins.hasAttr "compile" buildRes then
pkgs.writeShellScript "compile" buildRes.compile
else null;
runFile = pkgs.writeShellScript "run" run;
runFile = pkgs.writeShellScript "run" buildRes.run;
metadata = {
inherit language version runtime aliases limitOverrides;
language = buildRes.language;
version = buildRes.version;
runtime = buildRes.runtime or null;
aliases = buildRes.aliases or [];
limitOverrides = buildRes.limitOverrides or {};
run = runFile;
compile = compileFile;
packageSupport = packages != null;
};
tests = if (builtins.length buildRes.tests) > 0 then
buildRes.tests
else abort "Language ${buildRes.language} doesn't provide any tests";
in {
inherit packages metadata;
tests = if (builtins.length tests) > 0 then
tests
else abort "Language ${language} doesn't provide any tests";
inherit metadata tests;
};
mkTest = {
files,

2
piston
View File

@ -94,7 +94,7 @@ case "$SUBCOMMAND" in
-e PISTON_RUNTIME_SET=$runtime_set \
-v "$SCRIPT_DIR":/piston/src \
-v $DEV_VOLUME_NAME:/nix \
-d "$IMAGE_NAME_DEV:$IMAGE_TAG" \
"$IMAGE_NAME_DEV:$IMAGE_TAG" \
bash -c "cd /piston/src/api && yarn run dev"
;;

View File

@ -1,15 +1,12 @@
{ pkgs, piston, ... }:
let
pkg = pkgs.python3;
in piston.mkRuntime {
let basePkg = pkgs.python3;
in piston.mkRuntime (libraries:
let pkg = basePkg.withPackages libraries;
in {
language = "python3";
version = pkg.version;
version = basePkg.version;
aliases = [
"py3"
"py"
"python"
];
aliases = [ "py3" "py" "python" ];
run = ''
${pkg}/bin/python3 "$@"
@ -24,4 +21,4 @@ in piston.mkRuntime {
};
})
];
}
})