commit 0d1be02e20ca248e1b732fe6baa7b8f6bd4ebef9
parent a5ca6747b4b9418bf5f429c8ad265b29211a02bd
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 13 Jun 2022 11:07:51 +0200
parent a5ca6747b4b9418bf5f429c8ad265b29211a02bd
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 13 Jun 2022 11:07:51 +0200
machines/{blechkasten,blechbuechse}: modularize configuration
19 files changed, 544 insertions(+), 777 deletions(-)
A
|
75
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A
|
134
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A
|
143
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M
|
200
++++++-------------------------------------------------------------------------
D
|
144
-------------------------------------------------------------------------------
M
|
200
++++++-------------------------------------------------------------------------
D
|
144
-------------------------------------------------------------------------------
diff --git a/configurations/darwin/appSettings.nix b/configurations/darwin/appSettings.nix @@ -0,0 +1,43 @@ +{ config, pkgs, lib, ... }: + +{ + + system.activationScripts.extraUserActivation.text = '' + # + # TextEdit + # + + # Disable RichText + defaults write com.apple.TextEdit RichText -int 0 + + # Open and save files as UTF-8 + defaults write com.apple.TextEdit PlainTextEncoding -int 4 + defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 + + + + # + # iTerm + # + + # Disable iTerm's annoying promt when quitting it + defaults write com.googlecode.iterm2 PromptOnQuit -bool false + + + + # + # Hot.app + # + + # don't check for updates + defaults write com.xs-labs.Hot automaticallyCheckForUpdates -bool false + + # Disable icon in applet + defaults write com.xs-labs.Hot hideStatusIcon -bool true + + # set refresh-intervall to 10 sec + defaults write com.xs-labs.Hot refreshInterval -int 10 + + ''; + +}
diff --git a/configurations/darwin/finder.nix b/configurations/darwin/finder.nix @@ -0,0 +1,75 @@ +{ config, pkgs, lib, ... }: + +{ + + system.activationScripts.extraUserActivation.text = '' + # Avoid creating .DS_Store files on network or USB volumes + defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true + defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true + + # Automatically open a new Finder window when a volume is mounted + defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true + defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true + defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true + + # Set defaults for panes in Finder's "Get Info" + defaults write com.apple.finder FXInfoPanesExpanded -dict \ + General -bool true \ + OpenWith -bool true \ + Privileges -bool true \ + Preview -bool false + + # disable animation when opening the info window in finder (CMD + I) + defaults write com.apple.finder DisableAllAnimations -bool true + + # keep folders on top when sorting by name + defaults write com.apple.finder _FXSortFoldersFirst -bool true + + # Set $HOME as the default location for new Finder windows + defaults write com.apple.finder NewWindowTarget -string "PfLo" + defaults write com.apple.finder NewWindowTargetPath -string "file://${config.home-manager.users.leah.home.homeDirectory}/" + ''; + + system.defaults = { + NSGlobalDomain = { + AppleShowAllExtensions = true; + + # Save to disk (not to iCloud!) by default + NSDocumentSaveNewDocumentsToCloud = false; + + # Expand save panel by default + NSNavPanelExpandedStateForSaveMode = true; + NSNavPanelExpandedStateForSaveMode2 = true; + + # Enable spring loading for directories + "com.apple.springing.enabled" = true; + # Remove the spring loading delay for directories + "com.apple.springing.delay" = "0.0"; + }; + + LaunchServices = { + # disable "Application Downloaded from Internet" popup + LSQuarantine = false; + }; + + finder = { + #allow quitting the finder + QuitMenuItem = true; + # always show file-extensions + AppleShowAllExtensions = true; + # No icons on desktop + CreateDesktop = false; + # show statusbar at the bottom of the finder window + ShowStatusBar = true; + # no brotkrümel in finder pls + ShowPathbar = false; + # default view style ("icnv" = Icon view, "Nlsv" = List view, "clmv" = Column View, "Flwv" = Gallery View) + FXPreferredViewStyle = "Nlsv"; + # default search scope ("SCcf" = current folder; null = This Mac) + FXDefaultSearchScope = "SCcf"; + # no warning when changing the file extension + FXEnableExtensionChangeWarning = false; + }; + }; + +}
diff --git a/configurations/darwin/keyboard.nix b/configurations/darwin/keyboard.nix @@ -0,0 +1,47 @@ +{ config, pkgs, lib, ... }: + +{ + + imports = [ + ../../modules/darwin/hidutil.nix + ]; + + system.defaults = { + NSGlobalDomain = { + # keyboard repeat rate (default: 25/6) + InitialKeyRepeat = 35; + KeyRepeat = 3; + }; + }; + + hidutil = { + enable = true; + remapKeys = [ + { + # Internal keyboard + VendorID = "5ac"; + ProductID = "281"; + UserKeyMapping = [ + # Remap tilde on non-US keyboards + { HIDKeyboardModifierMappingSrc = 30064771172; HIDKeyboardModifierMappingDst = 30064771125; } + # Swap right_command and right_option + { HIDKeyboardModifierMappingSrc = 30064771303; HIDKeyboardModifierMappingDst = 30064771302; } + { HIDKeyboardModifierMappingSrc = 30064771302; HIDKeyboardModifierMappingDst = 30064771303; } + ]; + } + { + # Trackpoint Keyboard 2 + VendorID = "17ef"; + ProductID = "60ee"; + UserKeyMapping = [ + # Swap left_command and left_option + { HIDKeyboardModifierMappingSrc = 30064771299; HIDKeyboardModifierMappingDst = 30064771298; } + { HIDKeyboardModifierMappingSrc = 30064771298; HIDKeyboardModifierMappingDst = 30064771299; } + # Remap PrintScreen to left_command + { HIDKeyboardModifierMappingSrc = 30064771142; HIDKeyboardModifierMappingDst = 30064771299; } + ]; + } + ]; + }; + +}
diff --git a/configurations/darwin/systemSettings.nix b/configurations/darwin/systemSettings.nix @@ -0,0 +1,134 @@ +{ config, pkgs, lib, ... }: + +{ + + fonts = { + fontDir.enable = true; + fonts = with pkgs; [ + iosevka-bin + ]; + }; + + system.activationScripts.postActivation.text = '' + # Set the default shell to bash. MacOS doesn't do this like nixOS does + sudo chsh -s ${pkgs.bashInteractive}/bin/bash leah + + # Enable sudo Touch ID authentication, if not already enabled + if ! grep 'pam_tid.so' /etc/pam.d/sudo > /dev/null; then + sed -i "" '2i\ + auth sufficient pam_tid.so # use TouchID with sudo + ' /etc/pam.d/sudo + fi + ''; + + system.activationScripts.extraSystemSettings.text = '' + # Sleep display after 30 minutes + #sudo pmset -a displaysleep 30 + + # Prevent Time Machine from prompting to use new hard drives as backup volume + defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true + ''; + + system.activationScripts.extraUserActivation.text = '' + # Set accent color to green + defaults write .GlobalPreferences AppleAccentColor -int 3 + + # Show battery percentage in menubar + defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist BatteryShowPercentage -bool true + + # Show sound-applet always in menubar + defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist Sound -int 16 + + # Set menubar clock format + defaults write com.apple.menuextra.clock "DateFormat" -string "\"d MMM HH:mm:ss\"" + + # Flash clock time seperators + defaults write com.apple.menuextra.clock "FlashDateSeparators" -bool "true" + + # Prevent Photos from opening automatically when devices are plugged in + defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true + + # drag windows by holding CTRL + CMD and clicking anywhere in the window + # does not work with all applications + defaults write -g NSWindowShouldDragOnGesture -bool true + + # do not autogather large files when submitting a report + defaults write com.apple.appleseed.FeedbackAssistant "Autogather" -bool "false" + + # Disable Resume system-wide + defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false + ''; + + time.timeZone = "Europe/Berlin"; + + system.defaults = { + NSGlobalDomain = { + AppleInterfaceStyle = "Dark"; + AppleInterfaceStyleSwitchesAutomatically = false; + + AppleTemperatureUnit = "Celsius"; + AppleMeasurementUnits = "Centimeters"; + AppleMetricUnits = 1; + + AppleShowAllExtensions = true; + + # Always show scrollbars + AppleShowScrollBars = "Always"; + + # Enable subpixel font rendering on non-Apple LCDs + # Reference: https://github.com/kevinSuttle/macOS-Defaults/issues/17#issuecomment-266633501 + AppleFontSmoothing = 1; + + # navigate UI elements with keyboard (tab key) + AppleKeyboardUIMode = 3; + + ApplePressAndHoldEnabled = true; + + "com.apple.sound.beep.volume" = "0.6"; + + # Set sidebar icon size to medium + NSTableViewDefaultSizeMode = 2; + + # don't animate opening and closing of windows and popovers + NSAutomaticWindowAnimationsEnabled = false; + + NSAutomaticCapitalizationEnabled = false; + NSAutomaticDashSubstitutionEnabled = false; + NSAutomaticPeriodSubstitutionEnabled = false; + NSAutomaticQuoteSubstitutionEnabled = false; + NSAutomaticSpellingCorrectionEnabled = false; + + # Disable automatic termination of inactive apps + NSDisableAutomaticTermination = true; + }; + + # disable automatic macupdates + SoftwareUpdate.AutomaticallyInstallMacOSUpdates = false; + + dock = { + tilesize = 50; + minimize-to-application = true; + show-recents = false; + # Dont rearrange my workspaces automagicly, thanks + mru-spaces = false; + + # Disable all hot corners + wvous-tl-corner = 1; + wvous-tr-corner = 1; + wvous-bl-corner = 1; + wvous-br-corner = 1; + }; + + screencapture = { + disable-shadow = true; + location = "${config.home-manager.users.leah.home.homeDirectory}/Pictures/Screenshots"; + }; + + smb = { + NetBIOSName = config.networking.hostName; + ServerDescription = config.networking.hostName; + }; + + }; + +}
diff --git a/configurations/darwin/trackpad.nix b/configurations/darwin/trackpad.nix @@ -0,0 +1,28 @@ +{ config, pkgs, lib, ... }: + +{ + + system.defaults = { + NSGlobalDomain = { + # Natural scroll + "com.apple.swipescrolldirection" = true; + # Point & Click: Tracking speed + "com.apple.trackpad.scaling" = "1"; + }; + + trackpad = { + # Point & Click: Silent clicking (0 = on; 1 = off) + ActuationStrength = 1; + # Point & Click: Secondary click + TrackpadRightClick = true; + # Point & Click: Tap to click + Clicking = false; + + # Point & Click: Click + FirstClickThreshold = 2; + SecondClickThreshold = 2; + }; + + }; + +}
diff --git a/configurations/darwin/yabai.nix b/configurations/darwin/yabai.nix @@ -0,0 +1,143 @@ +{ config, pkgs, ... }: + +let + yabai = pkgs.callPackage ../../pkgs/yabai.nix {}; + + toggleFloating = pkgs.writeScript "yabaiToggleFloating.sh" '' + #!/usr/bin/env bash + PATH=$(eval echo $PATH) + + # Toggle the workspace layout between float and bsp + read -r curType index <<< $(echo $(yabai -m query --spaces --space | jq '.type, .index')) + + if [ $curType = '"bsp"' ]; then + yabai -m space --layout float + osascript -e "display notification \"Change the layout of workspace $index to float\" with title \"yabai\"" + else + yabai -m space --layout bsp + osascript -e "display notification \"Change the layout of workspace $index to bsp\" with title \"yabai\"" + fi + ''; + +in { + + environment.etc."sudoers.d/yabai".text = '' + leah ALL = (root) NOPASSWD: ${yabai}/bin/yabai --load-sa + ''; + + services.yabai = { + enable = true; + package = yabai; + config = { + layout = "float"; + + window_placement = "second_child"; + window_topmost = "off"; + window_shadow = "off"; + window_opacity = "off"; + +# focus_follows_mouse = "autofocus"; + mouse_follows_focus = "off"; + + mouse_modifier = "alt"; + mouse_action1 = "move"; + mouse_action2 = "resize"; + + }; + + extraConfig = '' + #sudo yabai --load-sa + + # load scripting-additions when Dock.app restarts + #yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa" + + # fix focus when closing windows + yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" + yabai -m signal --add event=application_terminated action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" + + # float system preferences + yabai -m rule --add app='^System Information$' manage=off layer=above + yabai -m rule --add app='^System Preferences$' manage=off layer=above + yabai -m rule --add title='Preferences$' manage=off layer=above + + # float settings and file windows + yabai -m rule --add title='Settings$' manage=off layer=above + yabai -m rule --add title='Opening$' manage=off layer=above + + # float Finder and AppStore + #yabai -m rule --add app='Finder' manage=off layer=above + #yabai -m rule --add app='App Store' manage=off layer=above + + #float firefox PiP window + #yabai -m rule --add label="Firfox PIP" app="^Firefox$" title="^(Picture-in-Picture)$" manage=off layer=above sticky=on + + yabai -m rule --add app='pinentry-mac' manage=off layer=above sticky=on + + #float Calculator + yabai -m rule --add app='Calculator' manage=off layer=above sticky=on + + yabai -m rule --add app='Firefox' space=1 + yabai -m rule --add app='Mail' space=2 + yabai -m rule --add app='Thunderbird' space=2 + yabai -m rule --add app='Finder' space=6 + ''; + }; + + services.skhd = { + enable = true; + skhdConfig = '' + # kill focused window + lalt + shift - q : yabai -m window --close + + # float / unfloat window and center on screen + #lalt - space : yabai -m window --toggle float; yabai -m window --grid 4:4:1:1:2:2 + + # enter fullscreen mode for the focused window + lalt - f : yabai -m window --toggle zoom-fullscreen + + # change layout of desktop + lalt - e : ${toggleFloating} + + # rotate tree + lalt - r : yabai -m space --rotate 90 + + # change focus (using arrow keys) + lalt - left : yabai -m window --focus west + lalt - right : yabai -m window --focus east + lalt - down : yabai -m window --focus south + lalt - up : yabai -m window --focus north + + # move managed window + shift + lalt - left : yabai -m window --warp west + shift + lalt - right : yabai -m window --warp east + shift + lalt - down : yabai -m window --warp south + shift + lalt - up : yabai -m window --warp north + + # move between workspaces + #lalt - 1 : yabai -m space --focus 1 + #lalt - 2 : yabai -m space --focus 2 + #lalt - 3 : yabai -m space --focus 3 + #lalt - 4 : yabai -m space --focus 4 + #lalt - 5 : yabai -m space --focus 5 + #lalt - 6 : yabai -m space --focus 6 + #lalt - 7 : yabai -m space --focus 7 + #lalt - 8 : yabai -m space --focus 8 + #lalt - 9 : yabai -m space --focus 9 + + # go back to previous workspace (kind of like back_and_forth in i3) + lalt - 0 : yabai -m space --focus recent + + # move focused window to workspace + lalt + shift - 1 : yabai -m window --space 1 + lalt + shift - 2 : yabai -m window --space 2 + lalt + shift - 3 : yabai -m window --space 3 + lalt + shift - 4 : yabai -m window --space 4 + lalt + shift - 5 : yabai -m window --space 5 + lalt + shift - 6 : yabai -m window --space 6 + lalt + shift - 7 : yabai -m window --space 7 + lalt + shift - 8 : yabai -m window --space 8 + lalt + shift - 9 : yabai -m window --space 9 + ''; + }; + +}
diff --git a/machines/blechbuechse/darwin-configuration.nix b/machines/blechbuechse/darwin-configuration.nix @@ -8,15 +8,22 @@ in { imports = [ <home-manager/nix-darwin> - ../../modules/darwin/syncthing.nix - ../../modules/darwin/hidutil.nix - ../../modules/darwin/quirks.nix + ../../modules/darwin/quirks.nix ../../helpers/make-nixpkgs.nix - ./services/syncthing.nix ../../configurations/yubikey.nix - ../../configurations/homebrew.nix + + ../../configurations/darwin/systemSettings.nix + ../../configurations/darwin/appSettings.nix + ../../configurations/darwin/keyboard.nix + ../../configurations/darwin/trackpad.nix + ../../configurations/darwin/homebrew.nix + ../../configurations/darwin/finder.nix + ../../configurations/darwin/skhd.nix + ../../configurations/darwin/yabai.nix + ../../configurations/darwin/speakers.nix + ../../configurations/programs/cli/bash.nix ../../configurations/programs/cli/micro.nix ../../configurations/programs/cli/ssh.nix @@ -29,44 +36,13 @@ in { ../../configurations/programs/cli/network-utilities.nix ../../configurations/programs/cli/scripts.nix ../../configurations/programs/cli/garminexport.nix - ./yabai.nix - ./skhd.nix - ./speakers.nix + + ./syncthing.nix ]; nix.package = pkgs.nix; services.nix-daemon.enable = true; - hidutil = { - enable = true; - remapKeys = [ - { - # Internal keyboard - VendorID = "5ac"; - ProductID = "281"; - UserKeyMapping = [ - # Remap tilde on non-US keyboards - { HIDKeyboardModifierMappingSrc = 30064771172; HIDKeyboardModifierMappingDst = 30064771125; } - # Swap right_command and right_option - { HIDKeyboardModifierMappingSrc = 30064771303; HIDKeyboardModifierMappingDst = 30064771302; } - { HIDKeyboardModifierMappingSrc = 30064771302; HIDKeyboardModifierMappingDst = 30064771303; } - ]; - } - { - # Trackpoint Keyboard 2 - VendorID = "17ef"; - ProductID = "60ee"; - UserKeyMapping = [ - # Swap left_command and left_option - { HIDKeyboardModifierMappingSrc = 30064771299; HIDKeyboardModifierMappingDst = 30064771298; } - { HIDKeyboardModifierMappingSrc = 30064771298; HIDKeyboardModifierMappingDst = 30064771299; } - # Remap PrintScreen to left_command - { HIDKeyboardModifierMappingSrc = 30064771142; HIDKeyboardModifierMappingDst = 30064771299; } - ]; - } - ]; - }; - home-manager = { useUserPackages = true; @@ -74,13 +50,6 @@ in { users.leah.home.homeDirectory = lib.mkForce "/Users/leah/"; }; - fonts = { - fontDir.enable = true; - fonts = with pkgs; [ - iosevka-bin - ]; - }; - environment = { darwinConfig = "\$HOME/nixfiles/darwin-configuration.nix"; loginShell = "${pkgs.bashInteractive}/bin/bash"; @@ -93,146 +62,5 @@ in { networking.hostName = "blechbuechse"; networking.computerName = config.networking.hostName; - system.activationScripts.postActivation.text = '' - # Set the default shell to bash. MacOS doesn't do this like nixOS does - sudo chsh -s ${pkgs.bashInteractive}/bin/bash leah - - # Enable sudo Touch ID authentication, if not already enabled - if ! grep 'pam_tid.so' /etc/pam.d/sudo > /dev/null; then - sed -i "" '2i\ - auth sufficient pam_tid.so # use TouchID with sudo - ' /etc/pam.d/sudo - fi - ''; - - system.activationScripts.extraSystemSettings.text = '' - # Sleep display after 30 minutes - #sudo pmset -a displaysleep 30 - sudo systemsetup -settimezone "Europe/Berlin" > /dev/null - ''; - - system.activationScripts.extraUserActivation.text = '' - # Set accent color to green - defaults write .GlobalPreferences AppleAccentColor -int 3 - - # Show battery percentage in menubar - defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist BatteryShowPercentage -bool true - - # Show sound-applet always in menubar - defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist Sound -int 16 - - # Set menubar clock format - defaults write com.apple.menuextra.clock "DateFormat" -string "\"d MMM HH:mm:ss\"" - - # Flash clock time seperators - defaults write com.apple.menuextra.clock "FlashDateSeparators" -bool "true" - - # Set defaults for panes in Finder's "Get Info" - defaults write com.apple.finder FXInfoPanesExpanded -dict \ - General -bool true \ - OpenWith -bool true \ - Privileges -bool true \ - Preview -bool false - - # Disable iTerm's annoying promt when quitting it - defaults write com.googlecode.iterm2 PromptOnQuit -bool false - - # Disable RichText in TextEdit - defaults write com.apple.TextEdit RichText -int 0 - - # Open and save files as UTF-8 in TextEdit - defaults write com.apple.TextEdit PlainTextEncoding -int 4 - defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 - - # Prevent Photos from opening automatically when devices are plugged in - defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true - - # drag windows by holding CTRL + CMD and clicking anywhere in the window - # does not work with all applications - defaults write -g NSWindowShouldDragOnGesture -bool true - - # do not autogather large files when submitting a report - defaults write com.apple.appleseed.FeedbackAssistant "Autogather" -bool "false" - - # disable "Application Downloaded from Internet" popup - defaults write com.apple.LaunchServices "LSQuarantine" -bool "false" - - # disable animation when opening the info window in finder (CMD + I) - defaults write com.apple.finder DisableAllAnimations -bool true - ''; - - system.defaults = { - NSGlobalDomain = { - AppleInterfaceStyle = "Dark"; - AppleInterfaceStyleSwitchesAutomatically = false; - - AppleTemperatureUnit = "Celsius"; - AppleMeasurementUnits = "Centimeters"; - AppleMetricUnits = 1; - - AppleShowAllExtensions = true; - AppleShowScrollBars = "Always"; - - # navigate UI elements with keyboard (tab key) - AppleKeyboardUIMode = 3; - - "com.apple.sound.beep.volume" = "0.6"; - - NSTableViewDefaultSizeMode = 2; - - NSDocumentSaveNewDocumentsToCloud = false; - - NSNavPanelExpandedStateForSaveMode = true; - NSNavPanelExpandedStateForSaveMode2 = true; - - NSAutomaticCapitalizationEnabled = false; - NSAutomaticDashSubstitutionEnabled = false; - NSAutomaticPeriodSubstitutionEnabled = false; - NSAutomaticQuoteSubstitutionEnabled = false; - NSAutomaticSpellingCorrectionEnabled = false; - - }; - - dock = { - tilesize = 50; - minimize-to-application = true; - show-recents = false; - # Dont rearrange my workspaces automagicly, thanks - mru-spaces = false; - - # Disable all hot corners - wvous-tl-corner = 1; - wvous-tr-corner = 1; - wvous-bl-corner = 1; - wvous-br-corner = 1; - }; - - finder = { - AppleShowAllExtensions = true; - CreateDesktop = false; - ShowStatusBar = true; - ShowPathbar = false; - FXPreferredViewStyle = "Nlsv"; - FXDefaultSearchScope = "SCcf"; - FXEnableExtensionChangeWarning = false; - }; - - screencapture = { - disable-shadow = true; - location = "/Users/leah/Pictures/Screenshots"; - }; - - smb = { - NetBIOSName = config.networking.hostName; - ServerDescription = config.networking.hostName; - }; - - trackpad = { - FirstClickThreshold = 1; - SecondClickThreshold = 2; - }; - - }; - system.stateVersion = 4; }
diff --git a/machines/blechbuechse/services/syncthing.nix b/machines/blechbuechse/services/syncthing.nix @@ -1,20 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - syncthingConfig = import ../../../configurations/syncthing.nix { inherit pkgs; inherit config; inherit lib; }; - -in { - - services = { - syncthing = { - enable = true; - - user = "leah"; - group = "staff"; - - dataDir = syncthingConfig.dataDir; - devices = syncthingConfig.devices; - folders = syncthingConfig.folders; - }; - }; -}
diff --git a/machines/blechbuechse/syncthing.nix b/machines/blechbuechse/syncthing.nix @@ -0,0 +1,23 @@ +{ pkgs, config, lib, ... }: + +let + syncthingConfig = import ../../configurations/syncthing.nix { inherit pkgs; inherit config; inherit lib; }; + +in { + imports = [ + ../../modules/darwin/syncthing.nix + ]; + + services = { + syncthing = { + enable = true; + + user = "leah"; + group = "staff"; + + dataDir = syncthingConfig.dataDir; + devices = syncthingConfig.devices; + folders = syncthingConfig.folders; + }; + }; +}
diff --git a/machines/blechbuechse/yabai.nix b/machines/blechbuechse/yabai.nix @@ -1,144 +0,0 @@ -{ config, pkgs, ... }: - -let - yabai = pkgs.callPackage ../../pkgs/yabai.nix {}; - - toggleFloating = pkgs.writeScript "yabaiToggleFloating.sh" '' - #!/usr/bin/env bash - PATH=$(eval echo $PATH) - - # Toggle the workspace layout between float and bsp - read -r curType index <<< $(echo $(yabai -m query --spaces --space | jq '.type, .index')) - - if [ $curType = '"bsp"' ]; then - yabai -m space --layout float - osascript -e "display notification \"Change the layout of workspace $index to float\" with title \"yabai\"" - else - yabai -m space --layout bsp - osascript -e "display notification \"Change the layout of workspace $index to bsp\" with title \"yabai\"" - fi - ''; - -in { - - environment.etc."sudoers.d/yabai".text = '' - leah ALL = (root) NOPASSWD: ${yabai}/bin/yabai --load-sa - ''; - - services.yabai = { - enable = true; - # currently not working :'( - # enableScriptingAddition = true; - package = yabai; - config = { - layout = "float"; - - window_placement = "second_child"; - window_topmost = "off"; - window_shadow = "off"; - window_opacity = "off"; - -# focus_follows_mouse = "autofocus"; - mouse_follows_focus = "off"; - - mouse_modifier = "alt"; - mouse_action1 = "move"; - mouse_action2 = "resize"; - - }; - - extraConfig = '' - #sudo yabai --load-sa - - # load scripting-additions when Dock.app restarts - #yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa" - - # fix focus when closing windows - yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" - yabai -m signal --add event=application_terminated action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" - - # float system preferences - yabai -m rule --add app='^System Information$' manage=off layer=above - yabai -m rule --add app='^System Preferences$' manage=off layer=above - yabai -m rule --add title='Preferences$' manage=off layer=above - - # float settings and file windows - yabai -m rule --add title='Settings$' manage=off layer=above - yabai -m rule --add title='Opening$' manage=off layer=above - - # float Finder and AppStore - #yabai -m rule --add app='Finder' manage=off layer=above - #yabai -m rule --add app='App Store' manage=off layer=above - - #float firefox PiP window - #yabai -m rule --add label="Firfox PIP" app="^Firefox$" title="^(Picture-in-Picture)$" manage=off layer=above sticky=on - - yabai -m rule --add app='pinentry-mac' manage=off layer=above sticky=on - - #float Calculator - yabai -m rule --add app='Calculator' manage=off layer=above sticky=on - - yabai -m rule --add app='Firefox' space=1 - yabai -m rule --add app='Mail' space=2 - yabai -m rule --add app='Finder' space=6 - ''; - }; - - services.skhd = { - enable = true; - skhdConfig = '' - # kill focused window - lalt + shift - q : yabai -m window --close - - # float / unfloat window and center on screen - #lalt - space : yabai -m window --toggle float; yabai -m window --grid 4:4:1:1:2:2 - - # enter fullscreen mode for the focused window - lalt - f : yabai -m window --toggle zoom-fullscreen - - # change layout of desktop - lalt - e : ${toggleFloating} - - # rotate tree - lalt - r : yabai -m space --rotate 90 - - # change focus (using arrow keys) - lalt - left : yabai -m window --focus west - lalt - right : yabai -m window --focus east - lalt - down : yabai -m window --focus south - lalt - up : yabai -m window --focus north - - # move managed window - shift + lalt - left : yabai -m window --warp west - shift + lalt - right : yabai -m window --warp east - shift + lalt - down : yabai -m window --warp south - shift + lalt - up : yabai -m window --warp north - - # move between workspaces - #lalt - 1 : yabai -m space --focus 1 - #lalt - 2 : yabai -m space --focus 2 - #lalt - 3 : yabai -m space --focus 3 - #lalt - 4 : yabai -m space --focus 4 - #lalt - 5 : yabai -m space --focus 5 - #lalt - 6 : yabai -m space --focus 6 - #lalt - 7 : yabai -m space --focus 7 - #lalt - 8 : yabai -m space --focus 8 - #lalt - 9 : yabai -m space --focus 9 - - # go back to previous workspace (kind of like back_and_forth in i3) - lalt - 0 : yabai -m space --focus recent - - # move focused window to workspace - lalt + shift - 1 : yabai -m window --space 1 - lalt + shift - 2 : yabai -m window --space 2 - lalt + shift - 3 : yabai -m window --space 3 - lalt + shift - 4 : yabai -m window --space 4 - lalt + shift - 5 : yabai -m window --space 5 - lalt + shift - 6 : yabai -m window --space 6 - lalt + shift - 7 : yabai -m window --space 7 - lalt + shift - 8 : yabai -m window --space 8 - lalt + shift - 9 : yabai -m window --space 9 - ''; - }; - -}
diff --git a/machines/blechkasten/darwin-configuration.nix b/machines/blechkasten/darwin-configuration.nix @@ -8,15 +8,22 @@ in { imports = [ <home-manager/nix-darwin> - ../../modules/darwin/syncthing.nix - ../../modules/darwin/hidutil.nix - ../../modules/darwin/quirks.nix + ../../modules/darwin/quirks.nix ../../helpers/make-nixpkgs.nix - ./services/syncthing.nix ../../configurations/yubikey.nix - ../../configurations/homebrew.nix + + ../../configurations/darwin/systemSettings.nix + ../../configurations/darwin/appSettings.nix + ../../configurations/darwin/keyboard.nix + ../../configurations/darwin/trackpad.nix + ../../configurations/darwin/homebrew.nix + ../../configurations/darwin/finder.nix + ../../configurations/darwin/skhd.nix + ../../configurations/darwin/yabai.nix + ../../configurations/darwin/speakers.nix + ../../configurations/programs/cli/bash.nix ../../configurations/programs/cli/micro.nix ../../configurations/programs/cli/ssh.nix @@ -29,44 +36,13 @@ in { ../../configurations/programs/cli/network-utilities.nix ../../configurations/programs/cli/scripts.nix ../../configurations/programs/cli/garminexport.nix - ./yabai.nix - ./skhd.nix - ./speakers.nix + + ./syncthing.nix ]; nix.package = pkgs.nix; services.nix-daemon.enable = true; - hidutil = { - enable = true; - remapKeys = [ - { - # Internal keyboard - VendorID = "5ac"; - ProductID = "281"; - UserKeyMapping = [ - # Remap tilde on non-US keyboards - { HIDKeyboardModifierMappingSrc = 30064771172; HIDKeyboardModifierMappingDst = 30064771125; } - # Swap right_command and right_option - { HIDKeyboardModifierMappingSrc = 30064771303; HIDKeyboardModifierMappingDst = 30064771302; } - { HIDKeyboardModifierMappingSrc = 30064771302; HIDKeyboardModifierMappingDst = 30064771303; } - ]; - } - { - # Trackpoint Keyboard 2 - VendorID = "17ef"; - ProductID = "60ee"; - UserKeyMapping = [ - # Swap left_command and left_option - { HIDKeyboardModifierMappingSrc = 30064771299; HIDKeyboardModifierMappingDst = 30064771298; } - { HIDKeyboardModifierMappingSrc = 30064771298; HIDKeyboardModifierMappingDst = 30064771299; } - # Remap PrintScreen to left_command - { HIDKeyboardModifierMappingSrc = 30064771142; HIDKeyboardModifierMappingDst = 30064771299; } - ]; - } - ]; - }; - home-manager = { useUserPackages = true; @@ -74,13 +50,6 @@ in { users.leah.home.homeDirectory = lib.mkForce "/Users/leah/"; }; - fonts = { - fontDir.enable = true; - fonts = with pkgs; [ - iosevka-bin - ]; - }; - environment = { darwinConfig = "\$HOME/nixfiles/darwin-configuration.nix"; loginShell = "${pkgs.bashInteractive}/bin/bash"; @@ -93,146 +62,5 @@ in { networking.hostName = "blechkasten"; networking.computerName = config.networking.hostName; - system.activationScripts.postActivation.text = '' - # Set the default shell to bash. MacOS doesn't do this like nixOS does - sudo chsh -s ${pkgs.bashInteractive}/bin/bash leah - - # Enable sudo Touch ID authentication, if not already enabled - if ! grep 'pam_tid.so' /etc/pam.d/sudo > /dev/null; then - sed -i "" '2i\ - auth sufficient pam_tid.so # use TouchID with sudo - ' /etc/pam.d/sudo - fi - ''; - - system.activationScripts.extraSystemSettings.text = '' - # Sleep display after 30 minutes - #sudo pmset -a displaysleep 30 - sudo systemsetup -settimezone "Europe/Berlin" > /dev/null - ''; - - system.activationScripts.extraUserActivation.text = '' - # Set accent color to green - defaults write .GlobalPreferences AppleAccentColor -int 3 - - # Show battery percentage in menubar - defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist BatteryShowPercentage -bool true - - # Show sound-applet always in menubar - defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist Sound -int 16 - - # Set menubar clock format - defaults write com.apple.menuextra.clock "DateFormat" -string "\"d MMM HH:mm:ss\"" - - # Flash clock time seperators - defaults write com.apple.menuextra.clock "FlashDateSeparators" -bool "true" - - # Set defaults for panes in Finder's "Get Info" - defaults write com.apple.finder FXInfoPanesExpanded -dict \ - General -bool true \ - OpenWith -bool true \ - Privileges -bool true \ - Preview -bool false - - # Disable iTerm's annoying promt when quitting it - defaults write com.googlecode.iterm2 PromptOnQuit -bool false - - # Disable RichText in TextEdit - defaults write com.apple.TextEdit RichText -int 0 - - # Open and save files as UTF-8 in TextEdit - defaults write com.apple.TextEdit PlainTextEncoding -int 4 - defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 - - # Prevent Photos from opening automatically when devices are plugged in - defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true - - # drag windows by holding CTRL + CMD and clicking anywhere in the window - # does not work with all applications - defaults write -g NSWindowShouldDragOnGesture -bool true - - # do not autogather large files when submitting a report - defaults write com.apple.appleseed.FeedbackAssistant "Autogather" -bool "false" - - # disable "Application Downloaded from Internet" popup - defaults write com.apple.LaunchServices "LSQuarantine" -bool "false" - - # disable animation when opening the info window in finder (CMD + I) - defaults write com.apple.finder DisableAllAnimations -bool true - ''; - - system.defaults = { - NSGlobalDomain = { - AppleInterfaceStyle = "Dark"; - AppleInterfaceStyleSwitchesAutomatically = false; - - AppleTemperatureUnit = "Celsius"; - AppleMeasurementUnits = "Centimeters"; - AppleMetricUnits = 1; - - AppleShowAllExtensions = true; - AppleShowScrollBars = "Always"; - - # navigate UI elements with keyboard (tab key) - AppleKeyboardUIMode = 3; - - "com.apple.sound.beep.volume" = "0.6"; - - NSTableViewDefaultSizeMode = 2; - - NSDocumentSaveNewDocumentsToCloud = false; - - NSNavPanelExpandedStateForSaveMode = true; - NSNavPanelExpandedStateForSaveMode2 = true; - - NSAutomaticCapitalizationEnabled = false; - NSAutomaticDashSubstitutionEnabled = false; - NSAutomaticPeriodSubstitutionEnabled = false; - NSAutomaticQuoteSubstitutionEnabled = false; - NSAutomaticSpellingCorrectionEnabled = false; - - }; - - dock = { - tilesize = 50; - minimize-to-application = true; - show-recents = false; - # Dont rearrange my workspaces automagicly, thanks - mru-spaces = false; - - # Disable all hot corners - wvous-tl-corner = 1; - wvous-tr-corner = 1; - wvous-bl-corner = 1; - wvous-br-corner = 1; - }; - - finder = { - AppleShowAllExtensions = true; - CreateDesktop = false; - ShowStatusBar = true; - ShowPathbar = false; - FXPreferredViewStyle = "Nlsv"; - FXDefaultSearchScope = "SCcf"; - FXEnableExtensionChangeWarning = false; - }; - - screencapture = { - disable-shadow = true; - location = "/Users/leah/Pictures/Screenshots"; - }; - - smb = { - NetBIOSName = config.networking.hostName; - ServerDescription = config.networking.hostName; - }; - - trackpad = { - FirstClickThreshold = 1; - SecondClickThreshold = 2; - }; - - }; - system.stateVersion = 4; }
diff --git a/machines/blechkasten/services/syncthing.nix b/machines/blechkasten/services/syncthing.nix @@ -1,20 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - syncthingConfig = import ../../../configurations/syncthing.nix { inherit pkgs; inherit config; inherit lib; }; - -in { - - services = { - syncthing = { - enable = true; - - user = "leah"; - group = "staff"; - - dataDir = syncthingConfig.dataDir; - devices = syncthingConfig.devices; - folders = syncthingConfig.folders; - }; - }; -}
diff --git a/machines/blechkasten/skhd.nix b/machines/blechkasten/skhd.nix @@ -1,47 +0,0 @@ -{ config, pkgs, ... }: - -let - newTerminal = pkgs.writeScript "newTerminalWindow.sh" '' - #!/usr/bin/env bash - # Open iTerm2 with single instance - - # Detects if iTerm2 is running - if ! pgrep -f "iTerm" > /dev/null; then - open -a "$HOME/Applications/iTerm.app" - else - # Create a new window - if ! osascript -e 'tell application "iTerm2" to create window with default profile' > /dev/null; then - # Get pids for any app with "iTerm" and kill - for i in $(pgrep -f "iTerm"); do kill -15 "$i"; done - open -a "$HOME/Applications/iTerm.app" - fi - fi - ''; - -in { - - home-manager.users.leah.home.packages = [ pkgs.skhd ]; - - services.skhd = { - enable = true; - skhdConfig = '' - # spawn new terminal window - lalt - return : ${newTerminal} - - # sleep - lalt - z : pmset sleepnow - - # switch between workspaces - lalt - 1 : ${pkgs.skhd}/bin/skhd -k "ctrl - 1" - lalt - 2 : ${pkgs.skhd}/bin/skhd -k "ctrl - 2" - lalt - 3 : ${pkgs.skhd}/bin/skhd -k "ctrl - 3" - lalt - 4 : ${pkgs.skhd}/bin/skhd -k "ctrl - 4" - lalt - 5 : ${pkgs.skhd}/bin/skhd -k "ctrl - 5" - lalt - 6 : ${pkgs.skhd}/bin/skhd -k "ctrl - 6" - lalt - 7 : ${pkgs.skhd}/bin/skhd -k "ctrl - 7" - lalt - 8 : ${pkgs.skhd}/bin/skhd -k "ctrl - 8" - lalt - 9 : ${pkgs.skhd}/bin/skhd -k "ctrl - 9" - ''; - }; - -}
diff --git a/machines/blechkasten/speakers.nix b/machines/blechkasten/speakers.nix @@ -1,30 +0,0 @@ -{ config, pkgs, lib, ... }: - -let - secrets = import ../../secrets; - SpeakerDaemon = pkgs.callPackage ../../pkgs/SpeakerDaemon {}; - switchSpeakers = pkgs.writeScript "switchSpeakers.sh" '' - #!/usr/bin/env bash - - curl -d '{"accessToken": "${secrets.hosts.lollo.smartied.accessToken}", "type": "SwitchStateAction", "deviceName": "modbus-20", "relay": 0, "toggle": true}' http://10.0.0.1:5000 - ''; - -in { - - services.skhd = { - enable = true; - skhdConfig = '' - # Switch speakers - lalt - delete : ${switchSpeakers} - ''; - }; - - launchd.user.agents.SpeakerDaemon = { - path = [ config.environment.systemPath ]; - - serviceConfig = { - ProgramArguments = [ "${SpeakerDaemon}/bin/SpeakerDaemon" ]; - KeepAlive = true; - }; - }; -}
diff --git a/machines/blechkasten/syncthing.nix b/machines/blechkasten/syncthing.nix @@ -0,0 +1,23 @@ +{ pkgs, config, lib, ... }: + +let + syncthingConfig = import ../../configurations/syncthing.nix { inherit pkgs; inherit config; inherit lib; }; + +in { + imports = [ + ../../modules/darwin/syncthing.nix + ]; + + services = { + syncthing = { + enable = true; + + user = "leah"; + group = "staff"; + + dataDir = syncthingConfig.dataDir; + devices = syncthingConfig.devices; + folders = syncthingConfig.folders; + }; + }; +}
diff --git a/machines/blechkasten/yabai.nix b/machines/blechkasten/yabai.nix @@ -1,144 +0,0 @@ -{ config, pkgs, ... }: - -let - yabai = pkgs.callPackage ../../pkgs/yabai.nix {}; - - toggleFloating = pkgs.writeScript "yabaiToggleFloating.sh" '' - #!/usr/bin/env bash - PATH=$(eval echo $PATH) - - # Toggle the workspace layout between float and bsp - read -r curType index <<< $(echo $(yabai -m query --spaces --space | jq '.type, .index')) - - if [ $curType = '"bsp"' ]; then - yabai -m space --layout float - osascript -e "display notification \"Change the layout of workspace $index to float\" with title \"yabai\"" - else - yabai -m space --layout bsp - osascript -e "display notification \"Change the layout of workspace $index to bsp\" with title \"yabai\"" - fi - ''; - -in { - - environment.etc."sudoers.d/yabai".text = '' - leah ALL = (root) NOPASSWD: ${yabai}/bin/yabai --load-sa - ''; - - services.yabai = { - enable = true; - # currently not working :'( - # enableScriptingAddition = true; - package = yabai; - config = { - layout = "float"; - - window_placement = "second_child"; - window_topmost = "off"; - window_shadow = "off"; - window_opacity = "off"; - -# focus_follows_mouse = "autofocus"; - mouse_follows_focus = "off"; - - mouse_modifier = "alt"; - mouse_action1 = "move"; - mouse_action2 = "resize"; - - }; - - extraConfig = '' - #sudo yabai --load-sa - - # load scripting-additions when Dock.app restarts - #yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa" - - # fix focus when closing windows - yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" - yabai -m signal --add event=application_terminated action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" - - # float system preferences - yabai -m rule --add app='^System Information$' manage=off layer=above - yabai -m rule --add app='^System Preferences$' manage=off layer=above - yabai -m rule --add title='Preferences$' manage=off layer=above - - # float settings and file windows - yabai -m rule --add title='Settings$' manage=off layer=above - yabai -m rule --add title='Opening$' manage=off layer=above - - # float Finder and AppStore - #yabai -m rule --add app='Finder' manage=off layer=above - #yabai -m rule --add app='App Store' manage=off layer=above - - #float firefox PiP window - #yabai -m rule --add label="Firfox PIP" app="^Firefox$" title="^(Picture-in-Picture)$" manage=off layer=above sticky=on - - yabai -m rule --add app='pinentry-mac' manage=off layer=above sticky=on - - #float Calculator - yabai -m rule --add app='Calculator' manage=off layer=above sticky=on - - yabai -m rule --add app='Firefox' space=1 - yabai -m rule --add app='Mail' space=2 - yabai -m rule --add app='Finder' space=6 - ''; - }; - - services.skhd = { - enable = true; - skhdConfig = '' - # kill focused window - lalt + shift - q : yabai -m window --close - - # float / unfloat window and center on screen - #lalt - space : yabai -m window --toggle float; yabai -m window --grid 4:4:1:1:2:2 - - # enter fullscreen mode for the focused window - lalt - f : yabai -m window --toggle zoom-fullscreen - - # change layout of desktop - lalt - e : ${toggleFloating} - - # rotate tree - lalt - r : yabai -m space --rotate 90 - - # change focus (using arrow keys) - lalt - left : yabai -m window --focus west - lalt - right : yabai -m window --focus east - lalt - down : yabai -m window --focus south - lalt - up : yabai -m window --focus north - - # move managed window - shift + lalt - left : yabai -m window --warp west - shift + lalt - right : yabai -m window --warp east - shift + lalt - down : yabai -m window --warp south - shift + lalt - up : yabai -m window --warp north - - # move between workspaces - #lalt - 1 : yabai -m space --focus 1 - #lalt - 2 : yabai -m space --focus 2 - #lalt - 3 : yabai -m space --focus 3 - #lalt - 4 : yabai -m space --focus 4 - #lalt - 5 : yabai -m space --focus 5 - #lalt - 6 : yabai -m space --focus 6 - #lalt - 7 : yabai -m space --focus 7 - #lalt - 8 : yabai -m space --focus 8 - #lalt - 9 : yabai -m space --focus 9 - - # go back to previous workspace (kind of like back_and_forth in i3) - lalt - 0 : yabai -m space --focus recent - - # move focused window to workspace - lalt + shift - 1 : yabai -m window --space 1 - lalt + shift - 2 : yabai -m window --space 2 - lalt + shift - 3 : yabai -m window --space 3 - lalt + shift - 4 : yabai -m window --space 4 - lalt + shift - 5 : yabai -m window --space 5 - lalt + shift - 6 : yabai -m window --space 6 - lalt + shift - 7 : yabai -m window --space 7 - lalt + shift - 8 : yabai -m window --space 8 - lalt + shift - 9 : yabai -m window --space 9 - ''; - }; - -}