Migrate git configuration

This commit is contained in:
Yadunand Prem 2025-08-18 13:38:40 +08:00
parent b8c758615b
commit 5cd56ddcf3
2 changed files with 119 additions and 17 deletions

View File

@ -17,14 +17,11 @@
home.packages = [
# pkgs.dive
pkgs.entr
pkgs.lazygit
pkgs.jq
pkgs.just
pkgs.rsync
pkgs.gh
pkgs.claude-code
pkgs.devenv
pkgs.jujutsu
pkgs.dive
];
@ -39,25 +36,16 @@
"/opt/homebrew/bin"
];
programs.zsh.shellAliases = {
lg = "lazygit";
};
zsh.enable = true;
git = {
enable = true;
gpgProgram = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
signingKey = "~/.ssh/yadunut_ed25519.pub";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.git.extraConfig = {
gpg.ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
user.signingkey = "~/.ssh/yadunut_ed25519.pub";
core.excludesFile = "~/.gitignore_global";
};
programs.gh = {
enable = true;
};
targets.darwin = {
defaults."com.apple.dock".autohide = true;
defaults."com.apple.finder".AppleShowAllFiles = true;

View File

@ -0,0 +1,114 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.git;
inherit (lib) mkEnableOption mkIf mkOption;
types = lib.types;
name = "Yadunand Prem";
email = "yadunand@yadunut.com";
in
{
options.git = {
enable = mkEnableOption "Git";
gpgProgram = mkOption {
default = null;
type = types.nullOr types.str;
};
signingKey = mkOption {
type = types.nullOr types.str;
default = null;
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
git
lazygit
jujutsu
delta
];
programs.zsh.shellAliases = {
lg = "lazygit";
};
programs.git = {
ignores = [
".DS_Store"
".direnv/"
".envrc"
"**/.claude/settings.local.json"
];
enable = true;
userEmail = email;
userName = name;
delta.enable = true;
lfs.enable = true;
extraConfig = lib.mkMerge [
{
init.defaultBranch = "main";
pull.rebase = true;
pull.autostash = true;
rebase.autostash = true;
rebase.autosquash = true;
push.autoSetupRemote = true;
commit.gpgsign = true;
commit.verbose = true;
# merge.conflictstyle = "zdiff2";
diff.colorMoved = true;
diff.algorithm = "histogram";
feature.experimental = true;
branch.sort = "committerdate";
diff.mnemonicPrefix = true;
fetch.all = true;
column.ui = "auto";
tags.sort = "version:refname";
push.followTags = true;
rerere.enabled = true;
rerere.autoupdate = true;
rebase.updateRefs = true;
credential.helper = [
"${pkgs.git-credential-oauth}/bin/git-credential-oauth"
];
gpg.format = "ssh";
credential = {
"https://git.yadunut.dev" = {
oauthClientId = "a4792ccc-144e-407e-86c9-5e7d8d9c3269";
oauthScopes = "read:repository write:repository";
oauthAuthURL = "/login/oauth/authorize";
oauthTokenURL = "/login/oauth/access_token";
};
};
}
(mkIf (cfg.gpgProgram != null) { gpg.ssh.program = cfg.gpgProgram; })
(mkIf (cfg.signingKey != null) { user.signingkey = cfg.signingKey; })
];
};
programs.jujutsu = {
enable = true;
settings = {
user = {
name = name;
email = email;
};
ui.default-command = "log";
};
};
programs.gh.enable = true;
};
}