add zig 0.9.0

This commit is contained in:
Dan Vargas 2022-02-01 13:18:40 -07:00
parent 6d1156188c
commit 6da12dd2b4
2 changed files with 44 additions and 0 deletions

View File

@ -14,4 +14,5 @@ args: {
"erlang" = import ./erlang.nix args;
"gawk-awk" = import ./gawk-awk.nix args;
"openjdk11_headless-java" = import ./openjdk11_headless-java.nix args;
"zig" = import ./zig.nix args;
}

43
runtimes/zig.nix Normal file
View File

@ -0,0 +1,43 @@
{pkgs, piston, ...}:
let
pkg = pkgs.zig;
in piston.mkRuntime {
language = "zig";
version = pkg.version;
aliases = [];
# Add .zig extension for compile script and optimize compiler for small programs
compile = ''
rename 's/$/\.zig/' "$@"
${pkg}/bin/zig build-exe -O ReleaseSafe --color off --cache-dir . --global-cache-dir . --name out *.zig
'';
# Remove first arg filename and run binary with remaining args
run = ''
shift
./out "$@"
'';
# These should output "OK" to STDOUT if everything looks good
# Run the following command to test the package:
# $ ./piston test zig
tests = [
# Standard output test
(piston.mkTest {
files = {
"test.zig" = ''
const std = @import("std");
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
try stdout.print("OK\n", .{});
}
'';
};
args = [];
stdin = "";
packages = [];
main = "test.zig";
})
];
}