Compare commits

..

No commits in common. "16e4f08dfaf93e1dbca7154dccd8c5e633d17a84" and "d244f0138cd92e330481ebd4444271d0f578a309" have entirely different histories.

44 changed files with 387 additions and 1241 deletions

View File

@ -1,9 +1,9 @@
# This "FROM" image is previously emitted by nix
FROM ghcr.io/engineer-man/piston:base-latest
ENV PISTON_FLAKE_PATH=/piston/src
COPY runtimes/ /piston/src/runtimes
COPY flake.nix flake.lock /piston/src/
ENV PISTON_FLAKE_PATH=/piston/packages
COPY runtimes/ /piston/packages/runtimes
COPY flake.nix flake.lock /piston/packages/
ARG RUNTIMESET=all

View File

@ -1,4 +1,4 @@
{pkgs, nosocket, isDev, ...}:
{pkgs, nosocket, ...}:
with pkgs; rec {
package = mkYarnPackage {
name = "piston";
@ -25,54 +25,36 @@ with pkgs; rec {
};
};
};
basePackages = with pkgs; [
package
nosocket
bash
nixFlakes
coreutils-full
cacert.out
git
gnutar
gzip
gnugrep
rename
util-linux
];
devPackages = with pkgs; [
nodejs-16_x
yarn
python3
gcc
gnumake
gnused
];
baseCommands = ''
mkdir -p piston/{jobs,runtimes} etc/nix {,var/}tmp run/lock
echo -e "experimental-features = nix-command flakes" >> etc/nix/nix.conf
echo "nixbld:x:30000:nixbld1,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld2,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld3,nixbld30,nixbld31,nixbld32,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9" >> etc/group
for i in $(seq 1 32)
do
echo "nixbld$i:x:$(( $i + 30000 )):30000:Nix build user $i:/var/empty:/run/current-system/sw/bin/nologin" >> etc/passwd
done
chmod 1777 {,var/}tmp/
'';
devCommands = ''
mkdir -p usr/bin
ln -s /bin/env usr/bin/env
chmod -R 1777 usr
'';
container = pkgs.dockerTools.buildLayeredImageWithNixDb {
name = if isDev then "piston" else "ghcr.io/engineer-man/piston";
name = "piston";
tag = "base-latest";
contents = if isDev then basePackages ++ devPackages else basePackages;
contents = with pkgs; [
package
nosocket
bash
nixFlakes
coreutils-full
cacert.out
git
gnutar
gzip
gnugrep
rename
util-linux
];
extraCommands = if isDev then baseCommands + devCommands else baseCommands;
extraCommands = ''
mkdir -p piston/{jobs,runtimes} etc/nix {,var/}tmp run/lock
echo -e "experimental-features = nix-command flakes" >> etc/nix/nix.conf
echo "nixbld:x:30000:nixbld1,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld2,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld3,nixbld30,nixbld31,nixbld32,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9" >> etc/group
for i in $(seq 1 32)
do
echo "nixbld$i:x:$(( $i + 30000 )):30000:Nix build user $i:/var/empty:/run/current-system/sw/bin/nologin" >> etc/passwd
done
chmod 1777 {,var/}tmp/
'';
config = {
Cmd = ["${package}/bin/pistond"];
@ -104,4 +86,4 @@ with pkgs; rec {
};
};
};
}
}

View File

