Skip to content

Add lightpanda and default package to flake.nix#1976

Closed
lukasl-dev wants to merge 10 commits intolightpanda-io:mainfrom
lukasl-dev:main
Closed

Add lightpanda and default package to flake.nix#1976
lukasl-dev wants to merge 10 commits intolightpanda-io:mainfrom
lukasl-dev:main

Conversation

@lukasl-dev
Copy link
Copy Markdown

@lukasl-dev lukasl-dev commented Mar 23, 2026

This PR adds the lightpanda and default packages to flake.nix, such that lightpanda can be build via.

nix build . # or `nix build github:lightpanda-io/browser`

This allows Nixians to include lightpanda directly into their system config as a flake input:

# flake.nix
inputs.lightpanda.url = "github:lightpanda-io/browser";

# lightpanda.nix
{ inputs, pkgs, ... }:
{
  environment.systemPackages = [
    inputs.lightpanda.packages.${pkgs.stdenv.hostPlatform.system}.default
  ];
}

It can also be run via nix run:

nix run github:lightpanda-io/browser # or `nix run .`

The package build reuses the existing FHS environment already defined in flake.nix, and adds the necessary Zig and Cargo dependency handling so the build works in the Nix sandbox.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@lukasl-dev
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@krichprollsch krichprollsch requested a review from mookums March 23, 2026 18:47
@mookums
Copy link
Copy Markdown
Contributor

mookums commented Mar 27, 2026

Hi! Tried this today and it fails for me.

error: Cannot build '/nix/store/hvma90wfwyxf8wqkybb079l8nn6aiv50-source.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/xy9bhpxljg97p4qhhhs65gmrws16sy2y-source
       Last 7 log lines:
       >
       > trying https://codeload.github.com/lightpanda-io/zig-v8-fork/tar.gz/refs/tags/v0.3.4
       >   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
       >                                  Dload  Upload   Total   Spent    Left  Speed
       > 100 57993    0 57993    0     0   159k      0 --:--:-- --:--:-- --:--:--  159k
       > unpacking source archive /build/v0.3.4
       > do not know how to unpack source archive /build/v0.3.4
       For full logs, run:
         nix log /nix/store/hvma90wfwyxf8wqkybb079l8nn6aiv50-source.drv
error: Cannot build '/nix/store/jm19kbiqd865a789ynnr2j3cf6yiigyn-zig-packages.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/9xv22gf5cql3hy9mka23hv6x1h4az1dp-zig-packages

@mookums mookums self-assigned this Mar 27, 2026
@lukasl-dev
Copy link
Copy Markdown
Author

That's interesting as I'm already using it in my own config.

It seems like Nix couldn't figure out how to extract the archive for codeload urls. I think I found a fix, however, could you share your nix --version and your system (x86_64-linux, aarch64-darwin, etc.)? Maybe it's a Nix version thing (which would be funny).

@lukasl-dev
Copy link
Copy Markdown
Author

lukasl-dev commented Apr 2, 2026

My VPS and my Raspberry PI had a similar issue. Not fully identical, but similar:

error: Cannot build '/nix/store/6k0j6p8s28pf2vjj6rqd84iyd1g2y9w3-source.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/d6k8my29bvn3q1gsghz4kb01wf0hxsad-source
       Last 8 log lines:
       >
       > trying https://chromium.googlesource.com/chromium/tools/depot_tools.git/+archive/4ce8ba39a3488397a2d1494f167020f21de502f3.tar.gz
       >   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
       >                                  Dload  Upload   Total   Spent    Left  Speed
       > 100 1251k    0 1251k    0     0  2199k      0 --:--:-- --:--:-- --:--:-- 2203k
       > unpacking source archive /build/4ce8ba39a3488397a2d1494f167020f21de502f3.tar.gz
       > error: zip file must contain a single file or directory.
       > hint: Pass stripRoot=false; to fetchzip to assume flat list of files.
       For full logs, run:
         nix log /nix/store/6k0j6p8s28pf2vjj6rqd84iyd1g2y9w3-source.drv

