Skip to content

Commit

Permalink
refactor: move brew to nix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Nov 7, 2023
1 parent eba4766 commit d95b661
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 183 deletions.
5 changes: 3 additions & 2 deletions .config/nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

outputs = inputs: {
darwinConfigurations.tmm = inputs.darwin.lib.darwinSystem {
system = "aarch64-darwin";
system = "aarch64-darwin";
pkgs = import inputs.nixpkgs { system = "aarch64-darwin"; };
modules = [
./modules/darwin.nix
inputs.home-manager.darwinModules.home-manager {
inputs.home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
Expand Down
42 changes: 37 additions & 5 deletions .config/nix/modules/darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,38 @@
NEXT_TELEMETRY_DISABLED = "1";
};
};
fonts.fontDir.enable = true;
fonts.fonts = [ (pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) ];
fonts = {
fontDir.enable = true;
fonts = [ (pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) ];
};
homebrew = {
enable = true;
masApps = {
BetterSnapTool = 417375580;
Craft = 1487937127;
Dato = 1470584107;
"Day One" = 1055511498;
"Pure Paste" = 1611378436;
Velja = 1607635845;
Xcode = 497799835;
};
casks = [
"1password"
"1password-cli"
"betterdisplay"
"cleanshot"
"contexts"
"daisydisk"
"dropbox"
"firefox"
"flux"
"google-chrome"
"numi"
"pixelsnap"
"raycast"
"remarkable"
];
};
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
Expand All @@ -21,7 +51,7 @@
dock.mineffect = "scale";
dock.show-process-indicators = true;
dock.tilesize = 48;
finder._FXShowPosixPathInTitle= true;
finder._FXShowPosixPathInTitle = true;
finder.AppleShowAllExtensions = true;
finder.FXEnableExtensionChangeWarning = false;
finder.FXPreferredViewStyle = "Nlsv";
Expand All @@ -35,8 +65,10 @@
NSGlobalDomain.InitialKeyRepeat = 14;
NSGlobalDomain.KeyRepeat = 1;
};
system.keyboard.enableKeyMapping = true;
system.keyboard.remapCapsLockToEscape = true;
system.keyboard = {
enableKeyMapping = true;
remapCapsLockToEscape = true;
};
users.users.tmm = {
home = "/Users/tmm";
shell = pkgs.fish;
Expand Down
98 changes: 52 additions & 46 deletions .config/nix/modules/home-manager.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{ pkgs, ... }: {
home.packages = with pkgs; [
babelfish # Translate bash scripts to fish (https://github.com/bouk/babelfish)
bat # Better `cat` (https://github.com/sharkdp/bat)
diff-so-fancy # Readable diffs (https://github.com/so-fancy/diff-so-fancy)
direnv # Project-based env variables (https://github.com/direnv/direnv)
dockutil # Manage dock items (https://github.com/kcrawford/dockutil)
eza # Better `ls` (https://github.com/eza-community/eza)
fd # Better `find` (https://github.com/sharkdp/fd)
fnm # Fast Node.js version manager (https://github.com/Schniz/fnm)
fzf # Fuzzy finder (https://github.com/junegunn/fzf)
babelfish
bat
diff-so-fancy
direnv
dockutil
eza
fd
fnm
fzf
git
gh # GitHub CLI (https://cli.github.com)
jq # JSON CLI (https://github.com/stedolan/jq)
neovim # Better `vim` (https://github.com/neovim/neovim)
ripgrep # Better `grep` (https://github.com/BurntSushi/ripgrep)
zoxide # Smarter `cd` (https://github.com/ajeetdsouza/zoxide)
gh
jq
neovim
ripgrep
zoxide
];
home.stateVersion = "23.05";
home.sessionVariables = {
Expand Down Expand Up @@ -119,52 +119,58 @@
p = "pnpm";
t = "tmux";
v = "nvim";

tn = "tmux new -s";
ta = "tmux a -t";
tks = "tmux kill-server";
tls = "tmux ls";
};
shellAliases = {
cat="bat --style=numbers,changes --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo tokyonight_night || echo tokyonight_day)";
find="fd";
fup="echo $fish_user_paths | tr \" \" \"\n\" | nl";
h="env GIT_WORK_TREE=$HOME GIT_DIR=$HOME/.files";
ls="eza";
reload="exec $SHELL -l"; vim="nvim"; hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder";
show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder";

hrc="nvim ~/.config/home-manager/home.nix";

hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder";
showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder";
cat = "bat --style=numbers,changes --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo tokyonight_night || echo tokyonight_day)";
find = "fd";
fup = "echo $fish_user_paths | tr \" \" \"\n\" | nl";
h = "env GIT_WORK_TREE=$HOME GIT_DIR=$HOME/.files";
ls = "eza";
reload = "exec $SHELL -l";
vim = "nvim";
hide = "defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder";
show = "defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder";

nconf = "nvim ~/.config/nix/flake.nix";
vconf = "nvim ~/.config/nvim/init.lua";
drs = "darwin-rebuild switch --flake ~/.config/nix/";

hidedesktop = "defaults write com.apple.finder CreateDesktop -bool false && killall Finder";
showdesktop = "defaults write com.apple.finder CreateDesktop -bool true && killall Finder";
};
};

programs.git = {
enable = true;

aliases = {
a = "add";
aa = "add .";
au = "add --update";
b = "branch";
c = "commit -m";
cn = "commit --no-verify -m";
ch = "checkout";
l = "log";
p = "push";
pf = "push --force";
pl = "pull";
s = "status";
amend = "commit --amend --reuse-message=HEAD";
go = "!go() { git checkout -b $1 2> /dev/null || git checkout $1; }; go";
hist = "log --pretty=oneline --pretty=format:'%Cred%h%Creset %C(yellow)%an%Creset %s%C(normal dim)%d%Creset %Cgreen(%cr)%Creset' --date=relative --abbrev-commit";
monkeys = "shortlog --summary --numbered";
undo = "reset --soft HEAD^";
unstage = "reset HEAD --";
a = "add";
aa = "add .";
au = "add --update";
b = "branch";
c = "commit -m";
cn = "commit --no-verify -m";
ch = "checkout";
l = "log";
p = "push";
pf = "push --force";
pl = "pull";
s = "status";

amend = "commit --amend --reuse-message=HEAD";
go = "!go() { git checkout -b $1 2> /dev/null || git checkout $1; }; go";
hist = "log --pretty=oneline --pretty=format:'%Cred%h%Creset %C(yellow)%an%Creset %s%C(normal dim)%d%Creset %Cgreen(%cr)%Creset' --date=relative --abbrev-commit";
monkeys = "shortlog --summary --numbered";
undo = "reset --soft HEAD^";
unstage = "reset HEAD --";
};
userName = "Tom Meagher";
userEmail = "[email protected]";
userName = "Tom Meagher";
userEmail = "[email protected]";

extraConfig = {
color.ui = "auto";
Expand Down
39 changes: 39 additions & 0 deletions .config/nvim/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,42 @@ nix
- https://gist.github.com/rsms/fb463396c95ad8d9efa338a8050a01dc
- https://speakerdeck.com/cocopon/creating-your-lovely-color-scheme?slide=63
- https://dotfiles.substack.com/p/16-elijah-manor?post_id=135441075

- https://nix-community.github.io/home-manager/options.html
- https://daiderd.com/nix-darwin/manual/index.html
- https://search.nixos.org/packages

---

```
NSGlobalDomain.AppleHighlightColor = "0.764700 0.976500 0.568600";
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults write com.apple.dock showLaunchpadGestureEnabled -int 0
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
defaults write com.apple.finder WarnOnEmptyTrash -bool false
chflags nohidden ~/Library
# Finder > Preferences
# Enable snap-to-grid for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
dockutil --no-restart --remove all
dockutil --no-restart --add "/Applications/Firefox.app"
dockutil --no-restart --add "/Applications/iTerm.app"
dockutil --no-restart --add "~/Downloads" --section others --sort name --view list
# Remove All Unavailable Simulators
xcrun simctl delete unavailable
brew 'gpg'
brew 'tmux'
brew 'mas' # App Store CLI (https://github.com/mas-cli/mas)
system.activationScripts
https://github.com/leonbreedt/nix-config/blob/15765e5aea9cce38fd1e342cf6df6799a11ef73e/macos/lib/dock.nix#L7
```
90 changes: 30 additions & 60 deletions .config/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -505,19 +505,22 @@ require("lazy").setup({
-- indent-blankline.nvim (https://github.com/lukas-reineke/indent-blankline.nvim)
{
"lukas-reineke/indent-blankline.nvim",
event = { "BufReadPost", "BufNewFile" },
main = "ibl",
opts = {
filetype_exclude = {
"help",
"alpha",
"dashboard",
"neo-tree",
"Trouble",
"lazy",
"mason",
"notify",
"toggleterm",
"lazyterm",
indent = { char = "" },
exclude = {
filetypes = {
"help",
"alpha",
"dashboard",
"neo-tree",
"Trouble",
"lazy",
"mason",
"notify",
"toggleterm",
"lazyterm",
},
},
},
},
Expand Down Expand Up @@ -675,41 +678,6 @@ require("lazy").setup({
},
},

{
"echasnovski/mini.indentscope",
event = { "BufReadPre", "BufNewFile" },
opts = function()
return {
draw = {
delay = 0,
animation = require("mini.indentscope").gen_animation.none(),
},
symbol = "",
options = {
indent_at_cursor = false,
try_as_border = true,
},
}
end,
init = function()
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"help",
"neo-tree",
"Trouble",
"lazy",
"mason",
"notify",
"toggleterm",
"lazyterm",
},
callback = function()
vim.b.miniindentscope_disable = true
end,
})
end,
},

-- neo-tree.nvim (https://github.com/nvim-neo-tree/neo-tree.nvim)
{
"nvim-neo-tree/neo-tree.nvim",
Expand Down Expand Up @@ -889,8 +857,8 @@ require("lazy").setup({
-- https://github.com/williamboman/mason.nvim
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
-- https://github.com/jose-elias-alvarez/null-ls.nvim
"jose-elias-alvarez/null-ls.nvim",
-- https://github.com/nvimtools/none-ls.nvim
"nvimtools/none-ls.nvim",
-- https://github.com/smjonas/inc-rename.nvim
"smjonas/inc-rename.nvim",
},
Expand All @@ -911,8 +879,9 @@ require("lazy").setup({

require("mason-lspconfig").setup({
ensure_installed = {
"biome",
"lua_ls",
"rome",
"rnix",
"tsserver",
},
automatic_installation = true,
Expand Down Expand Up @@ -945,7 +914,10 @@ require("lazy").setup({
},
},
},
rome = {
rnix = {
settings = {},
},
biome = {
settings = {},
},
rust_analyzer = {
Expand Down Expand Up @@ -1020,7 +992,7 @@ require("lazy").setup({
debounce = 150,
save_after_format = false,
sources = {
nls.builtins.formatting.rome,
nls.builtins.formatting.biome,
nls.builtins.formatting.stylua,
nls.builtins.formatting.fish_indent,
},
Expand Down Expand Up @@ -1262,8 +1234,6 @@ require("lazy").setup({
end
end,
on_highlights = function(hl, c)
-- indentscope
hl.MiniIndentscopeSymbol = { fg = c.purple }
-- neo-tree
hl.NeoTreeDirectoryIcon = { fg = c.comment }
hl.NeoTreeModified = { fg = c.comment }
Expand Down Expand Up @@ -1461,12 +1431,12 @@ require("lazy").setup({
tools = {
on_initialized = function()
vim.cmd([[
augroup RustLSP
autocmd CursorHold *.rs silent! lua vim.lsp.buf.document_highlight()
autocmd CursorMoved,InsertEnter *.rs silent! lua vim.lsp.buf.clear_references()
autocmd BufEnter,CursorHold,InsertLeave *.rs silent! lua vim.lsp.codelens.refresh()
augroup END
]])
augroup RustLSP
autocmd CursorHold *.rs silent! lua vim.lsp.buf.document_highlight()
autocmd CursorMoved,InsertEnter *.rs silent! lua vim.lsp.buf.clear_references()
autocmd BufEnter,CursorHold,InsertLeave *.rs silent! lua vim.lsp.codelens.refresh()
augroup END
]])
end,
},
}
Expand Down
Loading

0 comments on commit d95b661

Please sign in to comment.