-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
108 lines (102 loc) · 2.98 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
description = "schoenberg";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
({
nixosModule = { config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.schoenberg;
in
{
options.services.schoenberg = {
enable = mkEnableOption "schoenberg";
config = mkOption rec {
type = types.attrs;
apply = recursiveUpdate default;
default = {
mapping = { };
layers = [ ];
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
interception-tools
self.defaultPackage.aarch64-linux
];
systemd.services."schoenberg" = {
enable = true;
description = "Keyboard Mapping";
path = [
pkgs.interception-tools
self.defaultPackage.aarch64-linux
pkgs.bash
];
serviceConfig = {
ExecStart = "${pkgs.interception-tools}/bin/udevmon -c /etc/schoenberg_udev.yaml";
};
wants = [ "systemd-udev-settle.service" ];
after = [ "systemd-udev-settle.service" ];
wantedBy = [ "multi-user.target" ];
};
environment.etc."schoenberg_config.json" =
{
mode = "004";
text = builtins.toJSON cfg.config;
};
environment.etc."schoenberg_udev.yaml" =
{
mode = "004";
text =
''
- JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${self.defaultPackage.aarch64-linux}/bin/schoenberg_run /etc/schoenberg_config.json | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE"
DEVICE:
EVENTS:
EV_KEY: [KEY_F]
'';
};
};
};
} //
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs {
system = system;
});
commonPkgs = with pkgs; [
gtest
libyamlcpp
libevdev
nlohmann_json
interception-tools
];
in
{
defaultPackage = pkgs.stdenv.mkDerivation {
name = "schoenberg";
src = ./.;
buildInputs = commonPkgs;
nativeBuildInputs = [
pkgs.cmake
];
installPhase = ''
mkdir -p $out/bin
cp src/schoenberg_run $out/bin
'';
};
devShell =
pkgs.mkShell {
buildInputs = (with pkgs; [
which
cmake
gcc
jetbrains.clion
]) ++ commonPkgs;
shellHook = ''
'';
};
}));
}