From 388e50d9d495ccee61a11fa7f25ae36cf3bd0e85 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Jun 2022 17:46:26 -0400 Subject: [PATCH] start adding macos configuration --- flake.lock | 22 +++++ flake.nix | 16 +++- hosts/macbook/default.nix | 18 ++++ modules/darwin/system.nix | 178 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 232 insertions(+), 2 deletions(-) create mode 100644 hosts/macbook/default.nix create mode 100644 modules/darwin/system.nix diff --git a/flake.lock b/flake.lock index 4525a75..a09d1fc 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1651916036, + "narHash": "sha256-UuD9keUGm4IuVEV6wdSYbuRm7CwfXE63hVkzKDjVsh4=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "2f2bdf658d2b79bada78dc914af99c53cad37cba", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -54,6 +75,7 @@ }, "root": { "inputs": { + "darwin": "darwin", "home-manager": "home-manager", "nixpkgs": "nixpkgs", "nur": "nur" diff --git a/flake.nix b/flake.nix index 57cf519..cea1bdc 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,12 @@ # Used for system packages nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + # Used for MacOS system config + darwin = { + url = "github:/lnl7/nix-darwin/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # Used for user packages home-manager = { url = "github:nix-community/home-manager/master"; @@ -19,7 +25,7 @@ }; - outputs = { self, nixpkgs, home-manager, nur }: + outputs = { self, nixpkgs, darwin, home-manager, nur }: let @@ -56,7 +62,13 @@ import ./hosts/desktop { inherit nixpkgs home-manager nur globals; }; }; - # You can partition, format, and install with: + darwinConfigurations = { + macbook = import ./hosts/macbook { + inherit nixpkgs darwin home-manager nur globals; + }; + }; + + # You can partition, format, and install from a live disk with: # nix-shell -p nixFlakes # nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop # Will erase drives; use at your own risk! diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix new file mode 100644 index 0000000..2dbe287 --- /dev/null +++ b/hosts/macbook/default.nix @@ -0,0 +1,18 @@ +{ nixpkgs, darwin, home-manager, nur, globals, ... }: + +# System configuration for my MacBook +darwin.lib.darwinSystem { + system = "x86_64-darwin"; + specialArgs = { }; + modules = [ + globals + home-manager.darwinModules.home-manager + { + networking.hostName = "desktop"; + gui.enable = true; + gui.compositor.enable = true; + nixpkgs.overlays = [ nur.overlay ]; + } + ../common.nix + ]; +} diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix new file mode 100644 index 0000000..02123ec --- /dev/null +++ b/modules/darwin/system.nix @@ -0,0 +1,178 @@ +{ ... }: { + + system = { + + keyboard = { + remapCapsLockToControl = true; + enableKeyMapping = true; # Allows for skhd + }; + + defaults = { + NSGlobalDomain = { + + # Set to dark mode + AppleInterfaceStyle = "Dark"; + + # Don't change from dark to light automatically + AppleInterfaceSwitchesAutomatically = false; + + # Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs) + AppleKeyboardUIMode = 3; + + # Automatically show and hide the menu bar + _HIHideMenuBar = true; + + # Expand save panel by default + NSNavPanelExpandedStateForSaveMode = true; + + # Expand print panel by default + PMPrintingExpandedStateForPrint = true; + + # Replace press-and-hold with key repeat + ApplePressAndHoldEnabled = false; + + # Set a fast key repeat rate + KeyRepeat = 2; + + # Shorten delay before key repeat begins + InitialKeyRepeat = 12; + + # Save to local disk by default, not iCloud + NSDocumentSaveNewDocumentsToCloud = false; + + # Disable autocorrect capitalization + NSAutomaticCapitalizationEnabled = false; + + # Disable autocorrect smart dashes + NSAutomaticDashSubstitutionEnabled = false; + + # Disable autocorrect adding periods + NSAutomaticPeriodSubstitutionEnabled = false; + + # Disable autocorrect smart quotation marks + NSAutomaticQuoteSubstitutionEnabled = false; + + # Disable autocorrect spellcheck + NSAutomaticSpellingCorrectionEnabled = false; + }; + + dock = { + # Automatically show and hide the dock + autohide = true; + + # Add translucency in dock for hidden applications + showhidden = true; + + # Enable spring loading on all dock items + enable-spring-load-actions-on-all-items = true; + + # Highlight hover effect in dock stack grid view + mouse-over-hilite-stack = true; + + mineffect = "genie"; + orientation = "bottom"; + show-recents = false; + tilesize = 44; + }; + + finder = { + + # Default Finder window set to column view + FXPreferredViewStyle = "clmv"; + + # Finder search in current folder by default + FXDefaultSearchScope = "SCcf"; + + # Disable warning when changing file extension + FXEnableExtensionChangeWarning = false; + + # Allow quitting of Finder application + QuitMenuItem = true; + + }; + + # Disable "Are you sure you want to open" dialog + LaunchServices.LSQuarantine = false; + + # Disable trackpad tap to click + trackpad.Clicking = false; + + universalaccess = { + + # Zoom in with Control + Scroll Wheel + closeViewScrollWheelToggle = true; + closeViewZoomFollowsFocus = true; + }; + + # Where to save screenshots + screencapture.location = "~/Downloads"; + + }; + }; + + # echo "Disable disk image verification" + # defaults write com.apple.frameworks.diskimages skip-verify -bool true + # defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true + # defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true + # + # echo "Avoid creating .DS_Store files on network volumes" + # defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true + # + # # echo "Enable snap-to-grid for desktop icons" + # # /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist + # + # echo "Disable the warning before emptying the Trash" + # defaults write com.apple.finder WarnOnEmptyTrash -bool false + # + # echo "Require password immediately after sleep or screen saver begins" + # defaults write com.apple.screensaver askForPassword -int 1 + # defaults write com.apple.screensaver askForPasswordDelay -int 0 + # + # echo "Show the ~/Library folder" + # chflags nohidden ~/Library && xattr -d com.apple.FinderInfo ~/Library + # + # # Noah Prefs + # echo "Enable dock magnification" + # defaults write com.apple.dock magnification -bool true + # + # echo "Set dock size" + # defaults write com.apple.dock largesize -int 48 + # + # echo "Choose and order dock icons" + # __dock_item() { + # printf '%s%s%s%s%s' \ + # 'tile-datafile-data' \ + # '_CFURLString' \ + # "$1" \ + # '_CFURLStringType0' \ + # '' + # } + # + # defaults write com.apple.dock persistent-apps -array \ + # "$(__dock_item /Applications/1Password\ 7.app)" \ + # "$(__dock_item /Applications/Slack.app)" \ + # "$(__dock_item /System/Applications/Calendar.app)" \ + # "$(__dock_item /Applications/Firefox.app)" \ + # "$(__dock_item /System/Applications/Messages.app)" \ + # "$(__dock_item /System/Applications/Mail.app)" \ + # "$(__dock_item /Applications/Mimestream.app)" \ + # "$(__dock_item /Applications/zoom.us.app)" \ + # "$(__dock_item /Applications/Obsidian.app)" \ + # "$(__dock_item /Applications/Alacritty.app)" \ + # "$(__dock_item /System/Applications/System\ Preferences.app)" + # + # echo "Turn on Scroll Reverser" + # open /Applications/Scroll\ Reverser.app + # osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Applications/Scroll Reverser.app", hidden:false}' + # + # echo "Allow apps from anywhere" + # SPCTL=$(spctl --status) + # if ! [ "$SPCTL" = "assessments disabled" ] + # then + # sudo spctl --master-disable + # fi + # + # echo "Show the ~/Library folder" + # chflags nohidden ~/Library + +}