{ pkgs, prepareJob }: with pkgs; let self = { perl = prepareJob { name = "perl"; mem = 50; aliases = [ "pl" ]; storeDrives.perl = [ pkgsCross.musl64.perl ]; preCommand = '' perl -e 'print "Hello world!"' ''; command = '' perl "$1" ''; testInput = "print \"success\""; }; rust = let opts = lib.concatStringsSep " " [ "--color never" "-C opt-level=0" "-C prefer-dynamic" "-C debuginfo=0" "-v" "--error-format short" "-C codegen-units=1" ]; in prepareJob { name = "rust"; aliases = [ "rs" ]; mem = 200; storeDrives.rust = [ (rustChannelOf { channel = "nightly"; date = "2018-08-06"; }).rust gcc ]; preCommand = '' echo 'fn main() {}' > /tmp/sample rustc ${opts} -o /tmp/sample.out /tmp/sample /tmp/sample.out rm /tmp/sample /tmp/sample.out ''; command = '' mv "$1" /input.raw cat > /input < /input.go < /tmp/sample gcc -x c -o /tmp/sample.out /tmp/sample /tmp/sample.out ''; command = '' gcc -x c -o /input.out -w -fdiagnostics-color=never "$1" && /input.out ''; testInput = '' void main() { printf("success\n"); } ''; }; cpp = prepareJob { name = "cpp"; mem = 100; storeDrives.gcc = [ gcc ]; command = '' mv "$1" /input.raw cat > /input < using namespace std; int main() { $(cat /input.raw) return 0; }; EOF g++ -x 'c++' -o /input.out -w -fdiagnostics-color=never /input && /input.out ''; testInput = "cout << \"success\" << endl;"; }; tcc = prepareJob { name = "tcc"; mem = 50; storeDrives.tcc = [ tinycc ]; preCommand = '' echo 'int main() { return 0; }' > /tmp/sample tcc -run /tmp/sample ''; command = '' tcc -run "$1" 2>/dev/null ''; testInput = '' void main() { printf("success\n"); } ''; }; java = prepareJob rec { name = "java"; mem = 150; storeDrives.jdk = [ openjdk ]; preCommand = '' cat > /tmp/Main.java < /tmp/Main.kts < /input <]-[<<<]]]>>>-]>-.---.>..>.<<<<-.<+.>>>>>.>.<<.<-.' > /tmp/sample bf < /tmp/sample ''; command = '' bf < "$1" ''; testInput = "+[-[<<[+[--->]-[<<<]]]>>>-]>-.---.>..>.<<<<-.<+.>>>>>.>.<<.<-."; testOutput = "hello world"; }; php = prepareJob { name = "php"; mem = 100; storeDrives.php = [ php ]; command = '' php -r "$(cat "$1")" ''; testInput = ''echo "success";''; }; racket = prepareJob { name = "racket"; aliases = [ "rkt" "r" ]; mem = 200; storeDrives.racket = [ racket ]; preCommand = '' racket -e '(+ 40 2)' ''; command = '' ( echo "#lang racket" cat "$1" ) | racket /proc/self/fd/0 ''; testInput = "(displayln 'success)"; }; guile = prepareJob { name = "guile"; mem = 100; storeDrives.guile = [ guile ]; command = '' guile --no-auto-compile -s "$1" ''; testInput = ''(display "success")''; }; haskell = prepareJob { name = "haskell"; aliases = [ "hask" "hs" "h" ]; mem = 200; storeDrives.ghc = [ ghc ]; preCommand = '' echo '"foo":[]:[]' > /tmp/sample ghci -v0 < /tmp/sample ''; command = '' ghci -v0 -fdiagnostics-color=never < "$1" ''; testInput = "putStrLn \"success\""; }; qalculate = prepareJob { name = "qalculate"; mem = 100; aliases = [ "qalc" "calc" "cal" "q" ]; storeDrives.qalc = [ libqalculate ]; preCommand = '' mkdir /.config qalc "42 byte to megabyte" ''; command = '' qalc -terse -file "$1" ''; testInput = "\"success\""; testOutput = "\"success\""; }; nix = let nixpkgsAsDerivation = runCommand "nixpkgs-as-derivation" {} '' cp -a ${path} $out ''; in prepareJob { name = "nix"; mem = 200; storeDrives.nix = [ (nix.override { storeDir = "/tmp/nix/store"; stateDir = "/tmp/nix/var"; }) ]; storeDrives.nixpkgs = [ nixpkgsAsDerivation ]; preCommand = '' mkdir -p /tmp/nix/var/nix/db touch /tmp/nix/var/nix/db/big-lock # echo nixbld1:x:30001:30000:Nix build user 1:/:/bin/sh >> /etc/passwd # echo nixbld:x:30000:nixbld1 >> /etc/group mkdir -p /etc/nix echo 'build-users-group =' >> /etc/nix/nix.conf nix-instantiate --eval -E "42" ''; command = '' export NIX_PATH=nixpkgs=${toString nixpkgsAsDerivation} nix-instantiate --eval --read-write-mode --option allow-unsafe-native-code-during-evaluation true "$1" ''; testInput = '' with import {}; builtins.readFile (stdenvNoCC.mkDerivation { name = "foo"; buildCommand = "echo success > $out"; }) ''; testOutput = "\"success\""; }; listAll = with self; [ ash sh python python2 ruby perl lua nodejs haskell rust c tcc cpp java # kotlin racket guile brainfuck php go qalculate ]; all = symlinkJoin { name = "all-evaluators"; paths = self.listAll; }; apparmorAll = map (p: p.apparmor) self.listAll; }; in self