2022-01-30 06:41:24 +01:00
|
|
|
{
|
|
|
|
description = "Piston packages repo";
|
|
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
|
|
|
|
|
2022-02-08 16:22:02 +01:00
|
|
|
outputs = { self, nixpkgs }:
|
2022-01-30 06:41:24 +01:00
|
|
|
let
|
|
|
|
system = "x86_64-linux";
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2022-02-19 13:40:32 +01:00
|
|
|
nosocket = self.legacyPackages."${system}".nosocket;
|
2022-01-30 06:41:24 +01:00
|
|
|
args = {
|
|
|
|
inherit pkgs;
|
|
|
|
piston = {
|
2022-08-28 15:00:28 +02:00
|
|
|
mkRuntime = builderFn: let
|
|
|
|
languagePackagesFn = packages: with packages; [ ];
|
|
|
|
buildRes = builderFn languagePackagesFn;
|
|
|
|
compileFile = if builtins.hasAttr "compile" buildRes then
|
|
|
|
pkgs.writeShellScript "compile" buildRes.compile
|
2022-01-30 06:41:24 +01:00
|
|
|
else null;
|
2022-08-28 15:00:28 +02:00
|
|
|
runFile = pkgs.writeShellScript "run" buildRes.run;
|
2022-01-30 06:41:24 +01:00
|
|
|
metadata = {
|
2022-08-28 15:00:28 +02:00
|
|
|
language = buildRes.language;
|
|
|
|
version = buildRes.version;
|
|
|
|
runtime = buildRes.runtime or null;
|
|
|
|
aliases = buildRes.aliases or [];
|
|
|
|
limitOverrides = buildRes.limitOverrides or {};
|
2022-01-30 06:41:24 +01:00
|
|
|
run = runFile;
|
|
|
|
compile = compileFile;
|
|
|
|
};
|
2022-08-28 15:00:28 +02:00
|
|
|
tests = if (builtins.length buildRes.tests) > 0 then
|
|
|
|
buildRes.tests
|
|
|
|
else abort "Language ${buildRes.language} doesn't provide any tests";
|
2022-01-30 06:41:24 +01:00
|
|
|
in {
|
2022-08-28 15:00:28 +02:00
|
|
|
inherit metadata tests;
|
2022-01-30 06:41:24 +01:00
|
|
|
};
|
|
|
|
mkTest = {
|
|
|
|
files,
|
|
|
|
args? [],
|
|
|
|
stdin? "",
|
|
|
|
packages? [],
|
|
|
|
main? null
|
|
|
|
}: {
|
|
|
|
inherit files args stdin packages;
|
|
|
|
main = if main == null then
|
|
|
|
(
|
|
|
|
if (builtins.length (builtins.attrNames files)) == 1 then
|
|
|
|
(builtins.head (builtins.attrNames files))
|
|
|
|
else abort "Could not determine the main file for test - specify it using the 'main' parameter"
|
|
|
|
)
|
|
|
|
else main;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-01-30 10:29:21 +01:00
|
|
|
runtimes = import ./runtimes args;
|
|
|
|
runtimeList = names: pkgs.lib.filterAttrs (n: v: n == "bash") runtimes;
|
2022-01-30 06:41:24 +01:00
|
|
|
in {
|
|
|
|
piston = args.piston;
|
2022-01-30 10:29:21 +01:00
|
|
|
pistonRuntimes = runtimes;
|
|
|
|
pistonRuntimeSets = {
|
|
|
|
"all" = runtimes;
|
|
|
|
"bash-only" = runtimeList ["bash"];
|
2022-02-08 16:22:02 +01:00
|
|
|
"none" = { };
|
2022-01-30 06:41:24 +01:00
|
|
|
};
|
2022-06-05 12:24:56 +02:00
|
|
|
pistonMainstreamRuntimes = [
|
2022-06-05 11:31:49 +02:00
|
|
|
"mono-csharp"
|
|
|
|
"python3"
|
2022-06-05 11:50:29 +02:00
|
|
|
"node-javascript"
|
|
|
|
"node-typescript"
|
|
|
|
"mono-basic"
|
2022-06-05 11:31:49 +02:00
|
|
|
];
|
2022-01-30 06:41:24 +01:00
|
|
|
|
2022-01-30 10:29:21 +01:00
|
|
|
legacyPackages."${system}" = rec {
|
2022-01-30 06:41:24 +01:00
|
|
|
nosocket = (import ./nosocket { inherit pkgs; }).package;
|
2022-01-30 10:29:21 +01:00
|
|
|
piston = (import ./api { inherit pkgs nosocket; }).package;
|
2022-01-30 06:41:24 +01:00
|
|
|
};
|
|
|
|
|
2022-02-19 13:40:32 +01:00
|
|
|
containers = {
|
|
|
|
dev = (import ./api {
|
|
|
|
inherit pkgs nosocket;
|
2022-02-19 19:22:13 +01:00
|
|
|
isDev = true;
|
2022-02-19 13:40:32 +01:00
|
|
|
}).container;
|
|
|
|
|
|
|
|
prod = (import ./api {
|
|
|
|
inherit pkgs nosocket;
|
2022-02-19 19:22:13 +01:00
|
|
|
isDev = false;
|
2022-02-19 13:40:32 +01:00
|
|
|
}).container;
|
|
|
|
};
|
2022-01-30 06:41:24 +01:00
|
|
|
};
|
|
|
|
}
|