From 89e2e52e44ca03d4508eb97d4f417af27070ed73 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 15 Jun 2022 08:14:01 -0400 Subject: [PATCH] separate hammerspoon and add installation instructions --- darwin_setup.sh | 93 ++++++++++++++++++++++++++++++++++ modules/darwin/default.nix | 2 +- modules/darwin/hammerspoon.nix | 15 ++++++ modules/darwin/homebrew.nix | 41 +++++++-------- modules/darwin/system.nix | 1 + modules/darwin/utilities.nix | 6 --- 6 files changed, 129 insertions(+), 29 deletions(-) create mode 100755 darwin_setup.sh create mode 100644 modules/darwin/hammerspoon.nix diff --git a/darwin_setup.sh b/darwin_setup.sh new file mode 100755 index 0000000..9ae3a38 --- /dev/null +++ b/darwin_setup.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +# List brews +brew list --formula + +# List dependencies +brew list -1 | while read -r cask; do + echo -ne "\x1B[1;34m $cask \x1B[0m" + brew uses "$cask" --installed | awk '{printf(" %s ", $0)}' + echo "" +done + +# Uninstall brews +brew remove --force "$(brew list --formula)" +brew remove --force sd +brew remove --force zoxide +brew remove --force bat +brew remove --force fzf +brew remove --force tealdeer +brew remove --force glow +brew remove --force dos2unix +brew remove --force tree +brew remove --force wget +brew remove --force telnet +brew remove --force prettyping +brew remove --force httpie +brew remove --force gpg +brew remove --force qrencode +brew remove --force mpv +brew remove --force youtube-dl +brew remove --force pandoc +brew remove --force saulpw/vd/visidata +brew remove --force mdp +brew remove --force ansible +brew remove --force terraform +brew remove --force packer +brew remove --force awscli +brew remove --force kubectl +brew remove --force k9s +brew remove --force nmasur/repo/drips +brew remove --force hashicorp/tap/terraform-ls +brew remove --force tflint +brew remove --force noti +brew remove --force awslogs +brew remove --force shellcheck +brew remove --force shfmt +brew remove --force stylua +brew remove --force python +brew remove --force ipython +brew remove --force poetry +brew remove --force ruby +brew remove --force node +brew remove --force jq +brew remove --force gh +brew remove --force direnv +brew remove --force git +brew remove --force ripgrep +brew remove --force fd +brew remove --force neovim +brew remove --force exa +brew remove --force starship +brew remove --force tmux +brew remove --force fish +# brew remove --force trash + +# Uninstall casks +brew remove --force keybase +brew remove --force discord +brew remove --force obsidian +brew remove --force dropbox +brew remove --force 1password +brew remove --force firefox +brew remove --force font-fira-mono-nerd-font +brew remove --force alacritty +# brew remove --force scroll-reverser +# brew remove --force meetingbar +# brew remove --force gitify +# brew remove --force hammerspoon +# brew remove --force logitech-g-hub + +# Uninstall homebrew +bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" + +# Install Nix +sh -c "$(curl -L https://nixos.org/nix/install)" + +# Install nix-darwin +nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer +./result/bin/darwin-installer + +# Use with flake (requires installing first) +darwin-rebuild switch --flake . +darwin-rebuild switch --flake .#macbook # not sure if required diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 89cbd12..636bc24 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,5 +1,5 @@ { ... }: { - imports = [ ./system.nix ./tmux.nix ./utilities.nix ]; + imports = [ ./system.nix ./tmux.nix ./utilities.nix ./hammerspoon.nix ]; } diff --git a/modules/darwin/hammerspoon.nix b/modules/darwin/hammerspoon.nix new file mode 100644 index 0000000..0de0817 --- /dev/null +++ b/modules/darwin/hammerspoon.nix @@ -0,0 +1,15 @@ +{ config, ... }: { + + # Hammerspoon - MacOS custom automation scripting + + home-manager.users.${config.user} = { + xdg.configFile.hammerspoon = { source = ./hammerspoon; }; + }; + + homebrew.casks = [ "hammerspoon" ]; + + system.activationScripts.hammerspoon.text = '' + defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua" + ''; + +} diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index 770d55f..af99db8 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -1,26 +1,23 @@ -{ config, ... }: { +{ ... }: { - home-manager.users.${config.user} = { - homebrew = { - enable = true; - autoUpdate = false; # Don't update during rebuild - cleanup = "zap"; # Uninstall all programs not declared - taps = [ - "homebrew/cask-drivers" # Used for Logitech G-Hub - ]; - brews = [ - "trash" # Delete files and folders to trash instead of rm - ]; - casks = [ - "scroll-reverser" # Different scroll style for mouse vs. trackpad - "meetingbar" # Show meetings in menu bar - "gitify" # Git notifications in menu bar - "hammerspoon" # MacOS custom automation scripting - "logitech-g-hub" # Mouse and keyboard management - ]; - global.brewfile = true; # Run brew bundle from anywhere - global.nolock = true; # Don't save lockfile (since running from anywhere) - }; + homebrew = { + enable = true; + autoUpdate = false; # Don't update during rebuild + cleanup = "zap"; # Uninstall all programs not declared + taps = [ + "homebrew/cask-drivers" # Used for Logitech G-Hub + ]; + brews = [ + "trash" # Delete files and folders to trash instead of rm + ]; + casks = [ + "scroll-reverser" # Different scroll style for mouse vs. trackpad + "meetingbar" # Show meetings in menu bar + "gitify" # Git notifications in menu bar + "logitech-g-hub" # Mouse and keyboard management + ]; + global.brewfile = true; # Run brew bundle from anywhere + global.nolock = true; # Don't save lockfile (since running from anywhere) }; } diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index 700b555..2fc3f42 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -109,6 +109,7 @@ }; + # Settings that don't have an option in nix-darwin activationScripts.otherSettings.text = '' echo "Disable disk image verification" defaults write com.apple.frameworks.diskimages skip-verify -bool true diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index f085c32..9b3c9eb 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -35,12 +35,6 @@ fonts.fonts = with pkgs; [ (nerdfonts.override { fonts = [ "fira-mono" ]; }) ]; - xdg.configFile.hammerspoon = { source = ./hammerspoon; }; - }; - system.activationScripts.hammerspoon.text = '' - defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua" - ''; - }