From d1b07b4644c57351d1688c7d2b85414bbafcf99e Mon Sep 17 00:00:00 2001 From: Sigmanificient Date: Mon, 10 Mar 2025 00:37:49 +0100 Subject: [PATCH] xbattbar: refactor --- pkgs/by-name/xb/xbattbar/package.nix | 37 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/pkgs/by-name/xb/xbattbar/package.nix b/pkgs/by-name/xb/xbattbar/package.nix index f9e2fc3a1362..5d4b7b618eff 100644 --- a/pkgs/by-name/xb/xbattbar/package.nix +++ b/pkgs/by-name/xb/xbattbar/package.nix @@ -4,10 +4,9 @@ fetchgit, libX11, perl, - ... }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "xbattbar"; version = "1.4.9"; @@ -15,22 +14,20 @@ stdenv.mkDerivation rec { # repository. src = fetchgit { url = "https://salsa.debian.org/debian/xbattbar.git"; - rev = "upstream/${version}"; - sha256 = "10w7gs0l4hzhdn38yqyr3az7n4ncmfnd6hhhly6lk5dg7k441ck6"; + tag = "upstream/${finalAttrs.version}"; + hash = "sha256-ZrJAyDyvlUmNpxBC06yrzBJ7vhrZY4+GbfBDQoF+h4M="; }; buildInputs = [ libX11 ]; - # The following patches are applied: - # - sys-by-default: remove the APM checker binary, make the sys checker - # script the default. Rationale: checking battery status by /proc/apm is - # extremely oldschool and does not work on NixOS, while the sysfs script - # does. + # remove the APM checker binary, make the sys checker + # script the default. Rationale: checking battery status by /proc/apm is + # extremely oldschool and does not work on NixOS, while the sysfs script + # does. + patches = [ ./sys-by-default.patch ]; # - perl shebang patches for acpi/sys scripts # - unhardcode path to checker scripts # - add missing return type in main function - patches = [ ./sys-by-default.patch ]; - postPatch = '' substituteInPlace xbattbar.c \ --replace-fail "main(int argc" "int main(int argc" @@ -41,19 +38,23 @@ stdenv.mkDerivation rec { ''; installPhase = '' - mkdir -p $out/bin - mkdir -p $out/libexec + runHook preInstall + + mkdir -p $out/{bin,libexec} + install -m 0755 xbattbar $out/bin/ install -m 0755 xbattbar-check-acpi $out/libexec/ install -m 0755 xbattbar-check-sys $out/libexec/ + + runHook postInstall ''; - meta = with lib; { + meta = { description = "Display battery status in X11"; homepage = "https://salsa.debian.org/debian/xbattbar"; - license = licenses.gpl2Plus; - platforms = platforms.linux; - maintainers = [ maintainers.q3k ]; + license = with lib; licenses.gpl2Plus; + platforms = lib.platforms.linux; + maintainers = with lib.maintainers; [ q3k ]; mainProgram = "xbattbar"; }; -} +})