Nix: build without patching meson

Builds the subprojects directly, without relying on overridden packages.

Currently fails to link when building with Nix, but works fine when
running the Meson build in a devshell.
This commit is contained in:
Mihai Fufezan 2024-04-20 17:05:29 +03:00
parent ea47e8c92a
commit be53c86365
Signed by: fufexan
SSH Key Fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg
7 changed files with 16 additions and 154 deletions

View File

@ -92,8 +92,6 @@
# dependencies
hyprland-protocols
wlroots-hyprland
udis86
;
});
@ -104,10 +102,8 @@
} {
name = "hyprland-shell";
nativeBuildInputs = with pkgsFor.${system}; [cmake python3 expat libxml2];
buildInputs = [self.packages.${system}.wlroots-hyprland];
hardeningDisable = ["fortify"];
inputsFrom = [
self.packages.${system}.wlroots-hyprland
self.packages.${system}.hyprland
];
};

View File

@ -34,17 +34,13 @@ if cpp_compiler.check_header('execinfo.h')
endif
wlroots = subproject('wlroots-hyprland', default_options: ['examples=false', 'renderers=gles2'])
have_xwlr = wlroots.get_variable('features').get('xwayland')
xcb_dep = dependency('xcb', required: get_option('xwayland'))
cmake = import('cmake')
udis = cmake.subproject('udis86')
udis86 = udis.dependency('libudis86')
if get_option('xwayland').enabled() and not have_xwlr
error('Cannot enable Xwayland in Hyprland: wlroots has been built without Xwayland support')
endif
have_xwayland = xcb_dep.found() and have_xwlr
have_xwayland = xcb_dep.found()
if not have_xwayland
add_project_arguments('-DNO_XWAYLAND', language: 'cpp')

View File

@ -6,6 +6,7 @@
makeWrapper,
meson,
ninja,
cmake,
binutils,
cairo,
git,
@ -23,13 +24,14 @@
mesa,
pango,
pciutils,
python3,
systemd,
tomlplusplus,
udis86,
wayland,
wayland-protocols,
wayland-scanner,
wlroots-hyprland,
wlroots,
xcbutilwm,
xwayland,
debug ? false,
@ -47,9 +49,7 @@
}:
assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
assert lib.assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland"; let
wlr = wlroots-hyprland.override {inherit enableXWayland;};
in
assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland";
stdenv.mkDerivation {
pname = "hyprland${lib.optionalString debug "-debug"}";
inherit version;
@ -62,11 +62,6 @@ in
src = lib.cleanSource ../.;
};
patches = [
# make meson use the provided wlroots instead of the git submodule
./patches/meson-build.patch
];
postPatch = ''
# Fix hardcoded paths to /usr installation
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
@ -94,6 +89,8 @@ in
ninja
pkg-config
wayland-scanner
cmake
python3
];
outputs = [
@ -102,9 +99,10 @@ in
"dev"
];
buildInputs =
wlr.buildInputs
++ [
buildInputs = lib.concatLists [
wlroots.buildInputs
udis86.buildInputs
[
cairo
git
hyprcursor.dev
@ -118,14 +116,13 @@ in
pango
pciutils
tomlplusplus
udis86
wayland
wayland-protocols
wlr
]
++ lib.optionals stdenv.hostPlatform.isMusl [libexecinfo]
++ lib.optionals enableXWayland [libxcb xcbutilwm xwayland]
++ lib.optionals withSystemd [systemd];
(lib.optionals stdenv.hostPlatform.isMusl [libexecinfo])
(lib.optionals enableXWayland [libxcb xcbutilwm xwayland])
(lib.optionals withSystemd [systemd])
];
mesonBuildType =
if debug
@ -141,8 +138,6 @@ in
];
postInstall = ''
ln -s ${wlr}/include/wlr $dev/include/hyprland/wlroots
${lib.optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \
--suffix PATH : ${lib.makeBinPath [
@ -160,7 +155,7 @@ in
homepage = "https://github.com/hyprwm/Hyprland";
description = "A dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = licenses.bsd3;
platforms = wlr.meta.platforms;
platforms = wlroots.meta.platforms;
mainProgram = "Hyprland";
};
}

View File

@ -25,8 +25,6 @@ in {
inputs.hyprland-protocols.overlays.default
inputs.hyprlang.overlays.default
inputs.hyprwayland-scanner.overlays.default
self.overlays.wlroots-hyprland
self.overlays.udis86
# Hyprland packages themselves
(final: prev: let
date = mkDate (self.lastModifiedDate or "19700101");
@ -35,8 +33,6 @@ in {
stdenv = final.gcc13Stdenv;
version = "${props.version}+date=${date}_${self.shortRev or "dirty"}";
commit = self.rev or "";
udis86 = final.udis86-hyprland; # explicit override until decided on breaking change of the name
inherit (final) wlroots-hyprland; # explicit override until decided on breaking change of the name
inherit date;
};
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
@ -62,18 +58,4 @@ in {
hyprland-extras = lib.composeManyExtensions [
inputs.xdph.overlays.xdg-desktop-portal-hyprland
];
udis86 = final: prev: {
udis86-hyprland = final.callPackage ./udis86.nix {};
};
# Patched version of wlroots for Hyprland.
# It is under a new package name so as to not conflict with
# the standard version in nixpkgs.
wlroots-hyprland = final: prev: {
wlroots-hyprland = final.callPackage ./wlroots.nix {
version = "${mkDate (inputs.wlroots.lastModifiedDate or "19700101")}_${inputs.wlroots.shortRev or "dirty"}";
src = inputs.wlroots;
};
};
}

View File

@ -1,62 +0,0 @@
diff --git a/meson.build b/meson.build
index 1d2c7f9f..c5ef4e67 100644
--- a/meson.build
+++ b/meson.build
@@ -33,20 +33,7 @@ if cpp_compiler.check_header('execinfo.h')
add_project_arguments('-DHAS_EXECINFO', language: 'cpp')
endif
-wlroots = subproject('wlroots-hyprland', default_options: ['examples=false', 'renderers=gles2'])
-have_xwlr = wlroots.get_variable('features').get('xwayland')
-xcb_dep = dependency('xcb', required: get_option('xwayland'))
-
-cmake = import('cmake')
-udis = cmake.subproject('udis86')
-udis86 = udis.dependency('libudis86')
-
-if get_option('xwayland').enabled() and not have_xwlr
- error('Cannot enable Xwayland in Hyprland: wlroots has been built without Xwayland support')
-endif
-have_xwayland = xcb_dep.found() and have_xwlr
-
-if not have_xwayland
+if get_option('xwayland').disabled()
add_project_arguments('-DNO_XWAYLAND', language: 'cpp')
endif
@@ -69,8 +56,6 @@ if get_option('buildtype') == 'debug'
add_project_arguments('-DHYPRLAND_DEBUG', language: 'cpp')
endif
-version_h = run_command('sh', '-c', 'scripts/generateVersion.sh')
-
globber = run_command('find', 'src', '-name', '*.h*', check: true)
headers = globber.stdout().strip().split('\n')
foreach file : headers
diff --git a/src/meson.build b/src/meson.build
index 45701f5f..3505cefe 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -9,7 +9,7 @@ executable('Hyprland', src,
server_protos,
dependency('wayland-server'),
dependency('wayland-client'),
- wlroots.get_variable('wlroots'),
+ dependency('wlroots'),
dependency('cairo'),
dependency('hyprcursor'),
dependency('hyprlang', version: '>= 0.3.2'),
@@ -17,11 +17,11 @@ executable('Hyprland', src,
dependency('egl'),
dependency('xkbcommon'),
dependency('libinput'),
- xcb_dep,
+ dependency('xcb', required: get_option('xwayland')),
backtrace_dep,
epoll_dep,
systemd_dep,
- udis86,
+ dependency('udis86'),
dependency('pixman-1'),
dependency('gl', 'opengl'),

View File

@ -1,32 +0,0 @@
{
lib,
stdenv,
fetchFromGitHub,
autoreconfHook,
python3,
}:
stdenv.mkDerivation {
pname = "udis86";
version = "unstable-2022-10-13";
src = fetchFromGitHub {
owner = "canihavesomecoffee";
repo = "udis86";
rev = "5336633af70f3917760a6d441ff02d93477b0c86";
hash = "sha256-HifdUQPGsKQKQprByeIznvRLONdOXeolOsU5nkwIv3g=";
};
nativeBuildInputs = [autoreconfHook python3];
configureFlags = ["--enable-shared"];
outputs = ["bin" "out" "dev" "lib"];
meta = with lib; {
homepage = "https://udis86.sourceforge.net";
license = licenses.bsd2;
mainProgram = "udcli";
description = "Easy-to-use, minimalistic x86 disassembler library (libudis86)";
platforms = platforms.all;
};
}

View File

@ -1,13 +0,0 @@
{
version,
src,
wlroots,
enableXWayland ? true,
}:
wlroots.overrideAttrs (old: {
inherit version src enableXWayland;
pname = "${old.pname}-hyprland";
patches = [ ]; # don't inherit old.patches
})