From 5184b542b1f505c90f9ef4715ae949ac45b2b7ef Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sat, 4 Mar 2023 17:34:15 +0200 Subject: [PATCH] nix: show commit in hyprctl --- flake.nix | 1 + nix/default.nix | 4 ++++ nix/meson-build.patch | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/flake.nix b/flake.nix index f2a08dc0..24983119 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; diff --git a/nix/default.nix b/nix/default.nix index 78e103d4..6fb4db98 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -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"]; diff --git a/nix/meson-build.patch b/nix/meson-build.patch index 075cb6be..0b9e0d93 100644 --- a/nix/meson-build.patch +++ b/nix/meson-build.patch @@ -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')