Skip to content

Commit

Permalink
Manage Homebrew via nix
Browse files Browse the repository at this point in the history
nix is now managing all Homebrew taps, casks and brews.

Rake tasks have been updated to only apply config and to no longer
install any apps or services using the `brew` command.

Signed-off-by: Stephen Hoekstra <[email protected]>
  • Loading branch information
shoekstra committed May 7, 2023
1 parent 4c7ae7f commit 1cd2dcc
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 105 deletions.
12 changes: 10 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ require "rubocop/rake_task"
Rake::TaskManager.record_task_metadata = true
Rake.add_rakelib "lib/tasks"

desc "install EVERYTHING"
desc "install Homebrew"
task :install do
require "got_files/homebrew"

homebrew = GotFiles::Homebrew.new
homebrew.install
end

desc "setup EVERYTHING"
task :setup do
require "highline/import"

Rake.application.in_namespace(:install) do |namespace|
Rake.application.in_namespace(:setup) do |namespace|
namespace.tasks.sort_by(&:name).each do |t|
Rake::Task[t.name].invoke if HighLine.agree("#{t.comment.capitalize}? ")
end
Expand Down
10 changes: 0 additions & 10 deletions files/homebrew/Brewfile

This file was deleted.

16 changes: 0 additions & 16 deletions lib/got_files/homebrew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

module GotFiles
class Homebrew < Base
def bundle_install
Dir.chdir(File.expand_path("~")) do
system("brew bundle")
end
end

def install
return if installed?

Expand All @@ -19,15 +13,5 @@ def install
def installed?
command_exist?("brew")
end

def update_brewfile
Dir.chdir(File.expand_path("~")) do
system("brew bundle dump --force")
end
end

def setup
install_file "files/homebrew/Brewfile", false
end
end
end
12 changes: 1 addition & 11 deletions lib/got_files/neovim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@

module GotFiles
class Neovim < Base
def install
puts "Checking for dependencies..."

brew_install_if_missing("cmake", "CMake")
brew_install_if_missing("go", "Golang")
brew_install_if_missing("python", "Python 3")

brew_install_if_missing("neovim", "Neovim")

def setup
system("pip3 install --upgrade pynvim --user", out: File::NULL)
system("pip3 install --upgrade neovim --user", out: File::NULL)
end

def setup
system('defaults write com.googlecode.iterm2 "Draw Powerline Glyphs" -bool true')

mkdir_p File.expand_path("~/.config/nvim/backup")
Expand Down
19 changes: 5 additions & 14 deletions lib/got_files/terminal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@

module GotFiles
class Terminal < Base
def install
brew_cask_install_if_missing("iterm2", "iTerm2")

brew_install_if_missing("coreutils") # required gdircolors and gls
brew_install_if_missing("ccat", "ccat")

install_fzf
install_zim
end

def setup
setup_fzf
setup_zim

# Use gnu dircolors and ls
%w[dircolors ls].each do |f|
symlink("/usr/local/bin/g#{f}",
Expand Down Expand Up @@ -42,14 +35,12 @@ def setup

private

def install_fzf
brew_install_if_missing("fzf", "fzf")

def setup_fzf
system("$(brew --prefix)/opt/fzf/install --key-bindings --no-update-rc --no-bash --no-fish --completion",
out: File::NULL)
end

def install_zim
def setup_zim
unless File.exist?(File.join(ENV["HOME"], ".zim"))
system("curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh")
end
Expand Down
7 changes: 1 addition & 6 deletions lib/got_files/tmux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@

module GotFiles
class Tmux < Base
def install
brew_install_if_missing("reattach-to-user-namespace")
brew_install_if_missing("tmux", "Tmux")

def setup
git("https://github.com/gpakosz/.tmux.git",
"#{ENV['HOME']}/.tmux",
"Oh My Tmux!")

git("https://github.com/tmux-plugins/tpm",
"#{ENV['HOME']}/.tmux/plugins/tpm",
"Tmux Plugin Manager")
end

def setup
install_file %w[~/.tmux/.tmux.conf files/tmux/tmux.conf.local]

run %(tmux source ~/.tmux.conf) if ENV["TMUX"]
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/gpg.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

namespace "install" do
desc "install and setup GPG Agent (and optionally import an exported key)"
namespace "setup" do
desc "import a key"
task :gpg, [:key_to_import] do |_t, args|
require "got_files/Gpg"

Expand Down
30 changes: 0 additions & 30 deletions lib/tasks/homebrew.rake

This file was deleted.

5 changes: 2 additions & 3 deletions lib/tasks/neovim.rake
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

namespace "install" do
desc "install and setup Neovim"
namespace "setup" do
desc "setup Neovim"
task :neovim do
require "got_files/neovim"

neovim = GotFiles::Neovim.new
neovim.install
neovim.setup
end
end
5 changes: 2 additions & 3 deletions lib/tasks/terminal.rake
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

namespace "install" do
desc "install and setup terminal and shell experience"
namespace "setup" do
desc "setup terminal and shell experience"
task :terminal do
require "got_files/terminal"

terminal = GotFiles::Terminal.new
terminal.install
terminal.setup
end
end
5 changes: 2 additions & 3 deletions lib/tasks/tmux.rake
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

namespace "install" do
desc "install and setup Tmux"
namespace "setup" do
desc "setup Tmux"
task :tmux do
require "got_files/tmux"

tmux = GotFiles::Tmux.new
tmux.install
tmux.setup
end
end
14 changes: 9 additions & 5 deletions nix/hosts/sbpltt6cllvdl/default.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{ pkgs, ... }:

{
let
imports = [
./homebrew.nix
];

in {

inherit imports;

# Make sure the nix daemon always runs
services.nix-daemon.enable = true;

# If you use zsh you'll need to enable this so nix-darwin creates a zshrc sourcing needed environment changes
programs.zsh.enable = true;

homebrew.enable = true;
homebrew.casks = [
];

home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users."shoekstra" = import ./home.nix;
Expand Down
Loading

0 comments on commit 1cd2dcc

Please sign in to comment.