blob: 5e2a15aa18c766904ae8644bdd037c28c9cce7d7 (
plain)
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
64
65
66
67
68
69
70
71
72
73
|
{
lib,
stdenv,
fetchurl,
libarchive,
xar,
undmg,
nix-update-script,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "karabiner-elements";
version = "15.7.0";
src = fetchurl {
url = "https://github.com/pqrs-org/Karabiner-Elements/releases/download/v${finalAttrs.version}/Karabiner-Elements-${finalAttrs.version}.dmg";
hash = "sha256-Uy0k4xxkr33j92jxEhD/6DF0hhkdf8acU7lr3hTaFa4=";
};
outputs = [
"out"
"driver"
];
nativeBuildInputs = [
libarchive
xar
undmg
];
unpackPhase = ''
undmg $src
xar -xf Karabiner-Elements.pkg
cd Installer.pkg
zcat Payload | bsdcpio -i
cd ../Karabiner-DriverKit-VirtualHIDDevice.pkg
zcat Payload | bsdcpio -i
cd ..
'';
sourceRoot = ".";
postPatch = ''
shopt -s globstar
for f in *.pkg/Library/**/Launch{Agents,Daemons}/*.plist; do
substituteInPlace "$f" \
--replace-fail "/Library/" "$out/Library/"
done
'';
installPhase = ''
runHook preInstall
mkdir -p $out $driver
cp -R Installer.pkg/Applications Installer.pkg/Library $out
cp -R Karabiner-DriverKit-VirtualHIDDevice.pkg/Applications Karabiner-DriverKit-VirtualHIDDevice.pkg/Library $driver
cp "$out/Library/Application Support/org.pqrs/Karabiner-Elements/package-version" "$out/Library/Application Support/org.pqrs/Karabiner-Elements/version"
runHook postInstall
'';
dontFixup = true; # notarization breaks if fixup is enabled
passthru.updateScript = nix-update-script { };
meta = {
changelog = "https://github.com/pqrs-org/Karabiner-Elements/releases/tag/v${finalAttrs.version}";
description = "Powerful utility for keyboard customization on macOS Ventura (13) or later";
homepage = "https://karabiner-elements.pqrs.org/";
license = lib.licenses.unlicense;
maintainers = with lib.maintainers; [ auscyber ];
platforms = lib.platforms.darwin;
};
})
|