nixpkgs/pkgs/by-name/ka/karabiner-elements/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

70 lines
1.7 KiB
Nix

{
lib,
stdenv,
fetchurl,
cpio,
xar,
undmg,
nix-update-script,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "karabiner-elements";
version = "15.0.0";
src = fetchurl {
url = "https://github.com/pqrs-org/Karabiner-Elements/releases/download/v${finalAttrs.version}/Karabiner-Elements-${finalAttrs.version}.dmg";
hash = "sha256-xWCsbkP9cVnDjWFTgWl5KrR7wEpcQYM4Md99pTI/l14=";
};
outputs = [
"out"
"driver"
];
nativeBuildInputs = [
cpio
xar
undmg
];
unpackPhase = ''
undmg $src
xar -xf Karabiner-Elements.pkg
cd Installer.pkg
zcat Payload | cpio -i
cd ../Karabiner-DriverKit-VirtualHIDDevice.pkg
zcat Payload | cpio -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 = ''
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"
'';
passthru.updateScript = nix-update-script { };
meta = {
changelog = "https://github.com/pqrs-org/Karabiner-Elements/releases/tag/v${finalAttrs.version}";
description = "Karabiner-Elements is a powerful utility for keyboard customization on macOS Ventura (13) or later";
homepage = "https://karabiner-elements.pqrs.org/";
license = lib.licenses.unlicense;
maintainers = [ ];
platforms = lib.platforms.darwin;
};
})