Refactor git modules

This commit is contained in:
Yan Lin 2026-02-13 09:00:40 +01:00
parent 84065395ba
commit d8fc5590e4
5 changed files with 47 additions and 4 deletions

63
modules/git/home.nix Normal file
View file

@ -0,0 +1,63 @@
{ config, pkgs, ... }:
{
programs.git-credential-oauth = {
enable = true;
};
programs.git = {
enable = true;
ignores = [
"**/.claude/settings.local.json"
".DS_Store"
".env"
"node_modules/"
".venv/"
];
settings = {
user = {
name = "Yan Lin";
email = "github@yanlincs.com";
};
credential = {
"https://github.com".helper = "oauth";
"https://gitlab.com".helper = "oauth";
"https://bitbucket.org".helper = "oauth";
"https://git.overleaf.com".helper = "store";
"https://git.overleaf.com".username = "git";
};
core = {
editor = "nvim";
autocrlf = "input";
ignorecase = false;
};
init.defaultBranch = "main";
push = {
default = "simple";
autoSetupRemote = true;
};
pull = {
rebase = true;
};
merge = {
conflictstyle = "diff3";
};
diff = {
colorMoved = "default";
};
status = {
showUntrackedFiles = "all";
};
};
};
}

263
modules/git/lazygit.nix Normal file
View file

