Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci_zig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ jobs:
git clean -fdx
git reset --hard HEAD
nix develop ./src/ -c zig build && zig build snapshot && zig build test

- name: Test Nix package
if: ${{ runner.os == 'Linux' || (runner.os == 'macOS' && runner.arch != 'X64') }}
uses: ./.github/actions/flaky-retry
with:
command: |
nix build ./src#roc
result/bin/roc check src/PROFILING/bench_repeated_check.roc
error_string_contains: TemporaryNameServerFailure
retry_count: 3

zig-cross-compile:
needs: check-once
Expand Down
38 changes: 32 additions & 6 deletions src/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
let
pkgs = import nixpkgs { inherit system; };

dependencies = (with pkgs; [
zig=pkgs.zig_0_15;

dependencies = [
zig
zls
git # for use in ci/zig_lints.sh
]);
pkgs.zls
pkgs.git # for use in ci/zig_lints.sh
];

shellFunctions = ''
buildcmd() {
Expand All @@ -34,7 +36,7 @@
testcmd() {
zig build snapshot && zig build test
}
export -f testscmd
export -f testcmd

fmtcmd() {
zig build fmt
Expand All @@ -48,13 +50,37 @@
'';

in {
packages = {
default = self.packages.${system}.roc;
roc = pkgs.stdenv.mkDerivation {
name = "roc";
src = ../.;
nativeBuildInputs = [ zig.hook pkgs.pkg-config ];
zigBuildFlags = [ "-Doptimize=ReleaseFast" ];

# NIX_CFLAGS_COMPILE="";
# NIX_LDFLAGS="";
};
};

apps = {
default = self.apps.${system}.roc;
roc = {
type = "app";
program = "${self.packages.${system}.roc}/bin/roc";
meta = {
description = "Roc CLI";
mainProgram = "roc";
};
};
};

devShell = pkgs.mkShell {
buildInputs = dependencies;

shellHook = ''
${shellFunctions}

echo "Some convenient commands:"
echo "${shellFunctions}" | grep -E '^\s*[a-zA-Z_][a-zA-Z0-9_]*\(\)' | sed 's/().*//' | sed 's/^[[:space:]]*/ /' | while read func; do
body=$(echo "${shellFunctions}" | sed -n "/''${func}()/,/^[[:space:]]*}/p" | sed '1d;$d' | tr '\n' ';' | sed 's/;$//' | sed 's/[[:space:]]*$//')
Expand Down