Last active
February 25, 2024 10:54
-
-
Save voanhduy1512/e7ca398b73f00de3fac41931dad812d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
fontOverlay = import ./font-overlays.nix; | |
pkgsOverlay = import ./pkgs-overlay.nix; | |
user = "anhduy"; | |
in | |
{ config, pkgs, ... }: | |
{ | |
imports = [ <home-manager/nix-darwin> ]; | |
system.defaults.trackpad.Clicking = true; | |
system.defaults.trackpad.TrackpadThreeFingerDrag = true; | |
system.keyboard.enableKeyMapping = true; | |
system.keyboard.remapCapsLockToControl = true; | |
services.nix-daemon.enable = true; | |
nix.extraOptions = '' | |
gc-keep-derivations = true | |
gc-keep-outputs = true | |
''; | |
programs.zsh.enable = true; | |
nixpkgs.config.allowUnfree = true; | |
nixpkgs.overlays = [ pkgsOverlay fontOverlay ]; | |
users.users.${user}.home = "/Users/anhduy"; | |
home-manager = { | |
useUserPackages = true; | |
useGlobalPkgs = true; | |
users.${user} = { pkgs, config, lib, ... }: { | |
# TODO: temporary hack from https://github.com/nix-community/home-manager/issues/1341#issuecomment-778820334 | |
# Even though nix-darwin support symlink to ~/Application or ~/Application/Nix Apps | |
# Spotlight doesn't like symlink as all or it won't index them | |
home.activation = { | |
copyApplications = | |
let | |
apps = pkgs.buildEnv { | |
name = "home-manager-applications"; | |
paths = config.home.packages; | |
pathsToLink = "/Applications"; | |
}; | |
in | |
lib.hm.dag.entryAfter [ "writeBoundary" ] '' | |
baseDir="$HOME/Applications/Home Manager Apps" | |
if [ -d "$baseDir" ]; then | |
rm -rf "$baseDir" | |
fi | |
mkdir -p "$baseDir" | |
for appFile in ${apps}/Applications/*; do | |
target="$baseDir/$(basename "$appFile")" | |
$DRY_RUN_CMD cp ''${VERBOSE_ARG:+-v} -fHRL "$appFile" "$baseDir" | |
$DRY_RUN_CMD chmod ''${VERBOSE_ARG:+-v} -R +w "$target" | |
done | |
''; | |
}; | |
home.packages = with pkgs; [ | |
(pkgs.slack.overrideAttrs (oldAttrs: { | |
installPhase = '' | |
mkdir -p $out/Applications/Slack.app | |
cp -R . $out/Applications/Slack.app | |
''; | |
})) | |
tig | |
tat | |
ripgrep | |
fd | |
gopass | |
git-secret | |
coreutils | |
gcc | |
bazel | |
adoptopenjdk-bin | |
watch | |
ssm-session-manager-plugin | |
lima | |
k9s | |
graphviz | |
# Need for IntelliJ to format code | |
terraform | |
]; | |
programs.alacritty.enable = true; | |
programs.alacritty.settings = import ./config/alacritty.nix; | |
programs.bat.enable = true; | |
programs.bat.config.theme = "Nord"; | |
programs.zsh.shellAliases.cat = "${pkgs.bat}/bin/bat"; | |
programs.zsh.shellAliases.k = "kubectl"; | |
programs.zsh.shellAliases.ssh = "TERM=screen ${pkgs.openssh}/bin/ssh"; | |
programs.dircolors.enable = true; | |
programs.dircolors.enableZshIntegration = true; | |
home.file.".dir_colors".text = builtins.readFile ./config/nord_dir_colors; | |
programs.exa.enable = true; | |
programs.exa.enableAliases = true; | |
programs.zsh.enable = true; | |
programs.zsh.prezto.enable = true; | |
programs.zsh.profileExtra = '' | |
export EDITOR=nvim | |
export VISUAL=nvim | |
''; | |
programs.password-store.enable = true; | |
programs.password-store.package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]); | |
programs.fzf.enable = true; | |
programs.fzf.enableZshIntegration = true; | |
programs.fzf.changeDirWidgetCommand = "${pkgs.fd}/bin/fd --type d"; | |
programs.fzf.defaultCommand = "${pkgs.fd}/bin/fd --type file --hidden --exclude .git"; | |
programs.fzf.fileWidgetCommand = "${pkgs.fd}/bin/fd --type file --hidden --exclude .git"; | |
programs.fzf.fileWidgetOptions = [ "--preview '${pkgs.bat}/bin/bat --style=numbers --color=always {}'" ]; | |
programs.tmux.enable = true; | |
programs.tmux.terminal = "alacritty"; | |
programs.tmux.keyMode = "vi"; | |
programs.tmux.escapeTime = 10; | |
programs.tmux.prefix = "C-s"; | |
programs.tmux.extraConfig = '' | |
set -ga terminal-overrides ',*:Tc' | |
bind-key - split-window -v -c '#{pane_current_path}' | |
bind-key \\ split-window -h -c '#{pane_current_path}' | |
bind c new-window -c '#{pane_current_path}' | |
# act like vim | |
bind-key -r C-h select-window -t :- | |
bind-key -r C-l select-window -t :+ | |
# layout | |
bind Space next-layout | |
set -g renumber-windows on | |
# break pane | |
bind-key b break-pane -d | |
''; | |
programs.direnv.enable = true; | |
programs.direnv.enableZshIntegration = true; | |
programs.direnv.nix-direnv.enable = true; | |
programs.emacs.enable = true; | |
# programs.emacs.extraPackages = epkgs: [ epkgs.use-package epkgs.emms epkgs.magit epkgs.kubel ]; | |
programs.neovim.enable = true; | |
programs.neovim.extraPackages = with pkgs; [ | |
ripgrep | |
fzf | |
bat | |
]; | |
programs.neovim.extraConfig = '' | |
let mapleader = " " | |
set number | |
set relativenumber | |
set nocompatible | |
set nobackup | |
set hidden | |
let g:nord_italic_comments = 1 | |
set background=dark | |
colorscheme nord | |
let g:is_bash = 1 | |
nnoremap <C-p> :FZF<cr> | |
let g:fzf_colors = | |
\ { 'fg': ['fg', 'Normal'], | |
\ 'bg': ['bg', 'Normal'], | |
\ 'hl': ['fg', 'Comment'], | |
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], | |
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], | |
\ 'hl+': ['fg', 'Statement'], | |
\ 'info': ['fg', 'PreProc'], | |
\ 'border': ['fg', 'Ignore'], | |
\ 'prompt': ['fg', 'Conditional'], | |
\ 'pointer': ['fg', 'Exception'], | |
\ 'marker': ['fg', 'Keyword'], | |
\ 'spinner': ['fg', 'Label'], | |
\ 'header': ['fg', 'Comment'] } | |
" Close nerdtree | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
lua << EOF | |
local nvim_lsp = require('lspconfig') | |
local on_attach = function(client, bufnr) | |
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end | |
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end | |
-- Mappings. | |
local opts = { noremap=true, silent=true } | |
-- See `:help vim.lsp.*` for documentation on any of the below functions | |
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts) | |
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts) | |
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts) | |
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) | |
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) | |
buf_set_keymap('n', '1gD', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) | |
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) | |
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) | |
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts) | |
buf_set_keymap("n", ",f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) | |
buf_set_keymap("n", "ga", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) | |
end | |
-- Use a loop to conveniently call 'setup' on multiple servers and | |
-- map buffer local keybindings when the language server attaches | |
local servers = { "ccls" } | |
for _, lsp in ipairs(servers) do | |
nvim_lsp[lsp].setup { on_attach = on_attach } | |
end | |
nvim_lsp.rust_analyzer.setup({ | |
on_attach=on_attach, | |
settings = { | |
["rust-analyzer"] = { | |
assist = { | |
importGranularity = "module", | |
importPrefix = "by_self", | |
}, | |
cargo = { | |
loadOutDirsFromCheck = true | |
}, | |
procMacro = { | |
enable = true | |
}, | |
} | |
} | |
}) | |
require'nvim-treesitter.configs'.setup { | |
highlight = { | |
enable = true | |
} | |
} | |
EOF | |
''; | |
programs.neovim.plugins = with pkgs.vimPlugins; [ | |
nerdtree | |
vim-polyglot | |
nord-vim | |
fzf-vim | |
vim-nix | |
nvim-treesitter | |
nvim-lspconfig | |
]; | |
programs.git.enable = true; | |
programs.htop.enable = true; | |
programs.gpg.enable = true; | |
home.sessionVariables.SSH_AUTH_SOCK = "$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)"; | |
home.file."${config.xdg.configHome}/nvim/parser/nix.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-nix}/parser"; | |
home.file."${config.xdg.configHome}/nvim/parser/go.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-go}/parser"; | |
home.file."${config.xdg.configHome}/nvim/parser/haskell.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-haskell}/parser"; | |
home.file."${config.xdg.configHome}/nvim/parser/rust.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-rust}/parser"; | |
home.file."${config.xdg.configHome}/nvim/parser/c.so".source = "${pkgs.tree-sitter.builtGrammars.tree-sitter-c}/parser"; | |
home.file.".gnupg/gpg-agent.conf".text = '' | |
max-cache-ttl 18000 | |
default-cache-ttl 18000 | |
pinentry-program ${pkgs.pinentry_mac}/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac | |
enable-ssh-support | |
''; | |
}; | |
}; | |
fonts.enableFontDir = true; | |
fonts.fonts = with pkgs; [ | |
source-code-pro-0-38 | |
]; | |
# Used for backwards compatibility, please read the changelog before changing. | |
# $ darwin-rebuild changelog | |
system.stateVersion = 4; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's from home-manager,
imports = [ <home-manager/nix-darwin> ];
. You can read more options in home manager manual here https://rycee.gitlab.io/home-manager/options.html