nix: show commit in hyprctl

This commit is contained in:
Mihai Fufezan 2023-03-04 17:34:15 +02:00
parent fea2031bfe
commit 5184b542b1
No known key found for this signature in database
GPG key ID: 5899325F2F120900
3 changed files with 17 additions and 0 deletions

View file

@ -79,6 +79,7 @@
stdenv = prev.gcc12Stdenv;
version = props.version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
wlroots = wlroots-hyprland;
commit = self.rev or "";
inherit (inputs.hyprland-protocols.packages.${prev.stdenv.hostPlatform.system}) hyprland-protocols;
inherit udis86;
};

View file

@ -32,6 +32,7 @@
nvidiaPatches ? false,
withSystemd ? true,
version ? "git",
commit,
}: let
assertXWayland = lib.assertMsg (hidpiXWayland -> enableXWayland) ''
Hyprland: cannot have hidpiXWayland when enableXWayland is false.
@ -102,6 +103,9 @@ in
postPatch = ''
# Fix hardcoded paths to /usr installation
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
substituteInPlace meson.build \
--replace "@GIT_COMMIT_HASH@" '${commit}' \
--replace "@GIT_DIRTY@" '${if commit == "" then "dirty" else ""}'
'';
passthru.providedSessions = ["hyprland"];

View file

@ -2,6 +2,18 @@ diff --git a/meson.build b/meson.build
index f380255..abd7cd3 100644
--- a/meson.build
+++ b/meson.build
@@ -21,9 +21,9 @@ else
endif
GIT_BRANCH = run_command('git', 'rev-parse', '--abbrev-ref', 'HEAD', check: false).stdout().strip()
-GIT_COMMIT_HASH = run_command('git', 'rev-parse', 'HEAD', check: false).stdout().strip()
+GIT_COMMIT_HASH = '@GIT_COMMIT_HASH@'
GIT_COMMIT_MESSAGE = run_command('sh', '-c', 'git show | head -n 5 | tail -n 1', check: false).stdout().strip()
-GIT_DIRTY = run_command('sh', '-c', 'git diff-index --quiet HEAD -- || echo "dirty"', check: false).stdout().strip()
+GIT_DIRTY = '@GIT_DIRTY@'
add_project_arguments(
[
@@ -39,23 +39,8 @@ add_project_arguments(
],
language: 'cpp')