fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6cfg = config . targets . darwin ; 7homeDir = config . home . homeDirectory ; 8confFile = pkgs . writeText "DefaultKeybinding.dict" 9( lib . generators . toPlist { } cfg . keybindings ); 10in { 11options . targets . darwin . keybindings = mkOption { 12type = with types ; attrsOf anything ; 13default = { }; 14example = { 15"^u" = "deleteToBeginningOfLine:" ; 16"^w" = "deleteWordBackward:" ; 17}; 18description = '' 19This will configure the default keybindings for text fields in macOS 20applications. See 21[Apple's documentation](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html) 22for more details. 23 24::: {.warning} 25Existing keybinding configuration will be wiped when using this 26option. 27::: 28'' ; 29}; 30 31config = mkIf ( cfg . keybindings != { }) { 32assertions = [ 33( hm . assertions . assertPlatform "targets.darwin.keybindings" pkgs 34platforms . darwin ) 35]; 36 37# NOTE: just copy the files because symlinks won't be recognized by macOS 38home . activation . setCocoaKeybindings = 39hm . dag . entryAfter [ "writeBoundary" ] '' 40$VERBOSE_ECHO "Configuring keybindings for the Cocoa Text System" 41$DRY_RUN_CMD install -Dm644 $VERBOSE_ARG \ 42" ${ confFile } " " ${ homeDir } /Library/KeyBindings/DefaultKeyBinding.dict" 43'' ; 44}; 45}