Last active
March 5, 2026 19:05
-
-
Save lyekumchew/e7e339bccf1878356944d3458c372577 to your computer and use it in GitHub Desktop.
nix + home-manager
This file contains hidden or 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
| { | |
| config, | |
| pkgs, | |
| lib, | |
| ... | |
| }: | |
| { | |
| home.stateVersion = "25.11"; | |
| programs.home-manager.enable = true; | |
| home.packages = with pkgs; [ | |
| aria2 | |
| curl | |
| htop | |
| iperf3 | |
| jq | |
| git-lfs | |
| mtr | |
| netcat | |
| tree | |
| vim | |
| wget | |
| wireguard-tools | |
| lazygit | |
| ]; | |
| home.sessionVariables = { | |
| LANG = "en_US.UTF-8"; | |
| LC_ALL = "en_US.UTF-8"; | |
| GOPATH = "$HOME/go"; | |
| }; | |
| home.file.".npmrc".text = '' | |
| prefix=~/.npm-global | |
| ''; | |
| home.sessionPath = [ | |
| "$HOME/.npm-global/bin" | |
| ]; | |
| programs.starship = { | |
| enable = true; | |
| enableZshIntegration = true; | |
| settings = { | |
| add_newline = true; | |
| character = { | |
| success_symbol = "[➜](bold green)"; | |
| error_symbol = "[✗](bold red)"; | |
| }; | |
| package.disabled = true; | |
| directory = { | |
| read_only = " 🔒"; | |
| }; | |
| git_branch = { | |
| symbol = "🌱 "; | |
| truncation_symbol = ""; | |
| }; | |
| aws.disabled = true; | |
| }; | |
| }; | |
| programs.atuin = { | |
| enable = true; | |
| enableZshIntegration = true; | |
| settings = { | |
| style = "compact"; | |
| show_tabs = true; | |
| inline_height = 20; | |
| show_preview = true; | |
| enter_accept = false; | |
| search_mode = "fuzzy"; | |
| filter_mode = "global"; | |
| work_filter = true; | |
| pre_commands = [ | |
| "ls" | |
| "cd" | |
| "pwd" | |
| "clear" | |
| "exit" | |
| ]; | |
| exit_mode = "return-query"; | |
| }; | |
| }; | |
| programs.zoxide = { | |
| enable = true; | |
| enableZshIntegration = true; | |
| }; | |
| programs.tmux = { | |
| enable = true; | |
| shortcut = "a"; | |
| baseIndex = 1; | |
| newSession = false; | |
| escapeTime = 0; | |
| historyLimit = 10000; | |
| keyMode = "vi"; | |
| mouse = true; | |
| terminal = "tmux-256color"; | |
| plugins = with pkgs; [ | |
| tmuxPlugins.sensible | |
| tmuxPlugins.vim-tmux-navigator # 这个插件默认占用了 Ctrl+L | |
| { | |
| plugin = tmuxPlugins.catppuccin; | |
| extraConfig = '' | |
| set -g @catppuccin_flavor 'latte' | |
| # 已删除右侧状态栏的 cpu 模块 | |
| set -g @catppuccin_status_modules_right "session date_time" | |
| set -g @catppuccin_date_time_text "%H:%M" | |
| ''; | |
| } | |
| tmuxPlugins.resurrect | |
| { | |
| plugin = tmuxPlugins.continuum; | |
| extraConfig = "set -g @continuum-restore 'off'"; | |
| } | |
| ]; | |
| extraConfig = '' | |
| # --- 关键修复:释放 Ctrl+L --- | |
| # vim-tmux-navigator 插件默认把 C-l 绑到了 select-pane -R | |
| # 我们强制解除这个全局绑定,让 Ctrl+L 能传递给 Zsh 进行补全 | |
| unbind -n C-l | |
| # 面板拆分 | |
| bind | split-window -h -c "#{pane_current_path}" | |
| bind - split-window -v -c "#{pane_current_path}" | |
| unbind '"' | |
| unbind % | |
| set-option -ga terminal-overrides ",xterm-256color:Tc" | |
| ''; | |
| }; | |
| programs.zsh = { | |
| enable = true; | |
| enableCompletion = true; | |
| autosuggestion.enable = true; | |
| syntaxHighlighting.enable = true; | |
| oh-my-zsh = { | |
| enable = true; | |
| plugins = [ "git" ]; | |
| }; | |
| initContent = '' | |
| bindkey '^L' autosuggest-accept | |
| # Fix paste slowness | |
| pasteinit() { | |
| OLD_SELF_INSERT=''${''${(s.:.)widgets[self-insert]}[2,3]} | |
| zle -N self-insert url-quote-magic | |
| } | |
| pastefinish() { | |
| zle -N self-insert $OLD_SELF_INSERT | |
| } | |
| zstyle :bracketed-paste-magic paste-init pasteinit | |
| zstyle :bracketed-paste-magic paste-finish pastefinish | |
| # PATH deduplication | |
| typeset -U path | |
| path=( | |
| $HOME/bin | |
| $HOME/.cargo/bin | |
| $GOPATH/bin | |
| ${lib.optionalString pkgs.stdenv.isDarwin "/opt/homebrew/bin /opt/homebrew/sbin"} | |
| $path | |
| ) | |
| [[ -f "$HOME/.secrets" ]] && source "$HOME/.secrets" | |
| [[ -f "$HOME/.zsh_aliases" ]] && source "$HOME/.zsh_aliases" | |
| killport() { | |
| echo "Killing process on port: $1" | |
| lsof -t -i tcp:"$1" | xargs -r kill -9 | |
| } | |
| ''; | |
| }; | |
| } |
This file contains hidden or 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
| { | |
| "nodes": { | |
| "flake-compat": { | |
| "flake": false, | |
| "locked": { | |
| "lastModified": 1761588595, | |
| "narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=", | |
| "owner": "edolstra", | |
| "repo": "flake-compat", | |
| "rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5", | |
| "type": "github" | |
| }, | |
| "original": { | |
| "owner": "edolstra", | |
| "repo": "flake-compat", | |
| "type": "github" | |
| } | |
| }, | |
| "flake-utils": { | |
| "inputs": { | |
| "systems": "systems" | |
| }, | |
| "locked": { | |
| "lastModified": 1701680307, | |
| "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", | |
| "owner": "numtide", | |
| "repo": "flake-utils", | |
| "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", | |
| "type": "github" | |
| }, | |
| "original": { | |
| "owner": "numtide", | |
| "repo": "flake-utils", | |
| "type": "github" | |
| } | |
| }, | |
| "git-hooks": { | |
| "inputs": { | |
| "flake-compat": "flake-compat", | |
| "gitignore": "gitignore", | |
| "nixpkgs": [ | |
| "go-overlay", | |
| "nixpkgs" | |
| ] | |
| }, | |
| "locked": { | |
| "lastModified": 1765016596, | |
| "narHash": "sha256-rhSqPNxDVow7OQKi4qS5H8Au0P4S3AYbawBSmJNUtBQ=", | |
| "owner": "cachix", | |
| "repo": "git-hooks.nix", | |
| "rev": "548fc44fca28a5e81c5d6b846e555e6b9c2a5a3c", | |
| "type": "github" | |
| }, | |
| "original": { | |
| "owner": "cachix", | |
| "repo": "git-hooks.nix", | |
| "type": "github" | |
| } | |
| }, | |
| "gitignore": { | |
| "inputs": { | |
| "nixpkgs": [ | |
| "go-overlay", | |
| "git-hooks", | |
| "nixpkgs" | |
| ] | |
| }, | |
| "locked": { | |
| "lastModified": 1709087332, | |
| "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", | |
| "owner": "hercules-ci", | |
| "repo": "gitignore.nix", | |
| "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", | |
| "type": "github" | |
| }, | |
| "original": { | |
| "owner": "hercules-ci", | |
| "repo": "gitignore.nix", | |
| "type": "github" | |
| } | |
| }, | |
| "go-overlay": { | |
| "inputs": { | |
| "flake-utils": "flake-utils", | |
| "git-hooks": "git-hooks", | |
| "nixpkgs": [ | |
| "nixpkgs" | |
| ] | |
| }, | |
| "locked": { | |
| "lastModified": 1772693053, | |
| "narHash": "sha256-0GK/MKb2tDZRhcz8E+f/VFnGcNgSMgMa/X3lmGePhCw=", | |
| "owner": "purpleclay", | |
| "repo": "go-overlay", | |
| "rev": "268c5a26f2a3460ce90b3124653f36cc7b1affad", | |
| "type": "github" | |
| }, | |
| "original": { | |
| "owner": "purpleclay", | |
| "repo": "go-overlay", | |
| "type": "github" | |
| } | |
| }, | |
| "home-manager": { | |
| "inputs": { | |
| "nixpkgs": [ | |
| "nixpkgs" | |
| ] | |
| }, | |
| "locked": { | |
| "lastModified": 1772633327, | |
| "narHash": "sha256-jl+DJB2DUx7EbWLRng+6HNWW/1/VQOnf0NsQB4PlA7I=", | |
| "owner": "nix-community", | |
| "repo": "home-manager", | |
| "rev": "5a75730e6f21ee624cbf86f4915c6e7489c74acc", | |
| "type": "github" | |
| }, | |
| "original": { | |
| "owner": "nix-community", | |
| "repo": "home-manager", | |
| "type": "github" | |
| } | |
| }, | |
| "nixpkgs": { | |
| "locked": { | |
| "lastModified": 1772674223, | |
| "narHash": "sha256-/suKbHSaSmuC9UY7G0VRQ3aO+QKqxAQPQ19wG7QNkF8=", | |
| "owner": "nixos", | |
| "repo": "nixpkgs", | |
| "rev": "66d9241e3dc2296726dc522e62dbfe89c7b449f3", | |
| "type": "github" | |
| }, | |
| "original": { | |
| "owner": "nixos", | |
| "ref": "nixpkgs-unstable", | |
| "repo": "nixpkgs", | |
| "type": "github" | |
| } | |
| }, | |
| "root": { | |
| "inputs": { | |
| "go-overlay": "go-overlay", | |
| "home-manager": "home-manager", | |
| "nixpkgs": "nixpkgs" | |
| } | |
| }, | |
| "systems": { | |
| "locked": { | |
| "lastModified": 1681028828, | |
| "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | |
| "owner": "nix-systems", | |
| "repo": "default", | |
| "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | |
| "type": "github" | |
| }, | |
| "original": { | |
| "owner": "nix-systems", | |
| "repo": "default", | |
| "type": "github" | |
| } | |
| } | |
| }, | |
| "root": "root", | |
| "version": 7 | |
| } |
This file contains hidden or 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
| { | |
| description = "Dotfiles"; | |
| inputs = { | |
| nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | |
| home-manager = { | |
| url = "github:nix-community/home-manager"; | |
| inputs.nixpkgs.follows = "nixpkgs"; | |
| }; | |
| go-overlay = { | |
| url = "github:purpleclay/go-overlay"; | |
| inputs.nixpkgs.follows = "nixpkgs"; | |
| }; | |
| }; | |
| outputs = | |
| { | |
| nixpkgs, | |
| home-manager, | |
| go-overlay, | |
| ... | |
| }: | |
| let | |
| overlays = [ | |
| go-overlay.overlays.default | |
| # 核心技巧:把系统的 go 强制指向 overlay 的最新二进制版 | |
| (final: prev: { | |
| go = final.go-bin.latest; | |
| }) | |
| ]; | |
| mkPkgs = | |
| system: | |
| import nixpkgs { | |
| inherit system overlays; | |
| config.allowUnfree = true; | |
| }; | |
| in | |
| { | |
| homeConfigurations = { | |
| "mac" = home-manager.lib.homeManagerConfiguration { | |
| pkgs = mkPkgs "aarch64-darwin"; | |
| modules = [ ./mac.nix ]; | |
| }; | |
| "linux-amd64" = home-manager.lib.homeManagerConfiguration { | |
| pkgs = mkPkgs "x86_64-linux"; | |
| modules = [ ./linux.nix ]; | |
| }; | |
| "linux-arm64" = home-manager.lib.homeManagerConfiguration { | |
| pkgs = mkPkgs "aarch64-linux"; | |
| modules = [ ./linux.nix ]; | |
| }; | |
| }; | |
| }; | |
| } |
This file contains hidden or 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
| { config, pkgs, ... }: | |
| { | |
| imports = [ ./common.nix ]; | |
| home.username = "root"; | |
| home.homeDirectory = "/root"; | |
| home.packages = with pkgs; [ | |
| bind | |
| lsof | |
| ]; | |
| } |
This file contains hidden or 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
| { config, pkgs, ... }: | |
| { | |
| imports = [ ./common.nix ]; | |
| home.username = "autumn"; | |
| home.homeDirectory = "/Users/autumn"; | |
| home.packages = with pkgs; [ | |
| nodejs | |
| nixfmt | |
| nixd | |
| skeema | |
| ast-grep | |
| awscli | |
| cloc | |
| flyctl | |
| pnpm | |
| go | |
| bun | |
| openssh | |
| tdl | |
| openlist | |
| ]; | |
| home.sessionVariables = { | |
| SSH_AUTH_SOCK = "$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"; | |
| }; | |
| programs.zsh = { | |
| dirHashes = { | |
| desktop = "$HOME/Desktop"; | |
| downloads = "$HOME/Downloads"; | |
| documents = "$HOME/Documents"; | |
| applications = "/Applications"; | |
| surge = "$HOME/Library/Application Support/Surge/Profiles"; | |
| }; | |
| }; | |
| programs.zsh.shellAliases = { | |
| upd = "cd ~/.dotfiles && nix flake update && git add . && home-manager switch --flake .#mac && home-manager generations | awk 'NR>2 {print $5}' | xargs -I {} home-manager remove-generations {} && nix-collect-garbage && echo '✨ Update complete! Kept last 2 generations.' && echo '📊 Current /nix disk usage:' && df -h /nix"; | |
| undo = "home-manager switch --rollback"; | |
| }; | |
| programs.direnv = { | |
| enable = true; | |
| enableZshIntegration = true; | |
| nix-direnv.enable = true; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment