Files
nixpkgs/pkgs/by-name/op/openhue-cli/package.nix
2025-08-09 19:16:52 +00:00

62 lines
1.4 KiB
Nix

{
lib,
buildGoModule,
fetchFromGitHub,
versionCheckHook,
writableTmpDirAsHomeHook,
}:
buildGoModule (finalAttrs: {
pname = "openhue-cli";
version = "0.20";
src = fetchFromGitHub {
owner = "openhue";
repo = "openhue-cli";
tag = finalAttrs.version;
hash = "sha256-vUmJjuBcOjIhhtWrzq+y0fDlh+wQhgBwxnfuod27CBA=";
leaveDotGit = true;
postFetch = ''
cd "$out"
git rev-parse HEAD > $out/COMMIT
find "$out" -name .git -print0 | xargs -0 rm -rf
'';
};
vendorHash = "sha256-DhTe0fSWoAwzoGr8rZMsbSE92jJFr4T7aVx/ULMfVFo=";
env.CGO_ENABLED = 0;
ldflags = [
"-s"
"-w"
"-X main.version=${finalAttrs.version}"
];
preBuild = ''
ldflags+=" -X main.commit=$(cat COMMIT)"
'';
postInstall = ''
mv $out/bin/openhue-cli $out/bin/openhue
'';
doInstallCheck = true;
nativeInstallCheckInputs = [
versionCheckHook
writableTmpDirAsHomeHook
];
versionCheckProgram = "${placeholder "out"}/bin/openhue";
versionCheckProgramArg = "version";
versionCheckKeepEnvironment = [ "HOME" ];
meta = {
changelog = "https://github.com/openhue/openhue-cli/releases/tag/${finalAttrs.version}";
description = "CLI for interacting with Philips Hue smart lighting systems";
homepage = "https://github.com/openhue/openhue-cli";
mainProgram = "openhue";
maintainers = with lib.maintainers; [ madeddie ];
license = lib.licenses.asl20;
};
})