From cb94b8353a765d2429aefe9c9a2845510076d357 Mon Sep 17 00:00:00 2001 From: willemml Date: Tue, 11 Apr 2023 09:28:58 -0700 Subject: [PATCH] darwin configuration reorganization --- .../profiles/user/willem/darwin/base.nix | 56 +++++++++++---- .../profiles/user/willem/darwin/keybinds.nix | 68 +++++++++++++++++++ .../user/willem/programs/emacs/init.el | 4 +- nixos/hosts/zeus.darwin.nix | 61 ----------------- 4 files changed, 114 insertions(+), 75 deletions(-) create mode 100644 home-manager/modules/profiles/user/willem/darwin/keybinds.nix diff --git a/home-manager/modules/profiles/user/willem/darwin/base.nix b/home-manager/modules/profiles/user/willem/darwin/base.nix index 450c98e..389a413 100644 --- a/home-manager/modules/profiles/user/willem/darwin/base.nix +++ b/home-manager/modules/profiles/user/willem/darwin/base.nix @@ -23,14 +23,6 @@ in { ''; }; - home.file.".config/zsh/am.sh" = { - executable = true; - source = builtins.fetchurl { - url = "https://raw.githubusercontent.com/mcthomas/Apple-Music-CLI-Player/27353ec55abac8b5d73b8a061fb87f305c663adb/src/am.sh"; - sha256 = "sha256-78zRpNg7/OR7p8dpsJt6Xc4j0Y+8zSUtm/PT94nf03M="; - }; - }; - programs.zsh.shellAliases = { drs = "darwin-rebuild switch --flake ${config.home.homeDirectory}/.config/dotfiles.nix#"; @@ -62,17 +54,37 @@ in { NSGlobalDomain = { AppleLanguages = ["en-CA"]; AppleLocale = "en_CA"; + "com.apple.sound.beep.feedback" = 1; + AppleICUForce24HourTime = true; + AppleInterfaceStyle = "Dark"; + AppleMeasurementUnits = "Centimeters"; + AppleMetricUnits = true; + AppleShowAllExtensions = true; + AppleShowScrollBars = "WhenScrolling"; + AppleTemperatureUnit = "Celsius"; + NSAutomaticCapitalizationEnabled = false; + NSAutomaticDashSubstitutionEnabled = false; + NSAutomaticPeriodSubstitutionEnabled = false; + NSAutomaticQuoteSubstitutionEnabled = false; + NSAutomaticSpellingCorrectionEnabled = false; + NSAutomaticWindowAnimationsEnabled = false; + NSDocumentSaveNewDocumentsToCloud = false; + NSNavPanelExpandedStateForSaveMode = true; + NSNavPanelExpandedStateForSaveMode2 = true; + NSTableViewDefaultSizeMode = 1; + NSTextShowsControlCharacters = true; + NSWindowResizeTime = 0.0; }; - "com.apple.Safari" = { + com.apple.Safari = { AutoOpenSafeDownloads = false; IncludeDevelopMenu = true; ShowFullURLInSmartSearchField = true; }; - "com.apple.menuextra.clock" = { + com.apple.menuextra.clock = { DateFormat = "EEE d MMM HH:mm:ss"; FlashDateSeparators = false; }; - "com.apple.controlcenter" = { + com.apple.controlcenter = { "NSStatusItem Visible AccessibilityShortcuts" = false; "NSStatusItem Visible AirDrop" = false; "NSStatusItem Visible Battery" = true; @@ -87,11 +99,31 @@ in { "NSStatusItem Visible UserSwitcher" = false; "NSStatusItem Visible WiFi" = true; }; - "com.apple.systempreferences" = { + com.apple.systempreferences = { "com.apple.preference.battery".hasBeenWarnedAboutEnergyUsage = true; }; com.apple.appleseed.FeedbackAssistant.Autogather = false; com.apple.TextEdit.RichText = false; + loginwindow = { + SHOWFULLNAME = false; + GuestEnabled = false; + DisableConsoleAccess = true; + }; + LaunchServices.LSQuarantine = false; + com.apple.dock = { + autohide = true; + launchanim = false; + minimize-to-application = true; + mru-spaces = false; + orientation = "bottom"; + static-only = true; + tilesize = 35; + }; + com.apple.driver.AppleBluetoothMultitouch.trackpad = { + FirstClickThreshold = 0; + SecondClickThreshold = 2; + Clicking = true; + }; }; currentHostDefaults = { "com.apple.controlcenter".BatteryShowPercentage = true; diff --git a/home-manager/modules/profiles/user/willem/darwin/keybinds.nix b/home-manager/modules/profiles/user/willem/darwin/keybinds.nix new file mode 100644 index 0000000..8385f94 --- /dev/null +++ b/home-manager/modules/profiles/user/willem/darwin/keybinds.nix @@ -0,0 +1,68 @@ +{lib, ...}: { + # Global Emacs keybindings + targets.darwin.keybindings = { + "^l" = "centerSelectionInVisibleArea:"; + "^/" = "undo:"; + "^_" = "undo:"; + "^ " = "setMark:"; + "^\@" = "setMark:"; + "^w" = "deleteToMark:"; + "~f" = "moveWordForward:"; + "~b" = "moveWordBackward:"; + "~<" = "moveToBeginningOfDocument:"; + "~>" = "moveToEndOfDocument:"; + "~v" = "pageUp:"; + "~/" = "complete:"; + "~c" = [ + "capitalizeWord:" + "moveForward:" + "moveForward:" + ]; + "~u" = [ + "uppercaseWord:" + "moveForward:" + "moveForward:" + ]; + "~l" = [ + "lowercaseWord:" + "moveForward:" + "moveForward:" + ]; + "~d" = "deleteWordForward:"; + "^~h" = "deleteWordBackward:"; + "~\U007F" = "deleteWordBackward:"; + "~t" = "transposeWords:"; + "~\@" = [ + "setMark:" + "moveWordForward:" + "swapWithMark" + ]; + "~h" = [ + "setMark:" + "moveToEndOfParagraph:" + "swapWithMark" + ]; + "^x" = { + "u" = "undo:"; + "k" = "performClose:"; + "^f" = "openDocument:"; + "^x" = "swapWithMark:"; + "^m" = "selectToMark:"; + "^s" = "saveDocument:"; + "^w" = "saveDocumentAs:"; + }; + }; + + home.activation.configureDarwinKeyboard = let + userKeyMapping = [ + { + HIDKeyboardModifierMappingSrc = 30064771303; # remap right command to right control. + HIDKeyboardModifierMappingDst = 30064771300; + } + ]; + in + lib.hm.dag.entryAfter ["writeBoundary"] '' + $VERBOSE_ECHO "Configuring Darwin keyboard mappings." + $DRY_RUN_CMD /usr/bin/hidutil property --set '{"UserKeyMapping":${builtins.toJSON userKeyMapping}}' > /dev/null + ''; +} diff --git a/home-manager/modules/profiles/user/willem/programs/emacs/init.el b/home-manager/modules/profiles/user/willem/programs/emacs/init.el index 4a5e1bb..c2ba281 100644 --- a/home-manager/modules/profiles/user/willem/programs/emacs/init.el +++ b/home-manager/modules/profiles/user/willem/programs/emacs/init.el @@ -146,6 +146,8 @@ (editorconfig-mode 1) (global-set-key (kbd "C-c C-y") 'format-all-buffer) + +(add-to-list 'format-all-default-formatters '("Nix" alejandra)) (setq-default format-all-formatters format-all-default-formatters) (autoload 'gnuplot-mode "gnuplot" "Gnuplot major mode" t) @@ -325,8 +327,6 @@ (add-to-list 'auto-mode-alist '("\\.nix$" . poly-nix-mode)) -(add-to-list 'format-all-default-formatters '("Nix" alejandra)) - (define-key nix-mode-map (kbd "C-c C-u") 'nix-update-fetch) (setq org-babel-octave-shell-command "octave -q") diff --git a/nixos/hosts/zeus.darwin.nix b/nixos/hosts/zeus.darwin.nix index 9a14b0f..13fcca8 100644 --- a/nixos/hosts/zeus.darwin.nix +++ b/nixos/hosts/zeus.darwin.nix @@ -15,8 +15,6 @@ ''; environment.loginShell = "${pkgs.zsh}/bin/zsh -l"; - environment.systemPackages = with pkgs; [ - ]; programs.zsh.loginShellInit = '' reexec() { @@ -34,65 +32,6 @@ services.nix-daemon.enable = true; - system = { - defaults = { - loginwindow = { - SHOWFULLNAME = false; - GuestEnabled = false; - DisableConsoleAccess = true; - }; - LaunchServices.LSQuarantine = false; - dock = { - autohide = true; - launchanim = false; - minimize-to-application = true; - mru-spaces = false; - orientation = "bottom"; - static-only = true; - tilesize = 35; - }; - NSGlobalDomain = { - "com.apple.sound.beep.feedback" = 1; - AppleICUForce24HourTime = true; - AppleInterfaceStyle = "Dark"; - AppleMeasurementUnits = "Centimeters"; - AppleMetricUnits = 1; - AppleShowAllExtensions = true; - AppleShowScrollBars = "WhenScrolling"; - AppleTemperatureUnit = "Celsius"; - NSAutomaticCapitalizationEnabled = false; - NSAutomaticDashSubstitutionEnabled = false; - NSAutomaticPeriodSubstitutionEnabled = false; - NSAutomaticQuoteSubstitutionEnabled = false; - NSAutomaticSpellingCorrectionEnabled = false; - NSAutomaticWindowAnimationsEnabled = false; - NSDocumentSaveNewDocumentsToCloud = false; - NSNavPanelExpandedStateForSaveMode = true; - NSNavPanelExpandedStateForSaveMode2 = true; - NSTableViewDefaultSizeMode = 1; - NSTextShowsControlCharacters = true; - NSWindowResizeTime = 0.0; - }; - trackpad = { - FirstClickThreshold = 0; - SecondClickThreshold = 2; - Clicking = true; - }; - }; - - keyboard = { - enableKeyMapping = true; - remapCapsLockToEscape = true; - # see https://developer.apple.com/library/content/technotes/tn2450/_index.html for more info - userKeyMapping = [ - { - HIDKeyboardModifierMappingSrc = 30064771303; # remap right command to right control. - HIDKeyboardModifierMappingDst = 30064771300; - } - ]; - }; - }; - users.users.willem = { home = "/Users/willem"; isHidden = false;