Nix: use CMake for builds instead of Meson

Build using submodules instead of patching the build process and using
Nix derivations of the subprojects.

From this commit on, you'll have to change the Hyprland flake url to
`git+https://github.com/hyprwm/Hyprland?submodules=1`
This commit is contained in:
Mihai Fufezan 2024-04-21 19:58:54 +03:00
parent 99aa34db6e
commit f15513309b
7 changed files with 49 additions and 202 deletions

View File

@ -29,9 +29,11 @@
"hyprland-protocols": { "hyprland-protocols": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"xdph",
"nixpkgs" "nixpkgs"
], ],
"systems": [ "systems": [
"xdph",
"systems" "systems"
] ]
}, },
@ -114,12 +116,10 @@
"root": { "root": {
"inputs": { "inputs": {
"hyprcursor": "hyprcursor", "hyprcursor": "hyprcursor",
"hyprland-protocols": "hyprland-protocols",
"hyprlang": "hyprlang", "hyprlang": "hyprlang",
"hyprwayland-scanner": "hyprwayland-scanner", "hyprwayland-scanner": "hyprwayland-scanner",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"systems": "systems", "systems": "systems",
"wlroots": "wlroots",
"xdph": "xdph" "xdph": "xdph"
} }
}, },
@ -138,28 +138,9 @@
"type": "github" "type": "github"
} }
}, },
"wlroots": {
"flake": false,
"locked": {
"lastModified": 1713731601,
"narHash": "sha256-bdcKdtLkusvv85DNuJsajZLFeq7bXp+x5AGP1Sd4wD8=",
"owner": "hyprwm",
"repo": "wlroots-hyprland",
"rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "wlroots-hyprland",
"rev": "5c1d51c5a2793480f5b6c4341ad0797052aec2ea",
"type": "github"
}
},
"xdph": { "xdph": {
"inputs": { "inputs": {
"hyprland-protocols": [ "hyprland-protocols": "hyprland-protocols",
"hyprland-protocols"
],
"hyprlang": [ "hyprlang": [
"hyprlang" "hyprlang"
], ],

View File

@ -7,14 +7,6 @@
# <https://github.com/nix-systems/nix-systems> # <https://github.com/nix-systems/nix-systems>
systems.url = "github:nix-systems/default-linux"; systems.url = "github:nix-systems/default-linux";
wlroots = {
type = "github";
owner = "hyprwm";
repo = "wlroots-hyprland";
rev = "5c1d51c5a2793480f5b6c4341ad0797052aec2ea";
flake = false;
};
hyprcursor = { hyprcursor = {
url = "github:hyprwm/hyprcursor"; url = "github:hyprwm/hyprcursor";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -22,12 +14,6 @@
inputs.hyprlang.follows = "hyprlang"; inputs.hyprlang.follows = "hyprlang";
}; };
hyprland-protocols = {
url = "github:hyprwm/hyprland-protocols";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
};
hyprlang = { hyprlang = {
url = "github:hyprwm/hyprlang"; url = "github:hyprwm/hyprlang";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -44,7 +30,6 @@
url = "github:hyprwm/xdg-desktop-portal-hyprland"; url = "github:hyprwm/xdg-desktop-portal-hyprland";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems"; inputs.systems.follows = "systems";
inputs.hyprland-protocols.follows = "hyprland-protocols";
inputs.hyprlang.follows = "hyprlang"; inputs.hyprlang.follows = "hyprlang";
}; };
}; };
@ -92,8 +77,6 @@
# dependencies # dependencies
hyprland-protocols hyprland-protocols
wlroots-hyprland
udis86
; ;
}); });
@ -103,13 +86,9 @@
stdenv = pkgsFor.${system}.gcc13Stdenv; stdenv = pkgsFor.${system}.gcc13Stdenv;
} { } {
name = "hyprland-shell"; name = "hyprland-shell";
nativeBuildInputs = with pkgsFor.${system}; [cmake python3 expat libxml2]; nativeBuildInputs = with pkgsFor.${system}; [expat libxml2];
buildInputs = [self.packages.${system}.wlroots-hyprland];
hardeningDisable = ["fortify"]; hardeningDisable = ["fortify"];
inputsFrom = [ inputsFrom = [pkgsFor.${system}.hyprland];
self.packages.${system}.wlroots-hyprland
self.packages.${system}.hyprland
];
}; };
}); });