Apparently, zon2nix struggles with redirected urls and with archives that have no root directory. I created a zon2nix.sh to generate the required Nix file using zon2nix and patch it afterwards (canonical urls, root stripping). The script is available inside the devShell via zon2nix (without any arguments) and via nix run .#zon2nix.

And I renamed deps.nix to build.zig.zon.nix to make intent more clear, given there are cargo dependencies too.

I've tested it on all three of my Nix devices and two of them build successfuly now.

There's one issue left w.r.t. FHS for packaging.

@lukasl-dev
Copy link
Copy Markdown
Author

FHS-related issues are now also fixed. 3/3 Nix devices build successfully now.

@mookums
Copy link
Copy Markdown
Contributor

mookums commented Apr 22, 2026

Hello,

This does build for me now and it seems to work fine so I appreciate all of the fixes. I'm not entirely sure of the maintenance burden here considering most of the team doesn't use Nix and this seems to require regeneration of the build.zig.zon.nix whenever dependencies are bumped. I think a solution like this might be viable later down the line, whenever we hit a stable release cadence and generation of this files can be a part of preparation for a release.

@lukasl-dev
Copy link
Copy Markdown
Author

Hi! I understand your concern, but we as Nix users are pretty much used to pulling foreign Nix flakes that break every now and then (opencode, fff, etc.). That's why I included the zon2nix.sh script so that other Nixians can open PRs as soon as something breaks or dependencies change unexpectedly. Ideally, unless something changes drastically, a simple ./zon2nix.sh should suffice to update the build.zig.zon.nix file. So I don't believe the burden of maintaining the flake package is necessarily on your side, and Nix users are always* happy to see a project with a flake package :>

Copy link
Copy Markdown
Contributor

@mookums mookums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough with regards to maintenance. I'm willing to get this pushed through if you can just make some of these changes + make sure the flake and build.zig.zon.nix is up to date.

Comment thread flake.nix

flake-utils.url = "github:numtide/flake-utils";

zon2nix.url = "github:nix-community/zon2nix";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zon2nix.url = "github:nix-community/zon2nix";
zon2nix.url = "github:nix-community/zon2nix";
zon2nix.inputs.nixpkgs.follows = "nixpkgs";

Comment thread flake.nix
++ [ zon2nix.packages.${system}.default ];
text = # bash
''
exec bash "$PWD/zon2nix.sh"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried this today and i don't think you even need this wrapper script.

You can just do zon2nix > build.zig.zon.nix and it seems to generate a valid file that still builds.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this seems to work fine:

zon2nixScript = pkgs.writeShellApplication {
  name = "zon2nix";
  runtimeInputs = [ zon2nix.packages.${system}.default ];
  text = ''
    zon2nix > build.zig.zon.nix
  '';
};

Comment thread flake.nix
{
packages = rec {
default = lightpanda;
lightpanda = pkgs.stdenv.mkDerivation {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer if this was up in the let and then you just had something like:

...
lightpanda = pkgs.stdenv.mkDerivation {
...
}
in
{
packages =  {
     default = lightpanda;
      lightpanda = lightpanda;
    }
}

just makes the final part less noisy.

Comment thread zon2nix.sh
@@ -0,0 +1,132 @@
#!/usr/bin/env bash
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this file at all. See above comment about zon2nix

@mookums
Copy link
Copy Markdown
Contributor

mookums commented May 7, 2026

This PR also does not build for me if we do not provide a prebuilt v8.

@mookums
Copy link
Copy Markdown
Contributor

mookums commented May 7, 2026

Going to say this is not planned for now. I'm willing to revisit adding Nix build support to Lightpanda at a later date (especially in the future when we have stable builds).

@mookums mookums closed this May 7, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants