nix: change build system to meson

flake.nix: change wlroots url to mirror, update version
flake.lock: update wlroots & nixpkgs
nix/update-inputs.sh: update wlroots url
This commit is contained in:
Mihai Fufezan 2022-06-16 13:42:31 +03:00
parent f58bb0187b
commit 8bd7234d72
No known key found for this signature in database
GPG key ID: 5899325F2F120900
5 changed files with 55 additions and 40 deletions

View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1654593855, "lastModified": 1655221618,
"narHash": "sha256-c+SyXvj7THre87OyIdZfRVR+HhI/g1ZDrQ3VUtTuHkU=", "narHash": "sha256-ht8HRFthDKzYt+il+sGgkBwrv+Ex2l8jdGVpsrPfFME=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "033bd4fa9a8fbe0c68a88e925d9a884161044b25", "rev": "6616de389ed55fba6eeba60377fc04732d5a207c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -25,19 +25,17 @@
"wlroots": { "wlroots": {
"flake": false, "flake": false,
"locked": { "locked": {
"host": "gitlab.freedesktop.org",
"lastModified": 1654618691, "lastModified": 1654618691,
"narHash": "sha256-8y3u8CoigjoZOVbA2wCWBHlDNEakv0AVxU46/cOC00s=", "narHash": "sha256-8y3u8CoigjoZOVbA2wCWBHlDNEakv0AVxU46/cOC00s=",
"owner": "wlroots", "owner": "ThatOneCalculator",
"repo": "wlroots", "repo": "wlroots-mirror",
"rev": "b89ed9015c3fbe8d339e9d65cf70fdca6e5645bc", "rev": "b89ed9015c3fbe8d339e9d65cf70fdca6e5645bc",
"type": "gitlab" "type": "github"
}, },
"original": { "original": {
"host": "gitlab.freedesktop.org", "owner": "ThatOneCalculator",
"owner": "wlroots", "repo": "wlroots-mirror",
"repo": "wlroots", "type": "github"
"type": "gitlab"
} }
} }
}, },

View file

@ -4,7 +4,7 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
wlroots = { wlroots = {
url = "gitlab:wlroots/wlroots?host=gitlab.freedesktop.org"; url = "github:ThatOneCalculator/wlroots-mirror";
flake = false; flake = false;
}; };
}; };

View file

@ -3,7 +3,7 @@
stdenv, stdenv,
fetchFromGitHub, fetchFromGitHub,
pkg-config, pkg-config,
cmake, meson,
ninja, ninja,
libdrm, libdrm,
libinput, libinput,
@ -27,7 +27,7 @@ stdenv.mkDerivation {
src = ../.; src = ../.;
nativeBuildInputs = [ nativeBuildInputs = [
cmake meson
ninja ninja
pkg-config pkg-config
]; ];
@ -48,33 +48,14 @@ stdenv.mkDerivation {
] ]
++ lib.optional enableXWayland xwayland; ++ lib.optional enableXWayland xwayland;
cmakeFlags = mesonBuildType = "release";
["-DCMAKE_BUILD_TYPE=Release"]
++ lib.optional (!enableXWayland) "-DNO_XWAYLAND=true";
# enables building with nix-supplied wlroots instead of submodule mesonFlags = lib.optional (!enableXWayland) "-DNO_XWAYLAND=true";
prePatch = ''
sed -Ei 's/"\.\.\/wlroots\/include\/([a-zA-Z0-9./_-]+)"/<\1>/g' src/includes.hpp
'';
postPatch = ''
make protocols
'';
postBuild = '' patches = [
pushd ../hyprctl # make meson use the provided wlroots instead of the git submodule
make all ./meson-build.patch
popd ];
'';
installPhase = ''
pushd ..
install -Dm644 ./example/hyprland.desktop -t $out/share/wayland-sessions
install -Dm755 ./build/Hyprland -t $out/bin
install -Dm755 ./hyprctl/hyprctl -t $out/bin
install -Dm644 ./assets/* -t $out/share/hyprland
install -Dm644 ./example/hyprland.conf -t $out/share/hyprland
popd
'';
passthru.providedSessions = ["hyprland"]; passthru.providedSessions = ["hyprland"];

36
nix/meson-build.patch Normal file
View file

@ -0,0 +1,36 @@
diff --git a/meson.build b/meson.build
index 22ee4bf..5528613 100644
--- a/meson.build
+++ b/meson.build
@@ -2,16 +2,10 @@ project('Hyprland', 'cpp', 'c',
version : '0.1',
default_options : ['warning_level=3', 'cpp_std=c++20', 'default_library=static'])
-wlroots = subproject('wlroots', default_options: ['examples=false'])
-have_xwlr = wlroots.get_variable('features').get('xwayland')
+wlroots = dependency('wlroots', version: '>=0.16.0')
xcb_dep = dependency('xcb', required: get_option('xwayland'))
-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 not xcb_dep.found()
add_project_arguments('-DNO_XWAYLAND', language: 'cpp')
endif
diff --git a/src/meson.build b/src/meson.build
index 5d64188..a676333 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -7,7 +7,7 @@ executable('Hyprland', src,
server_protos,
dependency('wayland-server'),
dependency('wayland-client'),
- wlroots.get_variable('wlroots'),
+ wlroots,
dependency('cairo'),
dependency('pango'),
dependency('pangocairo'),

View file

@ -10,7 +10,7 @@ if [ $SUB_REV != $CRT_REV ]; then
nix flake lock --update-input nixpkgs nix flake lock --update-input nixpkgs
# update wlroots to submodule revision # update wlroots to submodule revision
nix flake lock --override-input wlroots "gitlab:wlroots/wlroots/$SUB_REV?host=gitlab.freedesktop.org" nix flake lock --override-input wlroots "github:ThatOneCalculator/wlroots-mirror/$SUB_REV"
# remove "dirty" mark from lockfile # remove "dirty" mark from lockfile
jq < flake.lock 'del(.nodes.wlroots.original.rev)' | sponge flake.lock jq < flake.lock 'del(.nodes.wlroots.original.rev)' | sponge flake.lock