diff options
author | Vaxry <[email protected]> | 2022-06-22 16:20:02 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2022-06-22 16:20:02 +0100 |
commit | bd41776a5aa86cc6294e3ec17ea9b46c9c5780df (patch) | |
tree | 50f65f7f4134d2705712d76138cbb9f9053965b9 | |
parent | c2ff3d9e76301230b32ffc5f8f30bc5d6aa73625 (diff) | |
parent | 593f24a2ecf86a2a4db3545a21ff4c75ee526f45 (diff) | |
download | Hyprland-bd41776a5aa86cc6294e3ec17ea9b46c9c5780df.tar.gz Hyprland-bd41776a5aa86cc6294e3ec17ea9b46c9c5780df.zip |
Merge pull request #227 from fufexan/meson
Nix: use meson for builds
-rw-r--r-- | .github/workflows/version-update.sh | 26 | ||||
-rw-r--r-- | flake.lock | 20 | ||||
-rw-r--r-- | flake.nix | 4 | ||||
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | nix/default.nix | 35 | ||||
-rw-r--r-- | nix/meson-build.patch | 36 | ||||
-rwxr-xr-x | nix/update-inputs.sh | 2 |
7 files changed, 83 insertions, 42 deletions
diff --git a/.github/workflows/version-update.sh b/.github/workflows/version-update.sh new file mode 100644 index 00000000..1bf95af9 --- /dev/null +++ b/.github/workflows/version-update.sh @@ -0,0 +1,26 @@ +name: "Nix & Meson: update version" + +on: [push, workflow_dispatch] + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v3 + - name: Update flake and meson version + run: | + REGEX="([0-9]+(\.[0-9a-zA-Z]+)+)" + + CRT_REV=$(git show-ref --tags --head --abbrev | head -n 1 | head -c 7) + TAG_REV=$(git show-ref --tags --abbrev | tail -n 1 | head -c 7) + CRT_VER=$(sed -nEe "/$REGEX/{p;q;}" meson.build | awk -F\' '{print $2}') + VERSION=$(git show-ref --tags --abbrev | tail -n 1 | tail -c +20) + + if [[ $TAG_REV = $CRT_REV ]] || [[ $CRT_VER != $VERSION ]]; then + sed -Ei "s/$REGEX/$VERSION/g" meson.build + sed -Ei "s/$REGEX/$VERSION/g" flake.nix + fi + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "[gha] bump flake and meson version" @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1654593855, - "narHash": "sha256-c+SyXvj7THre87OyIdZfRVR+HhI/g1ZDrQ3VUtTuHkU=", + "lastModified": 1655221618, + "narHash": "sha256-ht8HRFthDKzYt+il+sGgkBwrv+Ex2l8jdGVpsrPfFME=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "033bd4fa9a8fbe0c68a88e925d9a884161044b25", + "rev": "6616de389ed55fba6eeba60377fc04732d5a207c", "type": "github" }, "original": { @@ -25,19 +25,17 @@ "wlroots": { "flake": false, "locked": { - "host": "gitlab.freedesktop.org", "lastModified": 1654618691, "narHash": "sha256-8y3u8CoigjoZOVbA2wCWBHlDNEakv0AVxU46/cOC00s=", - "owner": "wlroots", - "repo": "wlroots", + "owner": "ThatOneCalculator", + "repo": "wlroots-mirror", "rev": "b89ed9015c3fbe8d339e9d65cf70fdca6e5645bc", - "type": "gitlab" + "type": "github" }, "original": { - "host": "gitlab.freedesktop.org", - "owner": "wlroots", - "repo": "wlroots", - "type": "gitlab" + "owner": "ThatOneCalculator", + "repo": "wlroots-mirror", + "type": "github" } } }, @@ -4,7 +4,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; wlroots = { - url = "gitlab:wlroots/wlroots?host=gitlab.freedesktop.org"; + url = "github:ThatOneCalculator/wlroots-mirror"; flake = false; }; }; @@ -32,7 +32,7 @@ src = inputs.wlroots; }); hyprland = prev.callPackage ./nix/default.nix { - version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")); + version = "0.5.0beta" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")); wlroots = wlroots-hyprland; }; }; diff --git a/meson.build b/meson.build index b902c80a..f75f64fd 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('Hyprland', 'cpp', 'c', - version : '0.1', + version : '0.5.0beta', default_options : ['warning_level=3', 'cpp_std=c++20', 'default_library=static']) wlroots = subproject('wlroots', default_options: ['examples=false']) diff --git a/nix/default.nix b/nix/default.nix index 20586b9f..18570f12 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -3,7 +3,7 @@ stdenv, fetchFromGitHub, pkg-config, - cmake, + meson, ninja, libdrm, libinput, @@ -27,7 +27,7 @@ stdenv.mkDerivation { src = ../.; nativeBuildInputs = [ - cmake + meson ninja pkg-config ]; @@ -48,33 +48,14 @@ stdenv.mkDerivation { ] ++ lib.optional enableXWayland xwayland; - cmakeFlags = - ["-DCMAKE_BUILD_TYPE=Release"] - ++ lib.optional (!enableXWayland) "-DNO_XWAYLAND=true"; + mesonBuildType = "release"; - # enables building with nix-supplied wlroots instead of submodule - prePatch = '' - sed -Ei 's/"\.\.\/wlroots\/include\/([a-zA-Z0-9./_-]+)"/<\1>/g' src/includes.hpp - ''; - postPatch = '' - make protocols - ''; + mesonFlags = lib.optional (!enableXWayland) "-DNO_XWAYLAND=true"; - postBuild = '' - pushd ../hyprctl - make all - 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 - ''; + patches = [ + # make meson use the provided wlroots instead of the git submodule + ./meson-build.patch + ]; passthru.providedSessions = ["hyprland"]; diff --git a/nix/meson-build.patch b/nix/meson-build.patch new file mode 100644 index 00000000..57950de9 --- /dev/null +++ b/nix/meson-build.patch @@ -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'), diff --git a/nix/update-inputs.sh b/nix/update-inputs.sh index 8c238222..856dd43a 100755 --- a/nix/update-inputs.sh +++ b/nix/update-inputs.sh @@ -10,7 +10,7 @@ if [ $SUB_REV != $CRT_REV ]; then nix flake lock --update-input nixpkgs # 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 jq < flake.lock 'del(.nodes.wlroots.original.rev)' | sponge flake.lock |