@ -8,20 +8,18 @@
"express": "^4.17.1",
"express-ws": "^5.0.2",
"logplease": "^1.2.15",
"nocamel": "git://github.com/HexF/nocamel.git#patch-1",
"node-fetch": "^2.6.1",
"uuid": "^8.3.2",
"nocamel": "git://github.com/HexF/nocamel.git#patch-1",
"waitpid": "git://github.com/HexF/node-waitpid.git"
},
"license": "MIT",
"scripts": {
"dev": "nodemon .",
"lint": "prettier . --write",
"prepack": "yarn2nix > yarn.nix"
},
"devDependencies": {
"node2nix": "^1.6.0",
"nodemon": "^2.0.15",
"prettier": "2.2.1"
},
"bin": {

View File

@ -3,6 +3,7 @@ const router = express.Router();
const events = require('events');
const runtime = require('../runtime');
const { Job } = require('../job');
const SIGNALS = [
@ -89,7 +90,10 @@ function get_job(job_info, available_runtimes) {
});
}
if (!files.some(file => !file.encoding || file.encoding === 'utf8')) {
if (
rt.language !== 'file' &&
!files.some(file => !file.encoding || file.encoding === 'utf8')
) {
return reject({
message: 'files must include at least one utf8 encoded file',
});

View File

@ -80,7 +80,10 @@ function get_job(job_info, available_runtimes) {
});
}
if (!files.some(file => !file.encoding || file.encoding === 'utf8')) {
if (
rt.language !== 'file' &&
!files.some(file => !file.encoding || file.encoding === 'utf8')
) {
return reject({
message: 'files must include at least one utf8 encoded file',
});

View File

@ -1,4 +1,5 @@
const logplease = require('logplease');
const logger = logplease.create('job');
const { v4: uuidv4 } = require('uuid');
const cp = require('child_process');
const path = require('path');
@ -225,7 +226,9 @@ class Job {
this.logger.info(`Executing job runtime=${this.runtime.toString()}`);
const code_files = this.files.filter(file => file.encoding == 'utf8');
const code_files =
(this.runtime.language === 'file' && this.files) ||
this.files.filter(file => file.encoding == 'utf8');
this.logger.debug('Compiling');
@ -271,7 +274,9 @@ class Job {
`Interactively executing job runtime=${this.runtime.toString()}`
);
const code_files = this.files.filter(file => file.encoding == 'utf8');
const code_files =
(this.runtime.language === 'file' && this.files) ||
this.files.filter(file => file.encoding == 'utf8');
if (this.runtime.compiled) {
eventBus.emit('stage', 'compile');

File diff suppressed because it is too large Load Diff

View File

@ -2,11 +2,14 @@
description = "Piston packages repo";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = { self, nixpkgs }:
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
nosocket = self.legacyPackages."${system}".nosocket;
baseContainer = (import ./api {
inherit pkgs;
nosocket = self.legacyPackages."${system}".nosocket;
}).container;
args = {
inherit pkgs;
piston = {
@ -63,7 +66,6 @@
pistonRuntimeSets = {
"all" = runtimes;
"bash-only" = runtimeList ["bash"];
"none" = { };
};
legacyPackages."${system}" = rec {
@ -71,16 +73,6 @@
piston = (import ./api { inherit pkgs nosocket; }).package;
};
containers = {
dev = (import ./api {
inherit pkgs nosocket;
isDev = true;
}).container;
prod = (import ./api {
inherit pkgs nosocket;
isDev = false;
}).container;
};
container = baseContainer;
};
}

16
packages/dotnet/5.0.201/build.sh vendored Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
curl "https://download.visualstudio.microsoft.com/download/pr/73a9cb2a-1acd-4d20-b864-d12797ca3d40/075dbe1dc3bba4aa85ca420167b861b6/dotnet-sdk-5.0.201-linux-x64.tar.gz" -Lo dotnet.tar.gz
tar xzf dotnet.tar.gz --strip-components=1
rm dotnet.tar.gz
# Cache nuget packages
export DOTNET_CLI_HOME=$PWD
./dotnet new console -o cache_application
./dotnet new console -lang F# -o fs_cache_application
./dotnet new console -lang VB -o vb_cache_application
# This calls a restore on the global-packages index ($DOTNET_CLI_HOME/.nuget/packages)
# If we want to allow more packages, we could add them to this cache_application
rm -rf cache_application fs_cache_application vb_cache_application
# Get rid of it, we don't actually need the application - just the restore

36
packages/dotnet/5.0.201/compile vendored Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
[ "${PISTON_LANGUAGE}" == "fsi" ] && exit 0
export DOTNET_CLI_HOME=$PWD
export HOME=$PWD
dotnet build --help > /dev/null # Shut the thing up
case "${PISTON_LANGUAGE}" in
basic.net)
rename 's/$/\.vb/' "$@" # Add .vb extension
dotnet new console -lang VB -o . --no-restore
rm Program.vb
;;
fsharp.net)
first_file=$1
shift
rename 's/$/\.fs/' "$@" # Add .fs extension
dotnet new console -lang F# -o . --no-restore
mv $first_file Program.fs # For some reason F#.net doesn't work unless the file name is Program.fs
;;
csharp.net)
rename 's/$/\.cs/' "$@" # Add .cs extension
dotnet new console -o . --no-restore
rm Program.cs
;;
*)
echo "How did you get here? (${PISTON_LANGUAGE})"
exit 1
;;
esac
dotnet restore --source $DOTNET_ROOT/.nuget/packages
dotnet build --no-restore

6
packages/dotnet/5.0.201/environment vendored Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Put 'export' statements here for environment variables
export DOTNET_ROOT=$PWD
export PATH=$DOTNET_ROOT:$PATH
export FSI_PATH=$(find $(pwd) -name fsi.dll)

66
packages/dotnet/5.0.201/metadata.json vendored Normal file
View File

@ -0,0 +1,66 @@
{
"language": "dotnet",
"version": "5.0.201",
"provides": [
{
"language": "basic.net",
"aliases": [
"basic",
"visual-basic",
"visual-basic.net",
"vb",
"vb.net",
"vb-dotnet",
"dotnet-vb",
"basic-dotnet",
"dotnet-basic"
],
"limit_overrides": { "max_process_count": 128 }
},
{
"language": "fsharp.net",
"aliases": [
"fsharp",
"fs",
"f#",
"fs.net",
"f#.net",
"fsharp-dotnet",
"fs-dotnet",
"f#-dotnet",
"dotnet-fsharp",
"dotnet-fs",
"dotnet-fs"
],
"limit_overrides": { "max_process_count": 128 }
},
{
"language": "csharp.net",
"aliases": [
"csharp",
"c#",
"cs",
"c#.net",
"cs.net",
"c#-dotnet",
"cs-dotnet",
"csharp-dotnet",
"dotnet-c#",
"dotnet-cs",
"dotnet-csharp"
],
"limit_overrides": { "max_process_count": 128 }
},
{
"language": "fsi",
"aliases": [
"fsx",
"fsharp-interactive",
"f#-interactive",
"dotnet-fsi",
"fsi-dotnet",
"fsi.net"
]
}
]
}

25
packages/dotnet/5.0.201/run vendored Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Put instructions to run the runtime
export DOTNET_CLI_HOME=$PWD
case "${PISTON_LANGUAGE}" in
basic.net)
;&
fsharp.net)
;&
csharp.net)
shift
dotnet bin/Debug/net5.0/$(basename $(realpath .)).dll "$@"
;;
fsi)
FILENAME=$1
rename 's/$/\.fsx/' $FILENAME # Add .fsx extension
shift
dotnet $FSI_PATH $FILENAME.fsx "$@"
;;
*)
echo "How did you get here? (${PISTON_LANGUAGE})"
exit 1
;;
esac

9
packages/dotnet/5.0.201/test.cs vendored Normal file
View File

@ -0,0 +1,9 @@
using System;
public class Test
{
public static void Main(string[] args)
{
Console.WriteLine("OK");
}
}

6
packages/dotnet/5.0.201/test.fs vendored Normal file
View File

@ -0,0 +1,6 @@
open System
[<EntryPoint>]
let main argv =
printfn "OK"
0

1
packages/dotnet/5.0.201/test.fsx vendored Normal file
View File

