powertop-macos: init at 1.3.3

Add the macOS PowerTop menu bar application under a macOS-qualified name to avoid colliding with the existing Linux powertop package.

Upstream is source-available and ships build.sh, but the source build currently requires newer Apple Swift Observation macro support than nixpkgs' Swift 5.10 provides. Package the upstream release zip instead and mark the package as binaryNativeCode.

Assisted-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
Mix
2026-06-30 17:29:24 +08:00
parent 2c51b55beb
commit e8a3e73cf4
@@ -0,0 +1,61 @@
{
fetchurl,
lib,
makeWrapper,
nix-update-script,
rcodesign,
stdenvNoCC,
unzip,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "powertop-macos";
version = "1.3.3";
strictDeps = true;
__structuredAttrs = true;
src = fetchurl {
url = "https://github.com/kDolphin/PowerTop/releases/download/v${finalAttrs.version}/PowerTop.zip";
hash = "sha256-GIuhJVyKjFsltlg9zZByHryaIYV6F+5Uj1yTucOL9Gw=";
};
nativeBuildInputs = [
makeWrapper
rcodesign
unzip
];
dontConfigure = true;
dontBuild = true;
sourceRoot = ".";
installPhase = ''
runHook preInstall
app="$out/Applications/PowerTop.app"
mkdir -p "$out/Applications"
cp -R PowerTop.app "$app"
makeWrapper "$app/Contents/MacOS/PowerTop" "$out/bin/powertop-macos"
runHook postInstall
'';
postFixup = ''
${lib.getExe rcodesign} sign "$out/Applications/PowerTop.app"
'';
passthru.updateScript = nix-update-script { extraArgs = [ "--use-github-releases" ]; };
meta = {
changelog = "https://github.com/kDolphin/PowerTop/releases/tag/v${finalAttrs.version}";
description = "Menu bar app for monitoring MacBook power usage";
homepage = "https://github.com/kDolphin/PowerTop";
license = lib.licenses.mit;
maintainers = [ ];
mainProgram = "powertop-macos";
platforms = [ "aarch64-darwin" ];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
};
})