From 8670938397eab34405645cd991852ae0e35237e6 Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Mon, 17 Nov 2025 07:02:35 -0800 Subject: [PATCH 1/3] add rust support into nix flake --- flake.lock | 51 +++++++++++++++++++++++++++++++++++++++++++++------ flake.nix | 10 +++++++++- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 497b274e8..13693e9a8 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1763016383, + "narHash": "sha256-eYmo7FNvm3q08iROzwIi8i9dWuUbJJl3uLR3OLnSmdI=", + "owner": "nix-community", + "repo": "fenix", + "rev": "0fad5c0e5c531358e7174cd666af4608f08bc3ba", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -75,11 +96,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1756822655, - "narHash": "sha256-xQAk8xLy7srAkR5NMZFsQFioL02iTHuuEIs3ohGpgdk=", + "lastModified": 1763043403, + "narHash": "sha256-DgCTbHdIpzbXSlQlOZEWj8oPt2lrRMlSk03oIstvkVQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4bdac60bfe32c41103ae500ddf894c258291dd61", + "rev": "75e04ecd084f93d4105ce68c07dac7656291fe2e", "type": "github" }, "original": { @@ -91,12 +112,30 @@ }, "root": { "inputs": { + "fenix": "fenix", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "zigPkgs": "zigPkgs", "zlsPkg": "zlsPkg" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1762860488, + "narHash": "sha256-rMfWMCOo/pPefM2We0iMBLi2kLBAnYoB9thi4qS7uk4=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "2efc80078029894eec0699f62ec8d5c1a56af763", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -136,11 +175,11 @@ ] }, "locked": { - "lastModified": 1756555914, - "narHash": "sha256-7yoSPIVEuL+3Wzf6e7NHuW3zmruHizRrYhGerjRHTLI=", + "lastModified": 1762907712, + "narHash": "sha256-VNW/+VYIg6N4b9Iq+F0YZmm22n74IdFS7hsPLblWuOY=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "d0df3a2fd0f11134409d6d5ea0e510e5e477f7d6", + "rev": "d16453ee78765e49527c56d23386cead799b6b53", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index fd5fbef87..330bbdf04 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,11 @@ zlsPkg.inputs.zig-overlay.follows = "zigPkgs"; zlsPkg.inputs.nixpkgs.follows = "nixpkgs"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-utils.url = "github:numtide/flake-utils"; }; @@ -19,6 +24,7 @@ nixpkgs, zigPkgs, zlsPkg, + fenix, flake-utils, ... }: @@ -36,6 +42,8 @@ inherit system overlays; }; + rustToolchain = fenix.packages.${system}.stable.toolchain; + # We need crtbeginS.o for building. crtFiles = pkgs.runCommand "crt-files" { } '' mkdir -p $out/lib @@ -51,6 +59,7 @@ # Build Tools zigpkgs."0.15.2" zls + rustToolchain python3 pkg-config cmake @@ -66,7 +75,6 @@ glib.dev glibc.dev zlib - zlib.dev ]; }; in From c1c0edab9f120579be7e4c2e9e273157691a48b9 Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Mon, 17 Nov 2025 07:02:53 -0800 Subject: [PATCH 2/3] fix curl dependency issue with zlib --- build.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 9f6271699..8b7fa2221 100644 --- a/build.zig +++ b/build.zig @@ -87,7 +87,7 @@ pub fn build(b: *Build) !void { .sanitize_c = enable_csan, .sanitize_thread = enable_tsan, .imports = &.{ - .{.name = "lightpanda", .module = lightpanda_module}, + .{ .name = "lightpanda", .module = lightpanda_module }, }, }), }); @@ -125,7 +125,7 @@ pub fn build(b: *Build) !void { .sanitize_c = enable_csan, .sanitize_thread = enable_tsan, .imports = &.{ - .{.name = "lightpanda", .module = lightpanda_module}, + .{ .name = "lightpanda", .module = lightpanda_module }, }, }), }); @@ -151,7 +151,7 @@ pub fn build(b: *Build) !void { .sanitize_c = enable_csan, .sanitize_thread = enable_tsan, .imports = &.{ - .{.name = "lightpanda", .module = lightpanda_module}, + .{ .name = "lightpanda", .module = lightpanda_module }, }, }), }); @@ -658,6 +658,8 @@ fn buildCurl(b: *Build, m: *Build.Module) !void { curl.addIncludePath(b.path(root ++ "lib")); curl.addIncludePath(b.path(root ++ "include")); + curl.addIncludePath(b.path("vendor/zlib")); + curl.addCSourceFiles(.{ .flags = &.{}, .files = &.{ From 38ca58d71e60cdf0bc010408e03936c938bbbbc5 Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Mon, 17 Nov 2025 07:25:44 -0800 Subject: [PATCH 3/3] use llvm on tests --- build.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/build.zig b/build.zig index 8b7fa2221..704203d2a 100644 --- a/build.zig +++ b/build.zig @@ -105,6 +105,7 @@ pub fn build(b: *Build) !void { // test const tests = b.addTest(.{ .root_module = lightpanda_module, + .use_llvm = true, .test_runner = .{ .path = b.path("src/test_runner.zig"), .mode = .simple }, }); const run_tests = b.addRunArtifact(tests);