1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-14 21:11:08 +01:00

treewide: reformat nixfmt-rfc-style

Reformat repository using new nixfmt-rfc-style.
This commit is contained in:
Austin Horstman 2025-04-07 16:11:29 -05:00
parent 5df48c4255
commit cba2f9ce95
1051 changed files with 37028 additions and 26594 deletions

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.macos-remap-keys;
keytables = import ./keytables.nix { inherit lib; };
@ -8,21 +13,21 @@ let
# Note: hidutil requires HIDKeyboardModifierMapping values to be in hexadecimal
# format rather than decimal JSON. Using hex strings instead of numbers will
# crash macOS.
makeMapping = table: from: to:
''
{ "HIDKeyboardModifierMappingSrc": ${
keyToHIDCode table from
}, "HIDKeyboardModifierMappingDst": ${keyToHIDCode table to} }'';
makeMapping =
table: from: to:
''{ "HIDKeyboardModifierMappingSrc": ${keyToHIDCode table from}, "HIDKeyboardModifierMappingDst": ${keyToHIDCode table to} }'';
makeMappingsList = table: mappings:
lib.mapAttrsToList (from: to: makeMapping table from to) mappings;
makeMappingsList =
table: mappings: lib.mapAttrsToList (from: to: makeMapping table from to) mappings;
allMappings = (makeMappingsList "keyboard" (cfg.keyboard or { }))
allMappings =
(makeMappingsList "keyboard" (cfg.keyboard or { }))
++ (makeMappingsList "keypad" (cfg.keypad or { }));
allMappingsString = lib.concatStringsSep ", " allMappings;
propertyString = ''{ "UserKeyMapping": [ ${allMappingsString} ] }'';
in {
in
{
meta.maintainers = [ lib.maintainers.WeetHet ];
options.services.macos-remap-keys = {
@ -51,19 +56,21 @@ in {
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.macos-remap-keys" pkgs
lib.platforms.darwin)
(lib.hm.assertions.assertPlatform "services.macos-remap-keys" pkgs lib.platforms.darwin)
];
home.activation.macosRemapKeys =
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
run --silence /usr/bin/hidutil property --set '${propertyString}'
'';
home.activation.macosRemapKeys = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
run --silence /usr/bin/hidutil property --set '${propertyString}'
'';
launchd.agents.remap-keys = {
enable = true;
config = {
ProgramArguments =
[ "/usr/bin/hidutil" "property" "--set" propertyString ];
ProgramArguments = [
"/usr/bin/hidutil"
"property"
"--set"
propertyString
];
KeepAlive.SuccessfulExit = false;
RunAtLoad = true;
};

View file

@ -1,13 +1,17 @@
{ lib }:
let
letters = let
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
lettersList = lib.stringToCharacters alphabet;
indices = builtins.genList (i: i + 4) 26;
in lib.listToAttrs (lib.zipListsWith (letter: index: {
name = letter;
value = "0x${lib.toHexString index}";
}) lettersList indices);
letters =
let
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
lettersList = lib.stringToCharacters alphabet;
indices = builtins.genList (i: i + 4) 26;
in
lib.listToAttrs (
lib.zipListsWith (letter: index: {
name = letter;
value = "0x${lib.toHexString index}";
}) lettersList indices
);
numbers = {
One = "0x1E";
@ -124,16 +128,22 @@ let
Equal = "0x67";
};
mapToInt = keyPage: attrs:
lib.mapAttrs (name: value:
let keycode = lib.fromHexString (lib.removePrefix "0x" value);
in "0x${lib.toHexString (keyPage + keycode)}") attrs;
mapToInt =
keyPage: attrs:
lib.mapAttrs (
name: value:
let
keycode = lib.fromHexString (lib.removePrefix "0x" value);
in
"0x${lib.toHexString (keyPage + keycode)}"
) attrs;
page7Keys = mapToInt (lib.fromHexString "700000000") (letters // numbers
// specialKeys // fKeys1To12 // fKeys13To24 // navigationKeys
// modifierKeys);
page7Keys = mapToInt (lib.fromHexString "700000000") (
letters // numbers // specialKeys // fKeys1To12 // fKeys13To24 // navigationKeys // modifierKeys
);
pageFFKeys = mapToInt (lib.fromHexString "FF00000000") { Fn = "0x3"; };
in {
in
{
keyboard = page7Keys // pageFFKeys;
keypad = mapToInt keypadKeys;
}