nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 versionCheckHook,
6 writableTmpDirAsHomeHook,
7}:
8
9buildGoModule (finalAttrs: {
10 pname = "openhue-cli";
11 version = "0.23";
12
13 src = fetchFromGitHub {
14 owner = "openhue";
15 repo = "openhue-cli";
16 tag = finalAttrs.version;
17 hash = "sha256-YkTlXON31cfA4EAS3RMhplVj7mFF3hx/CyiUrcQOkqc=";
18 leaveDotGit = true;
19 postFetch = ''
20 cd "$out"
21 git rev-parse HEAD > $out/COMMIT
22 find "$out" -name .git -print0 | xargs -0 rm -rf
23 '';
24 };
25
26 vendorHash = "sha256-S2CPDbgHcDYo6T2IIshmZkIatGLNMIdAMNBjowiMkwo=";
27
28 env.CGO_ENABLED = 0;
29
30 ldflags = [
31 "-s"
32 "-w"
33 "-X main.version=${finalAttrs.version}"
34 ];
35
36 preBuild = ''
37 ldflags+=" -X main.commit=$(cat COMMIT)"
38 '';
39
40 postInstall = ''
41 mv $out/bin/openhue-cli $out/bin/openhue
42 '';
43
44 doInstallCheck = true;
45 nativeInstallCheckInputs = [
46 versionCheckHook
47 writableTmpDirAsHomeHook
48 ];
49 versionCheckProgram = "${placeholder "out"}/bin/openhue";
50 versionCheckProgramArg = "version";
51 versionCheckKeepEnvironment = [ "HOME" ];
52
53 meta = {
54 changelog = "https://github.com/openhue/openhue-cli/releases/tag/${finalAttrs.version}";
55 description = "CLI for interacting with Philips Hue smart lighting systems";
56 homepage = "https://github.com/openhue/openhue-cli";
57 mainProgram = "openhue";
58 maintainers = with lib.maintainers; [ madeddie ];
59 license = lib.licenses.asl20;
60 };
61})