diff --git a/.github/workflows/ci_zig.yml b/.github/workflows/ci_zig.yml index 2f46642ff1d..3190154ff8e 100644 --- a/.github/workflows/ci_zig.yml +++ b/.github/workflows/ci_zig.yml @@ -258,6 +258,16 @@ jobs: git clean -fdx git reset --hard HEAD nix develop ./src/ -c zig build ${{ matrix.target_flag }} && zig build snapshot ${{ matrix.target_flag }} && zig build test ${{ matrix.target_flag }} + + - 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 @@ -291,4 +301,4 @@ jobs: # Test cross-compilation with Roc's cross-compilation system (musl + glibc) roc-cross-compile: - uses: ./.github/workflows/ci_cross_compile.yml \ No newline at end of file + uses: ./.github/workflows/ci_cross_compile.yml diff --git a/build.zig.zon b/build.zig.zon index d6472c94e0d..c1efb0bd8e1 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -4,47 +4,47 @@ .minimum_zig_version = "0.15.2", .dependencies = .{ .afl_kit = .{ - .url = "git+https://github.com/bhansconnect/zig-afl-kit?ref=main#b863c41ca47ed05729e0b509fb1926c111aa2800", - .hash = "afl_kit-0.1.0-NdJ3cncdAAA4154gtkRqNApovBYfOs-LWADNE-9BzzPC", + .url = "git+https://github.com/kristoff-it/zig-afl-kit.git#b6cb826f21d4026409caec30a932be462bca27b9", + .hash = "afl_kit-0.1.0-NdJ3cncdAADtO8S74G1yMYKO1f2XoHputmaJBInsHLp2", .lazy = true, }, .roc_deps_aarch64_macos_none = .{ - .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-macos-none.tar.xz?response-content-disposition=attachment", + .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-macos-none.tar.xz", .hash = "N-V-__8AAJuttw4mNdQg3ig107ac4uyAhcFPznGHmpnmX58C", .lazy = true, }, .roc_deps_aarch64_linux_musl = .{ - .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-linux-musl.tar.xz?response-content-disposition=attachment", + .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-linux-musl.tar.xz", .hash = "N-V-__8AABnBVRNhZGWHvWKm8PO-N4Js4Zr65NnswmkZ0nYX", .lazy = true, }, .roc_deps_aarch64_windows_gnu = .{ - .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-windows-gnu.zip?response-content-disposition=attachment", + .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-windows-gnu.zip", .hash = "N-V-__8AAEbXoBTC007kkcMVW2_P5yIKMxPKQ-L5sYEc3_qH", .lazy = true, }, .roc_deps_arm_linux_musleabihf = .{ - .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/arm-linux-musleabihf.tar.xz?response-content-disposition=attachment", + .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/arm-linux-musleabihf.tar.xz", .hash = "N-V-__8AAE9SyhMGHGnkgRenWYw-birLp2Nl-IYGqIbdlga3", .lazy = true, }, .roc_deps_x86_linux_musl = .{ - .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86-linux-musl.tar.xz?response-content-disposition=attachment", + .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86-linux-musl.tar.xz", .hash = "N-V-__8AAGXNmxEQQYT5QBEheV2NJzSQjwaBuUx8wj_tGdoy", .lazy = true, }, .roc_deps_x86_64_linux_musl = .{ - .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-linux-musl.tar.xz?response-content-disposition=attachment", + .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-linux-musl.tar.xz", .hash = "N-V-__8AAL1yjxS0Lef6Fv5mMGaqNa0rGcPJxOftYK0NYuJu", .lazy = true, }, .roc_deps_x86_64_macos_none = .{ - .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-macos-none.tar.xz?response-content-disposition=attachment", + .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-macos-none.tar.xz", .hash = "N-V-__8AAInnSA9gFeMzlB67m7Nu-NYBUOXqDrzYmYgatUHk", .lazy = true, }, .roc_deps_x86_64_windows_gnu = .{ - .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-windows-gnu.zip?response-content-disposition=attachment", + .url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-windows-gnu.zip", .hash = "N-V-__8AANpEpBfszYPGDvz9XJK8VRBNG7eQzzK1iNSlkdVG", .lazy = true, }, @@ -54,7 +54,7 @@ }, .zstd = .{ .url = "git+https://github.com/allyourcodebase/zstd.git#01327d49cbc56dc24c20a167bb0055d7fc23de84", // 1.5.7 - .hash = "1220b9feb4652a62df95843e78a5db008401599366989b52d7cab421bf6263fa73d0", + .hash = "zstd-1.5.7-KEItkJ8vAAC5_rRlKmLflYQ-eKXbAIQBWZNmmJtS18q0", }, }, .fingerprint = 0x9eea22a6c3bd0034, diff --git a/build.zig.zon.nix b/build.zig.zon.nix new file mode 100644 index 00000000000..38aaec34584 --- /dev/null +++ b/build.zig.zon.nix @@ -0,0 +1,217 @@ +# generated by zon2nix (https://github.com/Cloudef/zig2nix) + +{ + lib, + linkFarm, + fetchurl, + fetchgit, + runCommandLocal, + zig, + name ? "zig-packages", +}: + +with builtins; +with lib; + +let + unpackZigArtifact = + { name, artifact }: + runCommandLocal name { nativeBuildInputs = [ zig ]; } '' + hash="$(zig fetch --global-cache-dir "$TMPDIR" ${artifact})" + mv "$TMPDIR/p/$hash" "$out" + chmod 755 "$out" + ''; + + fetchZig = + { + name, + url, + hash, + }: + let + artifact = fetchurl { inherit url hash; }; + in + unpackZigArtifact { inherit name artifact; }; + + fetchGitZig = + { + name, + url, + hash, + rev ? throw "rev is required, remove and regenerate the zon2json-lock file", + }: + let + parts = splitString "#" url; + url_base = elemAt parts 0; + url_without_query = elemAt (splitString "?" url_base) 0; + in + fetchgit { + inherit name rev hash; + url = url_without_query; + deepClone = false; + }; + + fetchZigArtifact = + { + name, + url, + hash, + ... + }@args: + let + parts = splitString "://" url; + proto = elemAt parts 0; + path = elemAt parts 1; + fetcher = { + "git+http" = fetchGitZig ( + args + // { + url = "http://${path}"; + } + ); + "git+https" = fetchGitZig ( + args + // { + url = "https://${path}"; + } + ); + http = fetchZig { + inherit name hash; + url = "http://${path}"; + }; + https = fetchZig { + inherit name hash; + url = "https://${path}"; + }; + }; + in + fetcher.${proto}; +in +linkFarm name [ + { + name = "afl_kit-0.1.0-NdJ3cncdAADtO8S74G1yMYKO1f2XoHputmaJBInsHLp2"; + path = fetchZigArtifact { + name = "afl_kit"; + url = "git+https://github.com/kristoff-it/zig-afl-kit.git#b6cb826f21d4026409caec30a932be462bca27b9"; + hash = "sha256-b3aBfO1aiM9MV6Pqdy0A8xbRy/X9zEJCztXMe18k2rA="; + rev = "b6cb826f21d4026409caec30a932be462bca27b9"; + }; + } + { + name = "AFLplusplus-4.21.0-aA1y4dZxAAAhqDy_JoRw3zwNSg8MenEGP7uJI_xNcYuV"; + path = fetchZigArtifact { + name = "AFLplusplus"; + url = "git+https://github.com/allyourcodebase/AFLplusplus#7e65eb4262688a120bf830d145060aac0e5db920"; + hash = "sha256-f5Egmkg2tEOV5jfcNj9KTU0IWOAC/hGdypmC+IG88Q0="; + rev = "7e65eb4262688a120bf830d145060aac0e5db920"; + }; + } + { + name = "N-V-__8AAKE4uAAJZgEcPdaXnWqoj-IwYf3G2h9YSm-x92gg"; + path = fetchZigArtifact { + name = "AFLplusplus"; + url = "https://github.com/AFLplusplus/AFLplusplus/archive/v4.21c.tar.gz"; + hash = "sha256-EffHfTfP9uf2WsfMVbq3kB4MYgjoRaOHZDlNBO1WezA="; + }; + } + { + name = "N-V-__8AAJuttw4mNdQg3ig107ac4uyAhcFPznGHmpnmX58C"; + path = fetchZigArtifact { + name = "roc_deps_aarch64_macos_none"; + url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-macos-none.tar.xz"; + hash = "sha256-V5vrynGlea56TSLjNpkVpQFJID+d/U/yMaflwNSQaQU="; + }; + } + { + name = "N-V-__8AABnBVRNhZGWHvWKm8PO-N4Js4Zr65NnswmkZ0nYX"; + path = fetchZigArtifact { + name = "roc_deps_aarch64_linux_musl"; + url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-linux-musl.tar.xz"; + hash = "sha256-CXGVG1A7V/xhpu1Kgv6RtF7EH0xKXlVXWVLOfx8DptA="; + }; + } + { + name = "N-V-__8AAEbXoBTC007kkcMVW2_P5yIKMxPKQ-L5sYEc3_qH"; + path = fetchZigArtifact { + name = "roc_deps_aarch64_windows_gnu"; + url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-windows-gnu.zip"; + hash = "sha256-LbVIeMh8gguUczU7nDqOhmkPlSXIYU5kH6EhcssjpWY="; + }; + } + { + name = "N-V-__8AAE9SyhMGHGnkgRenWYw-birLp2Nl-IYGqIbdlga3"; + path = fetchZigArtifact { + name = "roc_deps_arm_linux_musleabihf"; + url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/arm-linux-musleabihf.tar.xz"; + hash = "sha256-0fw/KOpzj7OSgFrysfRGv4WlU/JvaaC3xXu6V+LyEs8="; + }; + } + { + name = "N-V-__8AAGXNmxEQQYT5QBEheV2NJzSQjwaBuUx8wj_tGdoy"; + path = fetchZigArtifact { + name = "roc_deps_x86_linux_musl"; + url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86-linux-musl.tar.xz"; + hash = "sha256-LyYtnADq9CmmzRH+qu3WPRHPj2LjY3zszlyCB+CiRAo="; + }; + } + { + name = "N-V-__8AAL1yjxS0Lef6Fv5mMGaqNa0rGcPJxOftYK0NYuJu"; + path = fetchZigArtifact { + name = "roc_deps_x86_64_linux_musl"; + url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-linux-musl.tar.xz"; + hash = "sha256-zmrzXp9790M4NfjFuBU+TZ7jWjJdN+Z1vRs9aKwkmJM="; + }; + } + { + name = "N-V-__8AAInnSA9gFeMzlB67m7Nu-NYBUOXqDrzYmYgatUHk"; + path = fetchZigArtifact { + name = "roc_deps_x86_64_macos_none"; + url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-macos-none.tar.xz"; + hash = "sha256-w3vpIPXWlmIRztbXPGXiemrwYF9jjFIaFxpZaLOZ9KI="; + }; + } + { + name = "N-V-__8AANpEpBfszYPGDvz9XJK8VRBNG7eQzzK1iNSlkdVG"; + path = fetchZigArtifact { + name = "roc_deps_x86_64_windows_gnu"; + url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-windows-gnu.zip"; + hash = "sha256-tckuUDxjoeAUWC5RiHW1IVKG3H67R1D0cONk93VbkLs="; + }; + } + { + name = "bytebox-0.0.1-SXc2seA2DwAUHbrqTMz_mAQQGqO0EVPYmZ89YZn4KsTi"; + path = fetchZigArtifact { + name = "bytebox"; + url = "git+https://github.com/rdunnington/bytebox#5c8753ba11c394e4d642dddbb459edcd7c97ac26"; + hash = "sha256-UMXzrH5OPqQmt5B2hlMkKzSa1gjI2EreDRK9Son+ZvM="; + rev = "5c8753ba11c394e4d642dddbb459edcd7c97ac26"; + }; + } + { + name = "stable_array-0.1.0-3ihgvVxbAACET5MoiUn2T5ENunG_da_X3kGbji-f4QTF"; + path = fetchZigArtifact { + name = "zig-stable-array"; + url = "git+https://github.com/rdunnington/zig-stable-array#9e4f089bd3abf127eafd307ecf9796455871becc"; + hash = "sha256-NpxyNyOoFAeyREn3SvEnI/tyaYgM1ZjlcK+0jG2N0Lk="; + rev = "9e4f089bd3abf127eafd307ecf9796455871becc"; + }; + } + { + name = "zstd-1.5.7-KEItkJ8vAAC5_rRlKmLflYQ-eKXbAIQBWZNmmJtS18q0"; + path = fetchZigArtifact { + name = "zstd"; + url = "git+https://github.com/allyourcodebase/zstd.git#01327d49cbc56dc24c20a167bb0055d7fc23de84"; + hash = "sha256-1w+hR2U9t6R4sNvUMynDsYO0sNAan2svjxjUvxT+x6A="; + rev = "01327d49cbc56dc24c20a167bb0055d7fc23de84"; + }; + } + { + name = "N-V-__8AAGxifwAAGwXwvsnl_aOXFGLZTeYCu0WBhuEXr96u"; + path = fetchZigArtifact { + name = "zstd"; + url = "git+https://github.com/facebook/zstd.git?ref=v1.5.7#f8745da6ff1ad1e7bab384bd1f9d742439278e99"; + hash = "sha256-tNFWIT9ydfozB8dWcmTMuZLCQmQudTFJIkSr0aG7S44="; + rev = "f8745da6ff1ad1e7bab384bd1f9d742439278e99"; + }; + } +] diff --git a/build.zig.zon2json-lock b/build.zig.zon2json-lock new file mode 100644 index 00000000000..35e27894d4e --- /dev/null +++ b/build.zig.zon2json-lock @@ -0,0 +1,83 @@ +{ + "afl_kit-0.1.0-NdJ3cncdAADtO8S74G1yMYKO1f2XoHputmaJBInsHLp2": { + "name": "afl_kit", + "url": "git+https://github.com/kristoff-it/zig-afl-kit.git#b6cb826f21d4026409caec30a932be462bca27b9", + "hash": "sha256-b3aBfO1aiM9MV6Pqdy0A8xbRy/X9zEJCztXMe18k2rA=", + "rev": "b6cb826f21d4026409caec30a932be462bca27b9" + }, + "AFLplusplus-4.21.0-aA1y4dZxAAAhqDy_JoRw3zwNSg8MenEGP7uJI_xNcYuV": { + "name": "AFLplusplus", + "url": "git+https://github.com/allyourcodebase/AFLplusplus#7e65eb4262688a120bf830d145060aac0e5db920", + "hash": "sha256-f5Egmkg2tEOV5jfcNj9KTU0IWOAC/hGdypmC+IG88Q0=", + "rev": "7e65eb4262688a120bf830d145060aac0e5db920" + }, + "N-V-__8AAKE4uAAJZgEcPdaXnWqoj-IwYf3G2h9YSm-x92gg": { + "name": "AFLplusplus", + "url": "https://github.com/AFLplusplus/AFLplusplus/archive/v4.21c.tar.gz", + "hash": "sha256-EffHfTfP9uf2WsfMVbq3kB4MYgjoRaOHZDlNBO1WezA=" + }, + "N-V-__8AAJuttw4mNdQg3ig107ac4uyAhcFPznGHmpnmX58C": { + "name": "roc_deps_aarch64_macos_none", + "url": "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-macos-none.tar.xz", + "hash": "sha256-V5vrynGlea56TSLjNpkVpQFJID+d/U/yMaflwNSQaQU=" + }, + "N-V-__8AABnBVRNhZGWHvWKm8PO-N4Js4Zr65NnswmkZ0nYX": { + "name": "roc_deps_aarch64_linux_musl", + "url": "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-linux-musl.tar.xz", + "hash": "sha256-CXGVG1A7V/xhpu1Kgv6RtF7EH0xKXlVXWVLOfx8DptA=" + }, + "N-V-__8AAEbXoBTC007kkcMVW2_P5yIKMxPKQ-L5sYEc3_qH": { + "name": "roc_deps_aarch64_windows_gnu", + "url": "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/aarch64-windows-gnu.zip", + "hash": "sha256-LbVIeMh8gguUczU7nDqOhmkPlSXIYU5kH6EhcssjpWY=" + }, + "N-V-__8AAE9SyhMGHGnkgRenWYw-birLp2Nl-IYGqIbdlga3": { + "name": "roc_deps_arm_linux_musleabihf", + "url": "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/arm-linux-musleabihf.tar.xz", + "hash": "sha256-0fw/KOpzj7OSgFrysfRGv4WlU/JvaaC3xXu6V+LyEs8=" + }, + "N-V-__8AAGXNmxEQQYT5QBEheV2NJzSQjwaBuUx8wj_tGdoy": { + "name": "roc_deps_x86_linux_musl", + "url": "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86-linux-musl.tar.xz", + "hash": "sha256-LyYtnADq9CmmzRH+qu3WPRHPj2LjY3zszlyCB+CiRAo=" + }, + "N-V-__8AAL1yjxS0Lef6Fv5mMGaqNa0rGcPJxOftYK0NYuJu": { + "name": "roc_deps_x86_64_linux_musl", + "url": "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-linux-musl.tar.xz", + "hash": "sha256-zmrzXp9790M4NfjFuBU+TZ7jWjJdN+Z1vRs9aKwkmJM=" + }, + "N-V-__8AAInnSA9gFeMzlB67m7Nu-NYBUOXqDrzYmYgatUHk": { + "name": "roc_deps_x86_64_macos_none", + "url": "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-macos-none.tar.xz", + "hash": "sha256-w3vpIPXWlmIRztbXPGXiemrwYF9jjFIaFxpZaLOZ9KI=" + }, + "N-V-__8AANpEpBfszYPGDvz9XJK8VRBNG7eQzzK1iNSlkdVG": { + "name": "roc_deps_x86_64_windows_gnu", + "url": "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.15.1/x86_64-windows-gnu.zip", + "hash": "sha256-tckuUDxjoeAUWC5RiHW1IVKG3H67R1D0cONk93VbkLs=" + }, + "bytebox-0.0.1-SXc2seA2DwAUHbrqTMz_mAQQGqO0EVPYmZ89YZn4KsTi": { + "name": "bytebox", + "url": "git+https://github.com/rdunnington/bytebox#5c8753ba11c394e4d642dddbb459edcd7c97ac26", + "hash": "sha256-UMXzrH5OPqQmt5B2hlMkKzSa1gjI2EreDRK9Son+ZvM=", + "rev": "5c8753ba11c394e4d642dddbb459edcd7c97ac26" + }, + "stable_array-0.1.0-3ihgvVxbAACET5MoiUn2T5ENunG_da_X3kGbji-f4QTF": { + "name": "zig-stable-array", + "url": "git+https://github.com/rdunnington/zig-stable-array#9e4f089bd3abf127eafd307ecf9796455871becc", + "hash": "sha256-NpxyNyOoFAeyREn3SvEnI/tyaYgM1ZjlcK+0jG2N0Lk=", + "rev": "9e4f089bd3abf127eafd307ecf9796455871becc" + }, + "zstd-1.5.7-KEItkJ8vAAC5_rRlKmLflYQ-eKXbAIQBWZNmmJtS18q0": { + "name": "zstd", + "url": "git+https://github.com/allyourcodebase/zstd.git#01327d49cbc56dc24c20a167bb0055d7fc23de84", + "hash": "sha256-1w+hR2U9t6R4sNvUMynDsYO0sNAan2svjxjUvxT+x6A=", + "rev": "01327d49cbc56dc24c20a167bb0055d7fc23de84" + }, + "N-V-__8AAGxifwAAGwXwvsnl_aOXFGLZTeYCu0WBhuEXr96u": { + "name": "zstd", + "url": "git+https://github.com/facebook/zstd.git?ref=v1.5.7#f8745da6ff1ad1e7bab384bd1f9d742439278e99", + "hash": "sha256-tNFWIT9ydfozB8dWcmTMuZLCQmQudTFJIkSr0aG7S44=", + "rev": "f8745da6ff1ad1e7bab384bd1f9d742439278e99" + } +} \ No newline at end of file diff --git a/src/flake.nix b/src/flake.nix index f7ea3a1bd65..457ea90a0c5 100644 --- a/src/flake.nix +++ b/src/flake.nix @@ -1,4 +1,3 @@ - # Use this flake with `nix develop ./src` { @@ -11,20 +10,28 @@ flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, flake-utils, ... }@inputs: + outputs = + { + self, + nixpkgs, + flake-utils, + + ... + }@inputs: let - supportedSystems = - [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; - in flake-utils.lib.eachSystem supportedSystems (system: + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + "aarch64-linux" + ]; + + in + flake-utils.lib.eachSystem supportedSystems ( + system: let pkgs = import nixpkgs { inherit system; }; - - dependencies = (with pkgs; [ - zig - zls - git # for use in ci/zig_lints.sh - ]); - + zig = pkgs.zig_0_15; shellFunctions = '' buildcmd() { zig build roc @@ -47,24 +54,74 @@ export -f cicmd ''; - in { + in + { + packages = { + default = self.packages.${system}.roc; + roc = pkgs.stdenv.mkDerivation (finalAttrs: { + pname = "roc"; + version = "0.0.0"; + src = pkgs.lib.cleanSource ./..; + deps = pkgs.callPackage ../build.zig.zon.nix { }; + nativeBuildInputs = [ + zig.hook + pkgs.pkg-config + ] + ++ pkgs.lib.lists.optional pkgs.stdenv.isDarwin [ pkgs.apple-sdk ]; + buildInputs = []; + dontConfigure = true; + zigBuildFlags = [ + "--system" + "${finalAttrs.deps}" + ]; + env.NIX_CFLAGS_COMPILE = ""; + env.NIX_LDFLAGS = ""; + env.NIX_CFLAGS_LINK = ""; + env.LD_LIBRARY_PATH=""; + env.LIBRARY_PATH=""; + + meta.mainProgram = "roc"; + }); + }; + + apps = { + default = self.apps.${system}.roc; + roc = { + type = "app"; + program = pkgs.lib.getExe self.packages.${system}.roc; + meta = { + description = "Roc CLI"; + mainProgram = "roc"; + }; + }; + }; devShell = pkgs.mkShell { - buildInputs = dependencies; + buildInputs = [ + zig + pkgs.zls + pkgs.git # for use in ci/zig_lints.sh + (pkgs.writeShellScriptBin "zon2lock" "nix run github:Cloudef/zig2nix -- zon2lock build.zig.zon") + (pkgs.writeShellScriptBin "zon2nix" "nix run github:Cloudef/zig2nix -- zon2nix build.zig.zon2json-lock") + ]; 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:]]*$//') echo " $func = $body" done + echo " zon2lock = nix run github:Cloudef/zig2nix -- zon2lock build.zig.zon" + echo " zon2nix = nix run github:Cloudef/zig2nix -- zon2nix build.zig.zon2json-lock" echo "" unset NIX_CFLAGS_COMPILE unset NIX_LDFLAGS ''; # unset to fix: Unrecognized C flag from NIX_CFLAGS_COMPILE: -fmacro-prefix-map }; - }); + formatter = pkgs.nixfmt-rfc-style; + } + ); }