diff --git a/CMakeLists.txt b/CMakeLists.txt index ad112dd..67f8a1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20) -project(quickshell VERSION "0.0.1") +project(quickshell VERSION "0.1.0") set(QT_MIN_VERSION "6.6.0") set(CMAKE_CXX_STANDARD 20) @@ -21,6 +21,14 @@ if (WAYLAND) message(STATUS " Session Lock: ${WAYLAND_SESSION_LOCK}") endif () +if (NOT DEFINED GIT_REVISION) + execute_process( + COMMAND git rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_REVISION + ) +endif() + add_compile_options(-Wall -Wextra) # nix workaround diff --git a/default.nix b/default.nix index 7534222..4fa9326 100644 --- a/default.nix +++ b/default.nix @@ -11,6 +11,16 @@ wayland, wayland-protocols, + gitRev ? (let + headExists = builtins.pathExists ./.git/HEAD; + headContent = builtins.readFile ./.git/HEAD; + in if headExists + then (let + matches = builtins.match "ref: refs/heads/(.*)\n" headContent; + in if matches != null + then builtins.readFile ./.git/refs/heads/${builtins.elemAt matches 0} + else headContent) + else "unknown"), debug ? false, enableWayland ? true, }: stdenv.mkDerivation { @@ -44,7 +54,9 @@ cmakeConfigurePhase ''; - cmakeFlags = lib.optional (!enableWayland) "-DWAYLAND=OFF"; + cmakeFlags = [ + "-DGIT_REVISION=${gitRev}" + ] ++ lib.optional (!enableWayland) "-DWAYLAND=OFF"; buildPhase = "ninjaBuildPhase"; enableParallelBuilding = true; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e0a8133..c1fdee8 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -17,6 +17,7 @@ qt_add_executable(quickshell panelinterface.cpp ) +set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS GIT_REVISION="${GIT_REVISION}") qt_add_qml_module(quickshell URI Quickshell VERSION 0.1) target_link_libraries(quickshell PRIVATE ${QT_DEPS}) diff --git a/src/core/main.cpp b/src/core/main.cpp index a7d8071..7dd7af3 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -20,7 +20,7 @@ int main(int argc, char** argv) { const auto app = QGuiApplication(argc, argv); QGuiApplication::setApplicationName("quickshell"); - QGuiApplication::setApplicationVersion("0.1.0"); + QGuiApplication::setApplicationVersion("0.1.0 (" GIT_REVISION ")"); QCommandLineParser parser; parser.addHelpOption();