@ -0,0 +1,263 @@
{ config, pkgs, lib, ... }:
{
programs.lazygit = {
enable = true;
settings = {
gui = {
theme = {
lightTheme = false;
activeBorderColor = ["#458588" "bold"];
inactiveBorderColor = ["#504945"];
searchingActiveBorderColor = ["#fabd2f" "bold"];
optionsTextColor = ["#83a598"];
selectedLineBgColor = ["#3c3836"];
selectedRangeBgColor = ["#3c3836"];
cherryPickedCommitBgColor = ["#458588"];
cherryPickedCommitFgColor = ["#ebdbb2"];
markedBaseCommitBgColor = ["#fabd2f"];
markedBaseCommitFgColor = ["#282828"];
unstagedChangesColor = ["#fb4934"];
defaultFgColor = ["#ebdbb2"];
};
showFileTree = true;
showListFooter = true;
showRandomTip = false;
showCommandLog = true;
showBottomLine = true;
showPanelJumps = true;
commandLogSize = 8;
splitDiff = "auto";
screenMode = "normal";
border = "rounded";
commitLength = {
show = true;
};
mouseEvents = true;
skipDiscardChangeWarning = false;
skipStashWarning = false;
sidePanelWidth = 0.3333;
expandFocusedSidePanel = false;
mainPanelSplitMode = "flexible";
enlargedSideViewLocation = "left";
language = "en";
nerdFontsVersion = "3";
diffContextSize = 3;
scrollHeight = 20;
};
git = {
pagers = [
{
colorArg = "always";
pager = "delta --dark --paging=never";
}
];
commit = {
signOff = false;
autoWrapCommitMessage = true;
autoWrapWidth = 72;
};
merging = {
manualCommit = false;
args = "";
};
skipHookPrefix = "WIP";
autoFetch = true;
autoRefresh = true;
branchLogCmd = "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --";
allBranchesLogCmds = [
"git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium"
];
disableForcePushing = false;
commitPrefixes = {};
parseEmoji = false;
log = {
order = "topo-order";
showGraph = "always";
showWholeGraph = false;
};
};
refresher = {
refreshInterval = 10;
fetchInterval = 60;
};
update = {
method = "never";
};
confirmOnQuit = false;
quitOnTopLevelReturn = false;
keybinding = {
universal = {
quit = "q";
quit-alt1 = "<c-c>";
return = "<esc>";
quitWithoutChangingDirectory = "Q";
togglePanel = "<tab>";
prevItem = "<up>";
nextItem = "<down>";
prevItem-alt = "k";
nextItem-alt = "j";
prevPage = ",";
nextPage = ".";
scrollLeft = "H";
scrollRight = "L";
gotoTop = "<";
gotoBottom = ">";
toggleRangeSelect = "v";
rangeSelectDown = "<s-down>";
rangeSelectUp = "<s-up>";
prevBlock = "<left>";
nextBlock = "<right>";
prevBlock-alt = "h";
nextBlock-alt = "l";
nextBlock-alt2 = "<tab>";
prevBlock-alt2 = "<backtab>";
jumpToBlock = ["1" "2" "3" "4" "5"];
nextMatch = "n";
prevMatch = "N";
startSearch = "/";
optionMenu = "?";
optionMenu-alt1 = "x";
select = "<space>";
goInto = "<enter>";
confirm = "<enter>";
confirmInEditor = "<a-enter>";
remove = "d";
new = "n";
edit = "e";
openFile = "o";
scrollUpMain = "<c-b>";
scrollDownMain = "<c-f>";
executeShellCommand = ":";
createRebaseOptionsMenu = "m";
diffingMenu = "W";
diffingMenu-alt = "<c-e>";
copyToClipboard = "<c-o>";
submitEditorText = "<enter>";
extrasMenu = "@";
toggleWhitespaceInDiffView = "<c-w>";
increaseContextInDiffView = "}";
decreaseContextInDiffView = "{";
};
status = {
checkForUpdate = "u";
recentRepos = "<enter>";
allBranchesLogGraph = "a";
};
files = {
commitChanges = "c";
commitChangesWithoutHook = "w";
amendLastCommit = "A";
commitChangesWithEditor = "C";
findBaseCommitForFixup = "<c-f>";
confirmDiscard = "x";
ignoreFile = "i";
refreshFiles = "r";
stashAllChanges = "s";
viewStashOptions = "S";
toggleStagedAll = "a";
viewResetOptions = "D";
fetch = "f";
toggleTreeView = "`";
openMergeOptions = "M";
openStatusFilter = "<c-b>";
};
branches = {
createPullRequest = "o";
viewPullRequestOptions = "O";
copyPullRequestURL = "<c-y>";
checkoutBranchByName = "c";
forceCheckoutBranch = "F";
rebaseBranch = "r";
renameBranch = "R";
mergeIntoCurrentBranch = "M";
viewGitFlowOptions = "i";
fastForward = "f";
createTag = "T";
pushTag = "P";
setUpstream = "u";
fetchRemote = "f";
};
worktrees = {
viewWorktreeOptions = "w";
};
commits = {
squashDown = "s";
renameCommit = "r";
renameCommitWithEditor = "R";
viewResetOptions = "g";
markCommitAsFixup = "f";
createFixupCommit = "F";
squashAboveCommits = "S";
moveDownCommit = "<c-j>";
moveUpCommit = "<c-k>";
amendToCommit = "A";
resetCommitAuthor = "a";
pickCommit = "p";
revertCommit = "t";
cherryPickCopy = "C";
pasteCommits = "V";
markCommitAsBaseForRebase = "B";
tagCommit = "T";
checkoutCommit = "<space>";
resetCherryPick = "<c-R>";
copyCommitAttributeToClipboard = "y";
openLogMenu = "<c-l>";
openInBrowser = "o";
viewBisectOptions = "b";
startInteractiveRebase = "i";
};
stash = {
popStash = "g";
renameStash = "r";
};
commitFiles = {
checkoutCommitFile = "c";
};
main = {
toggleSelectHunk = "a";
pickBothHunks = "b";
editSelectHunk = "E";
};
submodules = {
init = "i";
update = "u";
bulkMenu = "b";
};
commitMessage = {
commitMenu = "<c-o>";
};
};
os = {
open = if pkgs.stdenv.isDarwin then "open {{filename}}" else "xdg-open {{filename}}";
openLink = if pkgs.stdenv.isDarwin then "open {{link}}" else "xdg-open {{link}}";
};
disableStartupPopups = false;
customCommands = [];
services = {};
notARepository = "prompt";
};
};
}

43
modules/git/server.nix Normal file
View file

@ -0,0 +1,43 @@
{ config, lib, ... }:
let
cfg = config.services.git-server-custom;
in
{
options.services.git-server-custom = {
enable = lib.mkEnableOption "Forgejo git server";
domain = lib.mkOption {
type = lib.types.str;
default = "localhost";
};
httpPort = lib.mkOption {
type = lib.types.port;
default = 3000;
};
sshPort = lib.mkOption {
type = lib.types.port;
default = 22;
};
};
config = lib.mkIf cfg.enable {
services.forgejo = {
enable = true;
lfs.enable = true;
database.type = "sqlite3";
settings = {
server = {
DOMAIN = cfg.domain;
ROOT_URL = "https://${cfg.domain}/";
HTTP_ADDR = "127.0.0.1";
HTTP_PORT = cfg.httpPort;
SSH_PORT = cfg.sshPort;
};
service.DISABLE_REGISTRATION = true;
};
};
};
}