1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 pkg-config,
6}:
7let
8 pname = "xremap";
9 version = "0.14.0";
10
11 src = fetchFromGitHub {
12 owner = "xremap";
13 repo = "xremap";
14 tag = "v${version}";
15 hash = "sha256-UJcnlAwCbBDubMp0ScIK+RfN09UsC5kzFIFLIr80jfk=";
16 };
17
18 cargoHash = "sha256-QcAF/zKWClvpnEaQP7wyEgYpQw9F3TmYdmu4Y38H+Aw=";
19
20 buildXremap =
21 {
22 suffix ? "",
23 features ? [ ],
24 descriptionSuffix ? "",
25 }:
26 assert descriptionSuffix != "" && features != [ ];
27 rustPlatform.buildRustPackage {
28 pname = "${pname}${suffix}";
29 inherit version src cargoHash;
30
31 nativeBuildInputs = [ pkg-config ];
32
33 buildNoDefaultFeatures = true;
34 buildFeatures = features;
35
36 meta = {
37 description =
38 "Key remapper for X11 and Wayland"
39 + lib.optionalString (descriptionSuffix != "") " (${descriptionSuffix} support)";
40 homepage = "https://github.com/xremap/xremap";
41 changelog = "https://github.com/xremap/xremap/blob/${src.tag}/CHANGELOG.md";
42 license = lib.licenses.mit;
43 mainProgram = "xremap";
44 maintainers = [ lib.maintainers.hakan-demirli ];
45 platforms = lib.platforms.linux;
46 };
47 };
48
49 variants = {
50 x11 = buildXremap {
51 features = [ "x11" ];
52 descriptionSuffix = "X11";
53 };
54 gnome = buildXremap {
55 suffix = "-gnome";
56 features = [ "gnome" ];
57 descriptionSuffix = "Gnome";
58 };
59 kde = buildXremap {
60 suffix = "-kde";
61 features = [ "kde" ];
62 descriptionSuffix = "KDE";
63 };
64 wlroots = buildXremap {
65 suffix = "-wlroots";
66 features = [ "wlroots" ];
67 descriptionSuffix = "wlroots";
68 };
69 hyprland = buildXremap {
70 suffix = "-hyprland";
71 features = [ "hypr" ];
72 descriptionSuffix = "Hyprland";
73 };
74 };
75
76in
77variants.wlroots.overrideAttrs (finalAttrs: {
78 passthru = {
79 gnome = variants.gnome;
80 kde = variants.kde;
81 wlroots = variants.wlroots;
82 hyprland = variants.hyprland;
83 x11 = variants.x11;
84 };
85})