@ -0,0 +1 @@
printfn "OK"

9
packages/dotnet/5.0.201/test.vb vendored Normal file
View File

@ -0,0 +1,9 @@
Imports System
Module Module1
Sub Main()
Console.WriteLine("OK")
End Sub
End Module

25
packages/pascal/3.2.0/build.sh vendored Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
PREFIX=$(realpath $(dirname $0))
mkdir -p build
cd build
curl -L "https://sourceforge.net/projects/freepascal/files/Linux/3.2.0/fpc-3.2.0-x86_64-linux.tar/download" -o pascal.tar
tar xf pascal.tar --strip-components=1
# FreePascal uses an interactive installer
./install.sh << ANSWERS
$PREFIX
n
n
n
ANSWERS
cd ..
rm -rf build
# A sample config (needed for each "project") is written to /etc
# We'll copy that into the local lib dir (fpc searches there too on compile)
mkdir lib/fpc/etc
cp -r /etc/fp* lib/fpc/etc/

5
packages/pascal/3.2.0/compile vendored Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Compile pascal files
fpc -oout -v0 "$@"
chmod +x out

1
packages/pascal/3.2.0/environment vendored Normal file
View File

@ -0,0 +1 @@
export PATH=$PWD/bin:$PATH

5
packages/pascal/3.2.0/metadata.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"language": "pascal",
"version": "3.2.0",
"aliases": ["pascal", "freepascal", "pp", "pas"]
}

4
packages/pascal/3.2.0/run vendored Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
shift # Filename is only used to compile
./out "$@"

5
packages/pascal/3.2.0/test.pp vendored Normal file
View File

@ -0,0 +1,5 @@
program test;
begin
writeln('OK');
end.

5
packages/rust/1.50.0/build.sh vendored Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
curl -OL "https://static.rust-lang.org/dist/rust-1.50.0-x86_64-unknown-linux-gnu.tar.gz"
tar xzvf rust-1.50.0-x86_64-unknown-linux-gnu.tar.gz
rm rust-1.50.0-x86_64-unknown-linux-gnu.tar.gz

6
packages/rust/1.50.0/compile vendored Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# https://stackoverflow.com/questions/38041331/rust-compiler-cant-find-crate-for-std
# Rust compiler needs to find the stdlib to link against
rustc -o binary -L ${RUST_INSTALL_LOC}/rustc/lib -L ${RUST_INSTALL_LOC}/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$@"
chmod +x binary

5
packages/rust/1.50.0/environment vendored Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Put 'export' statements here for environment variables
export PATH=$PWD/rust-1.50.0-x86_64-unknown-linux-gnu/rustc/bin/:$PATH
export RUST_INSTALL_LOC=$PWD/rust-1.50.0-x86_64-unknown-linux-gnu

5
packages/rust/1.50.0/metadata.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"language": "rust",
"version": "1.50.0",
"aliases": ["rs"]
}

4
packages/rust/1.50.0/run vendored Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
shift
./binary "$@"

3
packages/rust/1.50.0/test.rs vendored Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println!("OK");
}

5
packages/rust/1.56.1/build.sh vendored Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
curl -OL "https://static.rust-lang.org/dist/rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz"
tar xzvf rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz
rm rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz

6
packages/rust/1.56.1/compile vendored Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# https://stackoverflow.com/questions/38041331/rust-compiler-cant-find-crate-for-std
# Rust compiler needs to find the stdlib to link against
rustc -o binary -L ${RUST_INSTALL_LOC}/rustc/lib -L ${RUST_INSTALL_LOC}/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$@"
chmod +x binary

5
packages/rust/1.56.1/environment vendored Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Put 'export' statements here for environment variables
export PATH=$PWD/rust-1.56.1-x86_64-unknown-linux-gnu/rustc/bin/:$PATH
export RUST_INSTALL_LOC=$PWD/rust-1.56.1-x86_64-unknown-linux-gnu

7
packages/rust/1.56.1/metadata.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"language": "rust",
"version": "1.56.1",
"aliases": [
"rs"
]
}

4
packages/rust/1.56.1/run vendored Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
shift
./binary "$@"

3
packages/rust/1.56.1/test.rs vendored Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println!("OK");
}

128
piston
View File

@ -3,7 +3,6 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CONTAINER_NAME="piston_api"
DEV_VOLUME_NAME="piston_nix"
IMAGE_TAG="base-latest"
IMAGE_NAME="ghcr.io/engineer-man/piston"
@ -12,11 +11,10 @@ IMAGE_NAME_DEV="piston"
SUBCOMMAND="$1"
shift
build_base() {
container_flake_key=$([[ $1 == "dev" ]] && echo "containers.dev" || echo "containers.prod")
CONTAINER_PATH="$(nix build ".#$container_flake_key" --no-link --json | jq '.[0].outputs.out' -r)"
echo "The image archive was created at: $CONTAINER_PATH"
build_base(){
CONTAINER_PATH="$(nix build ".#container" --no-link --json | jq '.[0].outputs.out' -r)" || exit 1
docker load -i $CONTAINER_PATH || exit 1
docker tag "$IMAGE_NAME_DEV:$IMAGE_TAG" "$IMAGE_NAME:$IMAGE_TAG" || exit 1
}
case "$SUBCOMMAND" in
@ -38,48 +36,28 @@ case "$SUBCOMMAND" in
docker pull "$IMAGE_NAME:$IMAGE_TAG"
;;
build)
build_base
if [[ ! -z "$1" ]]; then
# $1 contains a variant to build
runtime_set=$1
docker build \
--build-arg RUNTIMESET=$runtime_set \
-f "$SCRIPT_DIR"/Dockerfile.withset \
-t "$IMAGE_NAME_DEV:$runtime_set-latest" \
.
fi
;;
# dev commands
scaffold)
pushd "$SCRIPT_DIR/runtimes" > /dev/null
pushd $SCRIPT_DIR/runtimes > /dev/null
./scaffold.sh $1 $2
popd > /dev/null
;;
build-dev)
echo "Removing the Nix volume if it exists"
docker volume rm -f $DEV_VOLUME_NAME || exit 1
echo "Building the base docker image"
build_base dev
echo "Installing the required node modules"
docker run \
--rm \
-p 2000:2000 \
-it \
--name $CONTAINER_NAME \
-e PISTON_LOG_LEVEL=DEBUG \
-e PISTON_FLAKE_PATH=/piston/src \
-e PISTON_RUNTIME_SET=none \
-v "$SCRIPT_DIR":/piston/src \
"$IMAGE_NAME_DEV:$IMAGE_TAG" \
bash -c "cd /piston/src/api && yarn install"
echo "Done building"
build)
build_base
if [[ ! -z "$1" ]]; then
# $1 contains a variant to build
docker build \
--build-arg RUNTIMESET=$1 \
-f $SCRIPT_DIR/Dockerfile.withset \
-t "$IMAGE_NAME_DEV:$1-latest" \
.
fi
;;
start-dev)
build_base
runtime_set=all
if [[ ! -z "$1" ]]; then
runtime_set=$1
@ -90,66 +68,52 @@ case "$SUBCOMMAND" in
-it \
--name $CONTAINER_NAME \
-e PISTON_LOG_LEVEL=DEBUG \
-e PISTON_FLAKE_PATH=/piston/src \
-e PISTON_FLAKE_PATH=/piston/packages \
-e PISTON_RUNTIME_SET=$runtime_set \
-v "$SCRIPT_DIR":/piston/src \
-v $DEV_VOLUME_NAME:/nix \
-d "$IMAGE_NAME_DEV:$IMAGE_TAG" \
bash -c "cd /piston/src/api && yarn run dev"
;;
test)
docker run \
--rm \
-it \
-e PISTON_FLAKE_PATH=/piston/src \
-v "$SCRIPT_DIR":/piston/src \
--name piston_test_runner \
"$IMAGE_NAME:$IMAGE_TAG" \
piston-test $1
-v $PWD:/piston/packages \
-d "$IMAGE_NAME_DEV:$IMAGE_TAG"
;;
test-dev)
test)
build_base
docker run \
--rm \
-it \
-e PISTON_FLAKE_PATH=/piston/src \
-v "$SCRIPT_DIR":/piston/src \
-v $DEV_VOLUME_NAME:/nix \
-e PISTON_FLAKE_PATH=/piston/packages \
-v $PWD:/piston/packages \
--name piston_test_runner \
"$IMAGE_NAME_DEV:$IMAGE_TAG" \
/piston/src/api/src/bin/test.js $1
-it "$IMAGE_NAME_DEV:$IMAGE_TAG" \
piston-test $1
;;
*)
echo "=== Piston Management ==="
echo
echo "======================"
echo "General Commands"
echo "======================"
echo " logs Show Piston logs"
echo " start Start Piston production container"
echo " stop Stop Piston"
echo " restart Restart Piston"
echo " shell Open a bash shell for the container"
echo " update Fetch latest updates"
echo " exec <language> <file> Execute the files on Piston with language"
echo "Commands:"
echo " logs Show piston logs"
echo
echo "======================"
echo "Development Commands"
echo " start Starts piston"
echo " stop Stops piston"
echo " restart Restarts piston"
echo " shell Opens a bash shell for the api container"
echo
echo " update Fetches latest updates"
echo
echo " exec <language> <file> Execute the files on piston with language"
echo
echo "Development Commands:"
echo "Running some of these commands require a nix environment setup and on the path"
echo "See https://nixos.wiki/wiki/Nix_Installation_Guide#Stable_Nix"
echo "======================"
echo " build-dev Build the development image"
echo " build [runtime-set] Build the production image, and optionally"
echo " include a specified runtime set"
echo " start-dev Start Piston development container"
echo " scaffold <language> [runtime] Initialize a template for a new runtime"
echo " test <runtime> Run unit tests on the given runtime"
echo " Optionally set runtime to --all to test all"
echo " NOTE: This is only for the runtimes contained"
echo " within this repo"
echo " test-dev <runtime> test using the development container and volume"
echo
echo " start-dev Builds a container locally and starts piston"
echo " build [runtime-set] Builds and loads the API container optionally"
echo " including the runtime set within it"
echo " scaffold <language> [runtime] Initializes a new runtime"
echo " test <runtime> Runs unit tests on the given runtime"
echo " Optionally set runtime to --all to test all"
echo " NOTE: This is only for the runtimes contained"
echo " within this repo"
echo
;;
esac

