create packages flake
This commit is contained in:
parent
6a8dc48233
commit
064715d413
|
@ -13,6 +13,7 @@ services:
|
|||
- ./data/piston:/piston
|
||||
environment:
|
||||
- PISTON_REPO_URL=http://repo:8000/index
|
||||
- PISTON_LOG_LEVEL=DEBUG
|
||||
tmpfs:
|
||||
- /piston/jobs:exec
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1631561581,
|
||||
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1633356775,
|
||||
"narHash": "sha256-UBhRo1qy8xpOGTrjf7r2SFcULkFM+Wn4kchxN1ToDxs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "38501bec61c1e9447aa4ffc01ba07c40f4515327",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
description = "Piston packages repo";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
args = {
|
||||
inherit pkgs;
|
||||
piston = {
|
||||
mkRuntime = {
|
||||
language,
|
||||
version,
|
||||
runtime,
|
||||
run,
|
||||
compile? null,
|
||||
aliases? []
|
||||
}: let
|
||||
packageName = "${runtime}-${language}";
|
||||
compileFile = if compile != null then
|
||||
pkgs.writeShellScript "compile" compile
|
||||
else null;
|
||||
runFile = pkgs.writeShellScript "run" run;
|
||||
metadataFile = pkgs.writeText "metadata.json" (builtins.toJSON {
|
||||
inherit language version runtime aliases;
|
||||
});
|
||||
in pkgs.runCommandNoCC packageName {}
|
||||
(
|
||||
''
|
||||
mkdir -p $out/piston
|
||||
ln -s ${runFile} $out/piston/run
|
||||
ln -s ${metadataFile} $out/piston/metadata.json
|
||||
'' + (
|
||||
if compileFile != null then
|
||||
''
|
||||
ln -s ${compileFile} $out/piston/compile
|
||||
'' else "")
|
||||
);
|
||||
};
|
||||
};
|
||||
in {
|
||||
piston = {
|
||||
"node-javascript" = import ./node-javascript.nix args;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{pkgs, piston}:
|
||||
piston.mkRuntime {
|
||||
language = "javascript";
|
||||
version = pkgs.nodejs.version;
|
||||
runtime = "node";
|
||||
|
||||
aliases = [
|
||||
"node-js"
|
||||
"node-javascript"
|
||||
"js"
|
||||
];
|
||||
|
||||
run = ''
|
||||
${pkgs.nodejs}/bin/node "$@"
|
||||
'';
|
||||
|
||||
}
|
Loading…
Reference in New Issue