add piston nix pkg for gcc-c

This commit is contained in:
Dan Vargas 2022-02-16 10:23:32 -07:00
parent bc2036486c
commit 6297b0bcad
2 changed files with 42 additions and 0 deletions

View File

@ -45,4 +45,5 @@ args: {
"ghc-haskell" = import ./ghc-haskell.nix args; "ghc-haskell" = import ./ghc-haskell.nix args;
"groovy" = import ./groovy.nix args; "groovy" = import ./groovy.nix args;
"go" = import ./go.nix args; "go" = import ./go.nix args;
"gcc-c" = import ./gcc-c.nix args;
} }

41
runtimes/gcc-c.nix Normal file
View File

@ -0,0 +1,41 @@
{pkgs, piston, ...}:
let
pkg = pkgs.gcc;
in piston.mkRuntime {
language = "c";
version = pkg.version;
runtime = "gcc";
aliases = [
"gcc"
];
compile = ''
rename 's/$/\.c/' "$@" # Add .c extension
${pkg}/bin/gcc -std=c11 *.c -lm
'';
run = ''
shift
./a.out "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.c" = ''
#include <stdio.h>
int main(void) {
printf("OK");
return 0;
}
'';
};
args = [];
stdin = "";
packages = [];
main = "test.c";
})
];
}