Initial nix ad-hoc package installation
This commit is contained in:
parent
10183d0638
commit
8e230befce
35
flake.nix
35
flake.nix
|
@ -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
2
piston
|
@ -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"
|
||||
;;
|
||||
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
{pkgs, piston, ...}:
|
||||
let
|
||||
pkg = pkgs.python3;
|
||||
in piston.mkRuntime {
|
||||
{ pkgs, piston, ... }:
|
||||
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 "$@"
|
||||
${pkg}/bin/python3 "$@"
|
||||
'';
|
||||
|
||||
tests = [
|
||||
(piston.mkTest {
|
||||
files = {
|
||||
"test.py" = ''
|
||||
print("OK")
|
||||
'';
|
||||
};
|
||||
})
|
||||
(piston.mkTest {
|
||||
files = {
|
||||
"test.py" = ''
|
||||
print("OK")
|
||||
'';
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue