-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
81 lines (74 loc) · 2.35 KB
/
flake.nix
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
74
75
76
77
78
79
80
81
{
description = "Remap keys with pure macOS functionality";
inputs.flake-utils.url = "github:numtide/flake-utils";
# Also add flake-compat to inputs and outputs to easily allow updating
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
outputs = { self, nixpkgs, flake-utils, flake-compat }:
flake-utils.lib.eachSystem [ "x86_64-darwin" ] (system:
let
name = "macos-remap-keys";
pkgs = import nixpkgs { inherit system; };
python = pkgs.python3;
dependencies = pypkgs: with pypkgs; [
pyyaml
];
in
rec {
packages."${name}" = python.pkgs.buildPythonPackage {
name = name;
version = "0.1";
src = ./.;
propagatedBuildInputs = dependencies python.pkgs;
meta = {
homepage = "https://github.com/veehaitch/${name}";
description = self.description;
maintainers = pkgs.lib.maintainers.veehaitch;
};
};
defaultPackage = self.packages.${system}.${name};
# `nix run`
apps.${name} = flake-utils.lib.mkApp {
drv = packages.${name};
exePath = "/bin/remap.py";
};
defaultApp = apps.${name};
# `nix run .#launchd`
apps.launchd = {
type = "app";
program =
let drv = pkgs.writeShellScript "remap-launchd" ''
${defaultPackage}/bin/remap.py \
--config ${./config.yaml} \
--keytables ${./keytables.yaml} \
--launchd-plist \
~/Library/LaunchAgents/ch.veehait.macos-remap-keys.plist
'';
in drv.outPath;
};
# `nix run .#hidutil`
apps.hidutil = {
type = "app";
program =
let drv = pkgs.writeShellScript "remap-launchd" ''
hidutil property --set \
`${defaultPackage}/bin/remap.py \
--config ${./config.yaml} \
--keytables ${./keytables.yaml} \
--hidutil-property`
'';
in drv.outPath;
};
# `nix develop`
devShell = pkgs.mkShell {
name = "${name}-shell";
nativeBuildInputs = [
pkgs.black
(dependencies python.pkgs)
];
};
}
);
}