Lightpanda: the headless browser designed for AI and automation
lightpanda building for nix
Muki Kiboigodeee07ac8ffc
diff --git a/flake.lock b/flake.lockindex 311eec3c0..e709ba107 100644--- a/flake.lock+++ b/flake.lock@@ -1,5 +1,20 @@{"nodes": {+ "crane": {+ "locked": {+ "lastModified": 1791754810,+ "narHash": "sha256-cN0Mgk+sQtCJcGWs9H4M0CnLRAuC4I8aCwiBTcBJs6E=",+ "owner": "ipetkov",+ "repo": "crane",+ "rev": "bd63bf1d0a0f6dcacd7549c714a671ee63b0db6a",+ "type": "github"+ },+ "original": {+ "owner": "ipetkov",+ "repo": "crane",+ "type": "github"+ }+ },"fenix": {"inputs": {"nixpkgs": [@@ -57,6 +72,7 @@},"root": {"inputs": {+ "crane": "crane","fenix": "fenix","flake-utils": "flake-utils","nixpkgs": "nixpkgs",diff --git a/flake.nix b/flake.nixindex 33ea13c56..83d59984f 100644--- a/flake.nix+++ b/flake.nix@@ -22,7 +22,6 @@crane = {url = "github:ipetkov/crane";- inputs.nixpkgs.follows = "nixpkgs";};flake-utils.url = "github:numtide/flake-utils";@@ -61,36 +60,43 @@cp -r ${pkgs.gcc.cc}/lib/gcc $out/lib/gcc'';- # This build pipeline is very unhappy without an FHS-compliant env.+ buildDeps =+ pkgs: with pkgs; [+ gcc+ gcc.cc.lib+ crtFiles+ glibc.dev+ ];++ v8BuildDeps =+ pkgs: with pkgs; [+ python3+ pkg-config+ expat.dev+ glib.dev+ zlib+ ];++ # This build pipeline (V8 mainly) is very unhappy without an FHS-compliant env.fhs = pkgs.buildFHSEnv {name = "fhs-shell";multiArch = true;targetPkgs =- pkgs: with pkgs; [- # Build Tools+ pkgs:+ (buildDeps pkgs)+ ++ (v8BuildDeps pkgs)+ ++ (with pkgs; [zigzlsrustToolchain- python3- pkg-config- cmake- gperf-- # GCC- gcc- gcc.cc.lib- crtFiles-- # Libraries- expat.dev- glib.dev- glibc.dev- zlib- ];+ ]);};lightpanda = pkgs.callPackage ./nix/package.nix {- inherit rustToolchain;+ inherit craneLib;+ buildInputs = (buildDeps pkgs) ++ (with pkgs; [ zig ]);+ src = ./.;+ version = "1.0.0";};indiff --git a/nix/package.nix b/nix/package.nixindex 1ae02cdd4..020f7631b 100644--- a/nix/package.nix+++ b/nix/package.nix@@ -1,11 +1,13 @@{+ src,lib,+ pkgs,stdenv,- zig-flake,+ fetchurl,zig,- rustToolchain,- src,+ craneLib,version,+ buildInputs ? [ ],}:letv8Archives = {@@ -31,20 +33,44 @@ letzigV8Tag = "v0.5.7";v8Version = "14.9.207.35";- v8 = lib.fetchurl {+ v8 = fetchurl {url = "https://github.com/lightpanda-io/zig-v8-fork/releases/download/${zigV8Tag}/libc_v8_${v8Version}_${v8Archive.platform}.a";hash = v8Archive.hash;};- zigDeps = stdenv.mkDerivation {- name = "lightpanda-zig-deps";+ zigDeps = zig.fetchDeps {+ inherit src version;+ name = "lightpanda";+ # Whenever build.zig.zon is updated, this must be updated too.+ hash = "sha256-VEb7BpVQ2CEj6KYQLidlWJYDqrwUDDJKXFtxZxBbuQs=";+ };+ rustFfiLib = "liblightpanda_ffi.a";+ rustLib = craneLib.buildPackage {+ pname = "lightpanda-ffi";+ inherit version;+ src = src + "/src/rust";+ cargoExtraArgs = "-p lightpanda-ffi";+ doCheck = false;};in-stdenv.mkDerivation {+zig.makePackage {+ inherit stdenv src zigDeps;pname = "lightpanda";version = "${version}-nix";+ nativeBuildInputs = buildInputs ++ [+ pkgs.autoPatchelfHook+ ];++ zigReleaseMode = "fast";+ zigFlagsArray = [+ "-Dtarget=${stdenv.hostPlatform.parsed.cpu.name}-${stdenv.hostPlatform.parsed.kernel.name}-${stdenv.hostPlatform.parsed.abi.name}"+ "-Dprebuilt_v8_path=${v8}"+ "-Dprebuilt_rust_path=${rustLib}/lib/${rustFfiLib}"+ "-Dversion=${version}"+ ];+meta = {description = "Headless browser designed for AI and automation";homepage = "https://lightpanda.io";