diff options
author | Mihai Fufezan <[email protected]> | 2024-04-21 19:58:54 +0300 |
---|---|---|
committer | Mihai Fufezan <[email protected]> | 2024-05-05 16:30:39 +0300 |
commit | f15513309b24790099d42974274eb23f66f7c985 (patch) | |
tree | 07c48555fa44434c9f2a1ed3e8f1ad64111bcf42 /nix | |
parent | 99aa34db6e3529717961cf31ad08ab000d66cd77 (diff) | |
download | Hyprland-f15513309b24790099d42974274eb23f66f7c985.tar.gz Hyprland-f15513309b24790099d42974274eb23f66f7c985.zip |
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`
Diffstat (limited to 'nix')
-rw-r--r-- | nix/default.nix | 62 | ||||
-rw-r--r-- | nix/overlays.nix | 30 | ||||
-rw-r--r-- | nix/patches/meson-build.patch | 61 | ||||
-rw-r--r-- | nix/udis86.nix | 32 | ||||
-rw-r--r-- | nix/wlroots.nix | 16 |
5 files changed, 44 insertions, 157 deletions
diff --git a/nix/default.nix b/nix/default.nix index 216e69a5..e9d81fd7 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -4,10 +4,12 @@ pkg-config, pkgconf, makeWrapper, + cmake, meson, ninja, binutils, cairo, + expat, git, hyprcursor, hyprland-protocols, @@ -19,19 +21,19 @@ libexecinfo, libinput, libuuid, - libxcb, libxkbcommon, mesa, pango, pciutils, + python3, systemd, tomlplusplus, udis86, wayland, wayland-protocols, wayland-scanner, - wlroots-hyprland, - xcbutilwm, + wlroots, + xorg, xwayland, debug ? false, enableXWayland ? true, @@ -48,9 +50,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; @@ -63,11 +63,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 @@ -91,9 +86,11 @@ in hyprwayland-scanner jq makeWrapper + cmake meson ninja pkg-config + python3 wayland-scanner ]; @@ -103,10 +100,12 @@ in "dev" ]; - buildInputs = - wlr.buildInputs - ++ [ + buildInputs = lib.concatLists [ + wlroots.buildInputs + udis86.buildInputs + [ cairo + expat git hyprcursor.dev hyprland-protocols @@ -120,31 +119,32 @@ 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 [ + xorg.libxcb + xorg.libXdmcp + xorg.xcbutil + xorg.xcbutilwm + xwayland + ]) + (lib.optionals withSystemd [systemd]) + ]; - mesonBuildType = + cmakeBuildType = if debug - then "debug" - else "release"; + then "Debug" + else "RelWithDebInfo"; - mesonAutoFeatures = "disabled"; - - mesonFlags = [ - (lib.mesonEnable "xwayland" enableXWayland) - (lib.mesonEnable "legacy_renderer" legacyRenderer) - (lib.mesonEnable "systemd" withSystemd) + cmakeFlags = [ + (lib.cmakeBool "NO_XWAYLAND" (!enableXWayland)) + (lib.cmakeBool "LEGACY_RENDERER" legacyRenderer) + (lib.cmakeBool "NO_SYSTEMD" (!withSystemd)) ]; postInstall = '' - ln -s ${wlr}/include/wlr $dev/include/hyprland/wlroots - ${lib.optionalString wrapRuntimeDeps '' wrapProgram $out/bin/Hyprland \ --suffix PATH : ${lib.makeBinPath [ @@ -161,7 +161,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"; }; } diff --git a/nix/overlays.nix b/nix/overlays.nix index 3a7dca52..50d9f9d9 100644 --- a/nix/overlays.nix +++ b/nix/overlays.nix @@ -22,12 +22,11 @@ in { hyprland-packages = lib.composeManyExtensions [ # Dependencies inputs.hyprcursor.overlays.default - inputs.hyprland-protocols.overlays.default inputs.hyprlang.overlays.default inputs.hyprwayland-scanner.overlays.default - self.overlays.wlroots-hyprland - self.overlays.udis86 self.overlays.wayland-protocols + self.overlays.xwayland + # Hyprland packages themselves (final: prev: let date = mkDate (self.lastModifiedDate or "19700101"); @@ -36,19 +35,20 @@ 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;}; hyprland-debug = final.hyprland.override {debug = true;}; hyprland-legacy-renderer = final.hyprland.override {legacyRenderer = true;}; + + # deprecated packages hyprland-nvidia = builtins.trace '' hyprland-nvidia was removed. Please use the hyprland package. Nvidia patches are no longer needed. '' final.hyprland; + hyprland-hidpi = builtins.trace '' hyprland-hidpi was removed. Please use the hyprland package. @@ -64,18 +64,14 @@ in { 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; - }; + # Patches XWayland's pkgconfig file to not include Cflags or includedir + # The above two variables trip up CMake and the build fails + xwayland = final: prev: { + xwayland = prev.xwayland.overrideAttrs (old: { + postInstall = '' + sed -i '/includedir/d' $out/lib/pkgconfig/xwayland.pc + ''; + }); }; wayland-protocols = final: prev: { diff --git a/nix/patches/meson-build.patch b/nix/patches/meson-build.patch deleted file mode 100644 index eb1d3f9a..00000000 --- a/nix/patches/meson-build.patch +++ /dev/null @@ -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'), diff --git a/nix/udis86.nix b/nix/udis86.nix deleted file mode 100644 index d5e92afc..00000000 --- a/nix/udis86.nix +++ /dev/null @@ -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; - }; -} diff --git a/nix/wlroots.nix b/nix/wlroots.nix deleted file mode 100644 index b0dccb00..00000000 --- a/nix/wlroots.nix +++ /dev/null @@ -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 ]; -}) |