View File

@ -51,11 +51,4 @@ args: {
"gcc-fortran" = import ./gcc-fortran.nix args;
"yabasic" = import ./yabasic.nix args;
"emacs" = import ./emacs.nix args;
"gnat-ada" = import ./gnat-ada.nix args;
"rust" = import ./rust.nix args;
"dotnet-sdk-csharp" = import ./dotnet-sdk-csharp.nix args;
"dotnet-sdk-fsharp" = import ./dotnet-sdk-fsharp.nix args;
"dotnet-sdk-fsharp-interactive" = import ./dotnet-sdk-fsharp-interactive.nix args;
"dotnet-sdk-visual-basic" = import ./dotnet-sdk-visual-basic.nix args;
"fpc-pascal" = import ./fpc-pascal.nix args;
}

View File

@ -1,81 +0,0 @@
{pkgs, piston, ...}:
let
nugetPkg = pkgs.stdenv.mkDerivation {
pname = "csharp-nuget-packages";
version = pkgs.dotnet-sdk.version;
dontUnpack = true;
dontBuild = true;
dontConfigure = true;
dontFixup = true;
dontPatch = true;
buildInputs = [
pkgs.dotnet-sdk
];
installPhase = ''
mkdir $out
cd $out
export HOME=$PWD
dotnet new console -o cache_application
rm -rf cache_application
'';
};
pkg = pkgs.dotnet-sdk;
in piston.mkRuntime {
language = "csharp";
version = pkg.version;
runtime = "dotnet-sdk";
aliases = [
"csharp.net"
"c#"
"cs"
"c#.net"
"cs.net"
"c#-dotnet"
"cs-dotnet"
"csharp-dotnet"
"dotnet-c#"
"dotnet-cs"
"dotnet-csharp"
];
compile = ''
export HOME=${nugetPkg}
${pkg}/dotnet build --help > /dev/null # Supress welcome message
rename 's/$/\.cs/' "$@" # Add .cs extension
${pkg}/dotnet new console -o . --no-restore
rm Program.cs
${pkg}/dotnet restore --source ${nugetPkg}/.nuget/packages
${pkg}/dotnet build --no-restore
'';
run = ''
export HOME=$PWD
shift
${pkg}/dotnet bin/Debug/net6.0/$(basename $(realpath .)).dll "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.cs" = ''
using System;
public class Test
{
public static void Main(string[] args)
{
Console.WriteLine(args[0]);
}
}
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.cs";
})
];
}

View File

@ -1,52 +0,0 @@
{pkgs, piston, ...}:
let
pkg = pkgs.dotnet-sdk;
in piston.mkRuntime {
language = "fsharp-interactive";
version = pkg.version;
runtime = "dotnet-sdk";
aliases = [
"fsi"
"fsx"
"fsi.net"
"fsi-dotnet"
"dotnet-fsi"
"fsharp-interactive.net"
"fsharp-interactive-dotnet"
"dotnet-fsharp-interactive"
"f#-interactive"
"f#-interactive.net"
"f#-interactive-dotnet"
"dotnet-f#-interactive"
"fs-interactive"
"fs-interactive.net"
"fs-interactive-dotnet"
"dotnet-fs-interactive"
];
run = ''
export HOME=$PWD
FILENAME=$1
rename 's/$/\.fsx/' $FILENAME # Add .fsx extension
shift
${pkg}/dotnet fsi --help > /dev/null
${pkg}/dotnet fsi $FILENAME.fsx "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.fsx" = ''
open System
let args : string array = fsi.CommandLineArgs |> Array.tail
Console.WriteLine args[0]
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.fsx";
})
];
}

View File

@ -1,80 +0,0 @@
{pkgs, piston, ...}:
let
nugetPkg = pkgs.stdenv.mkDerivation {
pname = "fsharp-nuget-packages";
version = pkgs.dotnet-sdk.version;
dontUnpack = true;
dontBuild = true;
dontConfigure = true;
dontFixup = true;
dontPatch = true;
buildInputs = [
pkgs.dotnet-sdk
];
installPhase = ''
mkdir $out
cd $out
export HOME=$PWD
dotnet new console -lang F# -o fs_cache_application
rm -rf fs_cache_application
'';
};
pkg = pkgs.dotnet-sdk;
in piston.mkRuntime {
language = "fsharp";
version = pkg.version;
runtime = "dotnet-sdk";
aliases = [
"fsharp.net"
"fs"
"f#"
"fs.net"
"f#.net"
"fsharp-dotnet"
"fs-dotnet"
"f#-dotnet"
"dotnet-fsharp"
"dotnet-fs"
"dotnet-fs"
];
compile = ''
export HOME=${nugetPkg}
${pkg}/dotnet build --help > /dev/null # Supress welcome message
first_file=$1
shift
rename 's/$/\.fs/' "$@" # Add .fs extension
${pkg}/dotnet new console -lang F# -o . --no-restore
mv $first_file Program.fs
${pkg}/dotnet restore --source ${nugetPkg}/.nuget/packages
${pkg}/dotnet build --no-restore
'';
run = ''
export HOME=${nugetPkg}
shift
${pkg}/dotnet bin/Debug/net6.0/$(basename $(realpath .)).dll "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.fs" = ''
open System
[<EntryPoint>]
let main argv =
Console.WriteLine argv[0]
0
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.fs";
})
];
}

View File

@ -1,82 +0,0 @@
{pkgs, piston, ...}:
let
pkg = pkgs.dotnet-sdk;
nugetPkg = pkgs.stdenv.mkDerivation {
pname = "visual-basic-nuget-packages";
version = pkgs.dotnet-sdk.version;
dontUnpack = true;
dontBuild = true;
dontConfigure = true;
dontFixup = true;
dontPatch = true;
buildInputs = [
pkgs.dotnet-sdk
];
installPhase = ''
mkdir $out
cd $out
export HOME=$PWD
dotnet new console -lang VB -o cache_application
rm -rf cache_application
'';
};
in piston.mkRuntime {
language = "visual-basic";
version = pkg.version;
runtime = "dotnet-sdk";
aliases = [
"visual-basic.net"
"visual-basic-dotnet"
"dotnet-visual-basic"
"vb"
"vb.net"
"vb-dotnet"
"dotnet-vh"
"basic"
"basic.net"
"basic-dotnet"
"dotnet-basic"
];
compile = ''
export HOME=${nugetPkg}
${pkg}/dotnet build --help > /dev/null # Supress welcome message
rename 's/$/\.vb/' "$@" # Add .vb extension
${pkg}/dotnet new console -lang VB -o . --no-restore
rm Program.vb
${pkg}/dotnet restore --source ${nugetPkg}/.nuget/packages
${pkg}/dotnet build --no-restore
'';
run = ''
export HOME=$PWD
shift
${pkg}/dotnet bin/Debug/net6.0/$(basename $(realpath .)).dll "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.vb" = ''
Imports System
Module Module1
Sub Main(args As String())
Console.WriteLine(args(0))
End Sub
End Module
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.vb";
})
];
}

View File

@ -1,44 +0,0 @@
{pkgs, piston, ...}:
let
binutilsPkg = pkgs.binutils;
pkg = pkgs.fpc;
in piston.mkRuntime {
language = "pascal";
version = pkg.version;
runtime = "fpc";
aliases = [
"freepascal"
"pp"
"pas"
];
compile = ''
export PATH="${binutilsPkg}/bin:$PATH"
${pkg}/bin/fpc -oout -v0 "$@"
chmod +x out
'';
run = ''
shift
./out "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.pp" = ''
program test;
begin
writeln(paramStr(1));
end.
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.pp";
})
];
}

View File

@ -1,41 +0,0 @@
{pkgs, piston, ...}:
let
pkg = pkgs.gnat;
in piston.mkRuntime {
language = "ada";
version = pkg.version;
runtime = "gnat";
aliases = [
"adb"
"ads"
];
compile = ''
${pkg}/bin/gnatmake "$@" -o a.out
'';
run = ''
shift
./a.out "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.adb" = ''
with Text_IO; use Text_IO;
with Ada.Command_line; use Ada.Command_Line;
procedure hello is
begin
Put_Line(Argument(1));
end hello;
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.adb";
})
];
}

View File

@ -1,47 +0,0 @@
{pkgs, piston, ...}:
let
gccPackage = pkgs.gcc; # gcc is required for the linker
pkg = pkgs.rustc;
in piston.mkRuntime {
language = "rust";
version = pkg.version;
aliases = [
"rs"
];
compile = ''
${pkg}/bin/rustc -o binary -C linker=${gccPackage}/bin/gcc $1
chmod +x binary
'';
run = ''
shift
./binary "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.rs" = ''
pub mod helper;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
helper::print_something(args[1].to_string());
}
'';
"helper.rs" = ''
pub fn print_something(what: String) -> () {
println!("{}", what);
}
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.rs";
})
];
}