From f2c153c09b1a881a46f13eb22e6b17f32f7a2fde Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sat, 21 Dec 2024 23:20:38 +0200 Subject: [PATCH] nix: pass commit info to cmake --- flake.nix | 2 +- nix/default.nix | 6 ++++++ nix/overlays.nix | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 17e7b8d..7a75f43 100644 --- a/flake.nix +++ b/flake.nix @@ -40,7 +40,7 @@ overlays = with self.overlays; [default]; }); in { - overlays = import ./nix/overlays.nix {inherit inputs lib;}; + overlays = import ./nix/overlays.nix {inherit inputs lib self;}; packages = eachSystem (system: { default = self.packages.${system}.hyprlock; diff --git a/nix/default.nix b/nix/default.nix index 9b31c58..08b9f99 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -22,6 +22,7 @@ wayland-protocols, wayland-scanner, version ? "git", + shortRev ? "", }: stdenv.mkDerivation { pname = "hyprlock"; @@ -55,6 +56,11 @@ stdenv.mkDerivation { wayland-protocols ]; + cmakeFlags = lib.mapAttrsToList lib.cmakeFeature { + HYPRLOCK_COMMIT = shortRev; + HYPRLOCK_VERSION_COMMIT = shortRev; + }; + meta = { homepage = "https://github.com/hyprwm/hyprlock"; description = "A gpu-accelerated screen lock for Hyprland"; diff --git a/nix/overlays.nix b/nix/overlays.nix index 1535e61..512866f 100644 --- a/nix/overlays.nix +++ b/nix/overlays.nix @@ -1,6 +1,7 @@ { lib, inputs, + self, }: let mkDate = longDate: (lib.concatStringsSep "-" [ (builtins.substring 0 4 longDate) @@ -22,6 +23,7 @@ in { stdenv = prev.gcc14Stdenv; version = version + "+date=" + (mkDate (inputs.self.lastModifiedDate or "19700101")) + "_" + (inputs.self.shortRev or "dirty"); inherit (final) hyprlang; + shortRev = self.sourceInfo.shortRev or "dirty"; }; }) ];