about summary refs log tree commit diff
path: root/pkgs/by-name/sk/skhd/package.nix
blob: d3b3b9adb96a9887dda9da95b1bfd1f2892651ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{
  lib,
  overrideSDK,
  stdenv,
  darwin,
  fetchFromGitHub,
  testers,
  nix-update-script,
}:
let
  inherit (darwin.apple_sdk_11_0.frameworks) Carbon Cocoa;

  stdenv' = if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv;
in
stdenv'.mkDerivation (finalAttrs: {
  pname = "skhd";
  version = "0.3.9";

  src = fetchFromGitHub {
    owner = "koekeishiya";
    repo = "skhd";
    rev = "v${finalAttrs.version}";
    hash = "sha256-fnkWws/g4BdHKDRhqoCpdPFUavOHdk8R7h7H1dAdAYI=";
  };

  buildInputs = [
    Carbon
    Cocoa
  ];

  makeFlags = [ "BUILD_PATH=$(out)/bin" ];

  env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";

  postInstall = ''
    mkdir -p $out/Library/LaunchDaemons
    cp ${./org.nixos.skhd.plist} $out/Library/LaunchDaemons/org.nixos.skhd.plist
    substituteInPlace $out/Library/LaunchDaemons/org.nixos.skhd.plist --subst-var out
  '';

  passthru = {
    tests.version = testers.testVersion {
      package = finalAttrs.finalPackage;
      version = "skhd-v${finalAttrs.version}";
    };

    updateScript = nix-update-script { };
  };

  meta = {
    description = "Simple hotkey daemon for macOS";
    homepage = "https://github.com/koekeishiya/skhd";
    license = lib.licenses.mit;
    mainProgram = "skhd";
    maintainers = with lib.maintainers; [
      cmacrae
      lnl7
      periklis
      khaneliman
    ];
    platforms = lib.platforms.darwin;
  };
})