1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00

Nix: Expose ladybird package in flake; reuse in shell

Add and expose a `ladybird` package in the Nix flake. Allows building
Ladybird only using Nix, and without relying on the dev shell. Other
users will be able to build Ladybird from source using nix3 CLI via
`nix build github:LadybirdBrowser/ladybird` or add it as a flake input
to consume the package.

We also re-use the package in the devshell, to keep dependencies in-sync
between the bleeding-edge source package, and the dev shell. This is an
upgrade to how we previously inferred dependencies to Nixpkgs package
for Ladybird, which had a chance to lack dependencies required to build
the latest commit.
This commit is contained in:
NotAShelf 2025-03-04 17:15:36 +03:00 committed by Andrew Kaster
parent 41622eaf51
commit c276cc43f0
Notes: github-actions[bot] 2025-03-04 15:20:51 +00:00
3 changed files with 79 additions and 1 deletions

26
Toolchain/Nix/package.nix Normal file
View file

@ -0,0 +1,26 @@
# Override ladybird from nixpkgs with the source directory as the source
# and latest revision (or "dirty") as the version. Unless new dependencies
# are introduced, this should work just fine. If a new dependency is added
# and builds are broken, simply adding the missing dependencies in buildInputs
# inside of the attribute should do the trick.
{
self,
lib,
ladybird,
...
}:
ladybird.overrideAttrs {
# Reproducible source path
src = builtins.path {
path = ../../.;
name = "ladybird-source";
filter = lib.cleanSourceFilter;
};
# Short rev will be missing in "dirty" source trees. In which case we fall
# back to "dirty" as the version.
version = self.shortRev or "dirty";
# Let's not bother nixpkgs maintainers with issues in the source.
meta.maintainers = with lib.maintainers; [ NotAShelf ];
}

33
Toolchain/Nix/shell.nix Normal file
View file

@ -0,0 +1,33 @@
{
mkShell,
kdePackages,
ccache,
clang-tools,
pre-commit,
prettier,
ladybird,
...
}:
mkShell {
inputsFrom = [
ladybird
];
packages = [
ccache
clang-tools
pre-commit
prettier
];
# Fix for: https://github.com/LadybirdBrowser/ladybird/issues/371#issuecomment-2616415434
# https://github.com/NixOS/nixpkgs/commit/049a854b4be087eaa3a09012b9c452fbc838dd41
NIX_LDFLAGS = "-lGL";
shellHook = ''
# NOTE: This is required to make it find the wayland platform plugin installed
# above, but should probably be fixed upstream.
export QT_PLUGIN_PATH="$QT_PLUGIN_PATH:${kdePackages.qtwayland}/lib/qt-6/plugins"
export QT_QPA_PLATFORM="wayland;xcb"
'';
}