diff --git a/.gitignore b/.gitignore index 4617fae..424e1f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Local/work-specific configuration files .zshenv.local +git/.config/git/config.local # Nix result diff --git a/git/.config/git/.gitignore_global b/git/.config/git/.gitignore_global new file mode 100644 index 0000000..ca3f8d7 --- /dev/null +++ b/git/.config/git/.gitignore_global @@ -0,0 +1,4 @@ +.idea/ +.vscode/ + +.tool-versions diff --git a/git/.config/git/README.md b/git/.config/git/README.md new file mode 100644 index 0000000..b1cf506 --- /dev/null +++ b/git/.config/git/README.md @@ -0,0 +1,62 @@ +# Git Configuration + +This directory contains the shared git configuration that works across all platforms (NixOS, macOS, Linux, WSL). + +## OS-Specific Configurations + +You can create OS-specific git configuration files that will be automatically included: + +### Setup + +Add the following to the bottom of `config`: + +```gitconfig +# OS-specific configurations +# These will be loaded if the files exist +[include] + path = ~/.config/git/config.local + path = ~/.config/git/config.darwin + path = ~/.config/git/config.linux + path = ~/.config/git/config.wsl +``` + +### Create OS-Specific Files + +Then create the appropriate files: + +- **`config.darwin`** - macOS-specific settings +- **`config.linux`** - Native Linux-specific settings +- **`config.wsl`** - WSL-specific settings +- **`config.local`** - Machine-specific settings (not tracked in git) + +### Example OS-Specific Files + +**config.darwin:** +```gitconfig +# macOS-specific git configuration + +[core] + # macOS specific settings +``` + +**config.linux:** +```gitconfig +# Linux-specific git configuration + +[core] + # Linux specific settings +``` + +**config.wsl:** +```gitconfig +# WSL-specific git configuration + +[core] + # WSL might need different autocrlf handling +``` + +### Notes + +- Git will silently ignore include paths that don't exist +- Settings in later files override earlier ones +- You can add `config.local` to `.gitignore` for machine-specific settings diff --git a/git/.config/git/config b/git/.config/git/config new file mode 100644 index 0000000..dc1c71b --- /dev/null +++ b/git/.config/git/config @@ -0,0 +1,20 @@ +# Git configuration +# This file is managed by dotfiles and symlinked to ~/.config/git/config + +[user] + name = "user3301" + email = "26126682+user3301@users.noreply.github.com" + +[core] + autocrlf = "input" + editor = nvim + excludesfile = ~/.config/git/.gitignore_global + +[commit] + gpgsign = true + +# machine-specific configuration will be configurated there +# (eg: signkingkey) +[include] + path = ~/.config/git/config.local + diff --git a/home/archlinux.nix b/home/archlinux.nix index c5c84a6..bbcd8f7 100644 --- a/home/archlinux.nix +++ b/home/archlinux.nix @@ -6,6 +6,7 @@ ./modules/common.nix ./modules/shell.nix ./modules/dev-tools.nix + ./modules/git.nix ./modules/neovim.nix ./modules/terminal.nix ./modules/editors.nix @@ -30,13 +31,6 @@ # Example: Nix-specific or bleeding-edge tools ]; - # Git configuration - programs.git = { - enable = true; - userName = "user3301"; - userEmail = "26126682+user3301@users.noreply.github.com"; - }; - # Targets for non-NixOS systems targets.genericLinux.enable = true; diff --git a/home/darwin.nix b/home/darwin.nix index 05ce4b8..f0d4594 100644 --- a/home/darwin.nix +++ b/home/darwin.nix @@ -6,6 +6,7 @@ ./modules/common.nix ./modules/shell.nix ./modules/dev-tools.nix + ./modules/git.nix ./modules/neovim.nix ./modules/terminal.nix ./modules/editors.nix @@ -26,13 +27,6 @@ xdg.configFile."aerospace".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dotfiles/aerospace/.config/aerospace"; - # Git configuration - programs.git = { - enable = true; - userName = "gaiz"; - userEmail = "26126682+user3301@users.noreply.github.com"; - }; - # Home Manager state version home.stateVersion = "24.05"; } diff --git a/home/modules/dev-tools.nix b/home/modules/dev-tools.nix index fd8560d..bddc144 100644 --- a/home/modules/dev-tools.nix +++ b/home/modules/dev-tools.nix @@ -5,11 +5,6 @@ home.packages = with pkgs; [ vim - # Version control - git - gh # GitHub CLI - lazygit - # Modern CLI tools ripgrep fd @@ -33,18 +28,4 @@ # AI pkgs.claude-code ]; - - # Git configuration - programs.git = { - enable = true; - # User will configure name/email in their local .gitconfig or via system config - }; - - # GitHub CLI - programs.gh = { - enable = true; - settings = { - git_protocol = "ssh"; - }; - }; } diff --git a/home/modules/git.nix b/home/modules/git.nix new file mode 100644 index 0000000..5dd0dc4 --- /dev/null +++ b/home/modules/git.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: + +{ + # Git package + home.packages = with pkgs; [ + git + gh # GitHub CLI + lazygit + ]; + + # Git configuration via XDG config symlink + # This allows sharing the same config with macOS via GNU Stow + # Symlinks entire git config directory to include config.local and other files + xdg.configFile."git".source = config.lib.file.mkOutOfStoreSymlink + "${config.home.homeDirectory}/dotfiles/git/.config/git"; + + # GitHub CLI + programs.gh = { + enable = true; + settings = { + git_protocol = "ssh"; + }; + }; +} diff --git a/home/nixos-native.nix b/home/nixos-native.nix index 5b84f5e..6e03535 100644 --- a/home/nixos-native.nix +++ b/home/nixos-native.nix @@ -6,6 +6,7 @@ ./modules/common.nix ./modules/shell.nix ./modules/dev-tools.nix + ./modules/git.nix ./modules/neovim.nix ./modules/terminal.nix ./modules/editors.nix @@ -25,13 +26,6 @@ # Add more GUI apps as needed ]; - # Git configuration - programs.git = { - enable = true; - userName = "user3301"; - userEmail = "26126682+user3301@users.noreply.github.com"; - }; - # Home Manager state version home.stateVersion = "24.05"; } diff --git a/home/nixos-wsl.nix b/home/nixos-wsl.nix index 653879e..84ac57e 100644 --- a/home/nixos-wsl.nix +++ b/home/nixos-wsl.nix @@ -6,6 +6,7 @@ ./modules/common.nix ./modules/shell.nix ./modules/dev-tools.nix + ./modules/git.nix ./modules/neovim.nix ./modules/terminal.nix ./modules/editors.nix @@ -28,25 +29,6 @@ # Add any WSL-specific environment variables }; - # Git configuration for WSL - programs.git = { - enable = true; - signing = { - key = "23B0107B5D3811FB"; - signByDefault = true; - }; - settings = { - user = { - name = "user3301"; - email = "26126682+user3301@users.noreply.github.com"; - }; - core = { - # Handle Windows line endings - autocrlf = "input"; - }; - }; - }; - # GPG configuration programs.gpg = { enable = true;