View File

@ -4,10 +4,12 @@
pkg-config, pkg-config,
pkgconf, pkgconf,
makeWrapper, makeWrapper,
cmake,
meson, meson,
ninja, ninja,
binutils, binutils,
cairo, cairo,
expat,
git, git,
hyprcursor, hyprcursor,
hyprland-protocols, hyprland-protocols,
@ -19,19 +21,19 @@
libexecinfo, libexecinfo,
libinput, libinput,
libuuid, libuuid,
libxcb,
libxkbcommon, libxkbcommon,
mesa, mesa,
pango, pango,
pciutils, pciutils,
python3,
systemd, systemd,
tomlplusplus, tomlplusplus,
udis86, udis86,
wayland, wayland,
wayland-protocols, wayland-protocols,
wayland-scanner, wayland-scanner,
wlroots-hyprland, wlroots,
xcbutilwm, xorg,
xwayland, xwayland,
debug ? false, debug ? false,
enableXWayland ? true, enableXWayland ? true,
@ -48,9 +50,7 @@
}: }:
assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed."; assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
assert lib.assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` 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 assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland";
wlr = wlroots-hyprland.override {inherit enableXWayland;};
in
stdenv.mkDerivation { stdenv.mkDerivation {
pname = "hyprland${lib.optionalString debug "-debug"}"; pname = "hyprland${lib.optionalString debug "-debug"}";
inherit version; inherit version;
@ -63,11 +63,6 @@ in
src = lib.cleanSource ../.; src = lib.cleanSource ../.;
}; };
patches = [
# make meson use the provided wlroots instead of the git submodule
./patches/meson-build.patch
];
postPatch = '' postPatch = ''
# Fix hardcoded paths to /usr installation # Fix hardcoded paths to /usr installation
sed -i "s#/usr#$out#" src/render/OpenGL.cpp sed -i "s#/usr#$out#" src/render/OpenGL.cpp
@ -91,9 +86,11 @@ in
hyprwayland-scanner hyprwayland-scanner
jq jq
makeWrapper makeWrapper
cmake
meson meson
ninja ninja
pkg-config pkg-config
python3
wayland-scanner wayland-scanner
]; ];
@ -103,10 +100,12 @@ in
"dev" "dev"
]; ];
buildInputs = buildInputs = lib.concatLists [
wlr.buildInputs wlroots.buildInputs
++ [ udis86.buildInputs
[
cairo cairo
expat
git git
hyprcursor.dev hyprcursor.dev
hyprland-protocols hyprland-protocols
@ -120,31 +119,32 @@ in
pango pango
pciutils pciutils
tomlplusplus tomlplusplus
udis86
wayland wayland
wayland-protocols wayland-protocols
wlr
] ]
++ lib.optionals stdenv.hostPlatform.isMusl [libexecinfo] (lib.optionals stdenv.hostPlatform.isMusl [libexecinfo])
++ lib.optionals enableXWayland [libxcb xcbutilwm xwayland] (lib.optionals enableXWayland [
++ lib.optionals withSystemd [systemd]; xorg.libxcb
xorg.libXdmcp
xorg.xcbutil
xorg.xcbutilwm
xwayland
])
(lib.optionals withSystemd [systemd])
];
mesonBuildType = cmakeBuildType =
if debug if debug
then "debug" then "Debug"
else "release"; else "RelWithDebInfo";
mesonAutoFeatures = "disabled"; cmakeFlags = [
(lib.cmakeBool "NO_XWAYLAND" (!enableXWayland))
mesonFlags = [ (lib.cmakeBool "LEGACY_RENDERER" legacyRenderer)
(lib.mesonEnable "xwayland" enableXWayland) (lib.cmakeBool "NO_SYSTEMD" (!withSystemd))
(lib.mesonEnable "legacy_renderer" legacyRenderer)
(lib.mesonEnable "systemd" withSystemd)
]; ];
postInstall = '' postInstall = ''
ln -s ${wlr}/include/wlr $dev/include/hyprland/wlroots
${lib.optionalString wrapRuntimeDeps '' ${lib.optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \ wrapProgram $out/bin/Hyprland \
--suffix PATH : ${lib.makeBinPath [ --suffix PATH : ${lib.makeBinPath [
@ -161,7 +161,7 @@ in
homepage = "https://github.com/hyprwm/Hyprland"; homepage = "https://github.com/hyprwm/Hyprland";
description = "A dynamic tiling Wayland compositor that doesn't sacrifice on its looks"; description = "A dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = licenses.bsd3; license = licenses.bsd3;
platforms = wlr.meta.platforms; platforms = wlroots.meta.platforms;
mainProgram = "Hyprland"; mainProgram = "Hyprland";
}; };
} }

View File

@ -22,12 +22,11 @@ in {
hyprland-packages = lib.composeManyExtensions [ hyprland-packages = lib.composeManyExtensions [
# Dependencies # Dependencies
inputs.hyprcursor.overlays.default inputs.hyprcursor.overlays.default
inputs.hyprland-protocols.overlays.default
inputs.hyprlang.overlays.default inputs.hyprlang.overlays.default
inputs.hyprwayland-scanner.overlays.default inputs.hyprwayland-scanner.overlays.default
self.overlays.wlroots-hyprland
self.overlays.udis86
self.overlays.wayland-protocols self.overlays.wayland-protocols
self.overlays.xwayland
# Hyprland packages themselves # Hyprland packages themselves
(final: prev: let (final: prev: let
date = mkDate (self.lastModifiedDate or "19700101"); date = mkDate (self.lastModifiedDate or "19700101");
@ -36,19 +35,20 @@ in {
stdenv = final.gcc13Stdenv; stdenv = final.gcc13Stdenv;
version = "${props.version}+date=${date}_${self.shortRev or "dirty"}"; version = "${props.version}+date=${date}_${self.shortRev or "dirty"}";
commit = self.rev or ""; 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; inherit date;
}; };
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;}; hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
hyprland-debug = final.hyprland.override {debug = true;}; hyprland-debug = final.hyprland.override {debug = true;};
hyprland-legacy-renderer = final.hyprland.override {legacyRenderer = true;}; hyprland-legacy-renderer = final.hyprland.override {legacyRenderer = true;};
# deprecated packages
hyprland-nvidia = hyprland-nvidia =
builtins.trace '' builtins.trace ''
hyprland-nvidia was removed. Please use the hyprland package. hyprland-nvidia was removed. Please use the hyprland package.
Nvidia patches are no longer needed. Nvidia patches are no longer needed.
'' ''
final.hyprland; final.hyprland;
hyprland-hidpi = hyprland-hidpi =
builtins.trace '' builtins.trace ''
hyprland-hidpi was removed. Please use the hyprland package. hyprland-hidpi was removed. Please use the hyprland package.
@ -64,18 +64,14 @@ in {
inputs.xdph.overlays.xdg-desktop-portal-hyprland inputs.xdph.overlays.xdg-desktop-portal-hyprland
]; ];
udis86 = final: prev: { # Patches XWayland's pkgconfig file to not include Cflags or includedir
udis86-hyprland = final.callPackage ./udis86.nix {}; # The above two variables trip up CMake and the build fails
}; xwayland = final: prev: {
xwayland = prev.xwayland.overrideAttrs (old: {
# Patched version of wlroots for Hyprland. postInstall = ''
# It is under a new package name so as to not conflict with sed -i '/includedir/d' $out/lib/pkgconfig/xwayland.pc
# 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;
};
}; };
wayland-protocols = final: prev: { wayland-protocols = final: prev: {

View File

@ -1,61 +0,0 @@
diff --git a/meson.build b/meson.build
index 40883073..d8f2e536 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
@@ -65,8 +52,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 15c69552..327aa4fb 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,10 +17,10 @@ executable('Hyprland', src,
dependency('egl'),
dependency('xkbcommon'),
dependency('libinput'),
- xcb_dep,
+ dependency('xcb', required: get_option('xwayland')),
backtrace_dep,
epoll_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,16 +0,0 @@
{
version,
src,
git,
wlroots,
enableXWayland ? true,
}:
wlroots.overrideAttrs (old: {
inherit version src enableXWayland;
pname = "${old.pname}-hyprland";
patches = [ ]; # don't inherit old.patches
nativeBuildInputs = old.nativeBuildInputs ++ [ git ];
})