mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
parent
3bedff357a
commit
edc3be51ce
3 changed files with 58 additions and 2 deletions
|
@ -22,15 +22,16 @@ let
|
||||||
./modules/system
|
./modules/system
|
||||||
./modules/system/activation-checks.nix
|
./modules/system/activation-checks.nix
|
||||||
./modules/system/activation-scripts.nix
|
./modules/system/activation-scripts.nix
|
||||||
|
./modules/system/applications.nix
|
||||||
./modules/system/defaults-write.nix
|
./modules/system/defaults-write.nix
|
||||||
./modules/system/defaults/NSGlobalDomain.nix
|
|
||||||
./modules/system/defaults/LaunchServices.nix
|
./modules/system/defaults/LaunchServices.nix
|
||||||
|
./modules/system/defaults/NSGlobalDomain.nix
|
||||||
./modules/system/defaults/dock.nix
|
./modules/system/defaults/dock.nix
|
||||||
./modules/system/defaults/finder.nix
|
./modules/system/defaults/finder.nix
|
||||||
./modules/system/defaults/smb.nix
|
./modules/system/defaults/smb.nix
|
||||||
./modules/system/defaults/trackpad.nix
|
./modules/system/defaults/trackpad.nix
|
||||||
./modules/system/applications.nix
|
|
||||||
./modules/system/etc.nix
|
./modules/system/etc.nix
|
||||||
|
./modules/system/keyboard.nix
|
||||||
./modules/system/launchd.nix
|
./modules/system/launchd.nix
|
||||||
./modules/system/shells.nix
|
./modules/system/shells.nix
|
||||||
./modules/system/version.nix
|
./modules/system/version.nix
|
||||||
|
|
|
@ -59,6 +59,7 @@ in
|
||||||
${cfg.activationScripts.nix-daemon.text}
|
${cfg.activationScripts.nix-daemon.text}
|
||||||
${cfg.activationScripts.time.text}
|
${cfg.activationScripts.time.text}
|
||||||
${cfg.activationScripts.networking.text}
|
${cfg.activationScripts.networking.text}
|
||||||
|
${cfg.activationScripts.keyboard.text}
|
||||||
|
|
||||||
${cfg.activationScripts.extraPostActivation.text}
|
${cfg.activationScripts.extraPostActivation.text}
|
||||||
|
|
||||||
|
|
54
modules/system/keyboard.nix
Normal file
54
modules/system/keyboard.nix
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.system.keyboard;
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
system.keyboard.enableKeyMapping = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Whether to enable keyboard mappings.";
|
||||||
|
};
|
||||||
|
|
||||||
|
system.keyboard.remapCapsLockToControl = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Whether to remap the Caps Lock key to Control.";
|
||||||
|
};
|
||||||
|
|
||||||
|
system.keyboard.remapCapsLockToEscape = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Whether to remap the Caps Lock key to Escape.";
|
||||||
|
};
|
||||||
|
|
||||||
|
system.keyboard.userKeyMapping = mkOption {
|
||||||
|
internal = true;
|
||||||
|
type = types.listOf (types.attrsOf types.int);
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
List of keyboard mappings to apply, for more information see
|
||||||
|
<link xlink:href="https://developer.apple.com/library/content/technotes/tn2450/_index.html"/>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
|
||||||
|
system.keyboard.userKeyMapping = mkMerge [
|
||||||
|
(mkIf cfg.remapCapsLockToControl [{ HIDKeyboardModifierMappingSrc = 30064771129; HIDKeyboardModifierMappingDst = 30064771296; }])
|
||||||
|
(mkIf cfg.remapCapsLockToEscape [{ HIDKeyboardModifierMappingSrc = 30064771129; HIDKeyboardModifierMappingDst = 30064771113; }])
|
||||||
|
];
|
||||||
|
|
||||||
|
system.activationScripts.keyboard.text = optionalString cfg.enableKeyMapping ''
|
||||||
|
# Configuring keyboard
|
||||||
|
echo "configuring keyboard..." >&2
|
||||||
|
hidutil property --set '{"UserKeyMapping":${builtins.toJSON cfg.userKeyMapping}}' > /dev/null
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue