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:
parent
41622eaf51
commit
c276cc43f0
Notes:
github-actions[bot]
2025-03-04 15:20:51 +00:00
Author: https://github.com/NotAShelf
Commit: c276cc43f0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3767
3 changed files with 79 additions and 1 deletions
26
Toolchain/Nix/package.nix
Normal file
26
Toolchain/Nix/package.nix
Normal 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
33
Toolchain/Nix/shell.nix
Normal 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"
|
||||
'';
|
||||
}
|
21
flake.nix
21
flake.nix
|
@ -17,13 +17,32 @@
|
|||
eachSystem = nixpkgs.lib.genAttrs (import systems);
|
||||
in
|
||||
{
|
||||
packages = eachSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
# Default ladybird package built from source using current directory
|
||||
# as the source. This is not cached.
|
||||
ladybird = pkgs.callPackage ./Toolchain/Nix/package.nix { inherit self; };
|
||||
|
||||
# Alias for `nix run .` or `nix run github:LadybirdBrowser/ladybird`
|
||||
default = self.packages.${system}.ladybird;
|
||||
}
|
||||
);
|
||||
|
||||
devShells = eachSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
default = pkgs.callPackage ./Nix/shell.nix {
|
||||
# Override nixpkgs ladybird with the one provided
|
||||
# by this flake. This will allow inputsFrom to
|
||||
# remain in-sync with the package provided by the
|
||||
# flake.
|
||||
default = pkgs.callPackage ./Toolchain/Nix/shell.nix {
|
||||
inherit (self.packages.${system}) ladybird;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue