nixos-config/home-manager/modules/git/default.nix

196 lines
4.8 KiB
Nix
Raw Normal View History

2024-02-05 11:46:52 +01:00
{
pkgs,
config,
lib,
# flake-inputs,
2024-02-05 11:46:52 +01:00
...
2022-03-01 22:19:03 +01:00
}:
2024-02-05 11:46:52 +01:00
with lib;
let
2022-03-01 22:19:03 +01:00
cfg = config.eboskma.programs.git;
in
{
2021-11-21 19:07:12 +01:00
options.eboskma.programs.git = {
enable = mkEnableOption "enable git";
2023-05-21 17:10:54 +02:00
package = mkOption {
description = "The git package to use";
type = types.package;
default = pkgs.gitFull;
};
2021-11-21 19:07:12 +01:00
name = mkOption {
description = "your name";
type = types.nonEmptyStr;
};
email = mkOption {
description = "your e-mail address";
type = types.nonEmptyStr;
};
signingKey = mkOption {
description = "your signing key";
2021-11-21 19:07:12 +01:00
type = types.nullOr types.str;
default = null;
};
signingKeyFormat = mkOption {
description = "the type of signing key";
2024-02-05 11:46:52 +01:00
type = types.enum [
"openpgp"
"x509"
"ssh"
];
default = "openpgp";
};
2021-11-21 19:07:12 +01:00
};
2022-05-03 18:17:38 +02:00
config = mkIf cfg.enable {
2021-11-21 19:07:12 +01:00
programs.git = {
enable = true;
2023-05-21 17:10:54 +02:00
package = cfg.package;
2021-11-21 19:07:12 +01:00
userName = cfg.name;
userEmail = cfg.email;
signing = mkIf (cfg.signingKey != null) {
key = cfg.signingKey;
signByDefault = true;
};
2022-08-24 08:31:43 +02:00
lfs.enable = true;
2021-11-21 19:07:12 +01:00
delta = {
2022-05-19 22:05:59 +02:00
enable = false;
2021-11-21 19:07:12 +01:00
options = {
2022-03-22 10:59:19 +01:00
side-by-side = false;
2021-11-21 19:07:12 +01:00
};
};
aliases = {
ls = "ls-files";
ignored = "ls-files -o -i --exclude-standard";
st = "status -s -b";
branches = "branch -a";
tags = "tag";
stashes = "stash list";
nevermind = "!git reset --hard HEAD && git clean -d -f";
graph = "log --graph -10 --branches --remotes --tags --format=format:'%Cgreen%h %Creset %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order";
precommit = "diff --cached --diff-algorithm=minimal -w";
track = "branch -u";
stat = "status -s";
up = "pull --autostash --rebase";
cm = "commit -m";
changelog = "log --oneline --no-merges";
source = "remote get-url origin";
};
extraConfig = {
2023-07-04 20:25:31 +02:00
credential = {
2024-04-04 16:41:46 +02:00
helper = [
"cache --timeout 900"
2024-04-04 16:41:46 +02:00
"${pkgs.git-credential-oauth}/bin/git-credential-oauth"
];
2023-07-04 20:25:31 +02:00
"https://dev.azure.com" = {
useHttpPath = true;
};
"https://git.datarift.nl" = {
2024-04-04 16:41:46 +02:00
oauthClientId = "a4792ccc-144e-407e-86c9-5e7d8d9c3269";
oauthAuthURL = "/login/oauth/authorize";
oauthTokenURL = "/login/oauth/access_token";
2023-07-04 20:25:31 +02:00
};
"http://repohost.bedum.horus.nu" = {
oauthClientId = "b00b00f53f073f4b38f7c38b1b2a944bb5069d411552a9968f1fca1d3e60395d";
oauthScopes = "read_repository write_repository";
oauthAuthURL = "/oauth/authorize";
oauthTokenURL = "/oauth/token";
};
2023-07-04 20:25:31 +02:00
};
2021-11-21 19:07:12 +01:00
init = {
defaultBranch = "main";
};
core = {
editor = "${config.eboskma.programs.emacs.package}/bin/emacsclient";
2022-05-19 22:05:59 +02:00
pager = "${pkgs.bat}/bin/bat";
2024-03-28 23:06:12 +01:00
untrackedCache = true;
# fsmonitor =
# let
# git-fs-monitor = flake-inputs.git-fs-monitor.packages.${pkgs.system}.default;
# in
# "${git-fs-monitor}/bin/git-fs-monitor";
2021-11-21 19:07:12 +01:00
};
merge = {
ff = "only";
conflictstyle = "diff3";
tool = "${pkgs.meld}/bin/meld";
};
pull = {
ff = "only";
};
2022-05-19 21:42:17 +02:00
push = {
default = "current";
};
2021-11-21 19:07:12 +01:00
rebase = {
autoStash = true;
};
rerere.enabled = true;
2021-11-21 19:07:12 +01:00
color = {
ui = "auto";
status = {
added = "yellow";
changed = "green";
untracked = "cyan";
};
branch = {
current = "yellow reverse";
local = "yellow";
remote = "green";
};
diff = {
meta = "yellow bold";
frag = "magenta bold";
old = "red bold";
new = "green bold";
};
};
2022-01-24 11:15:17 +01:00
grep = {
lineNumber = true;
column = true;
patternType = "extended";
};
2022-09-06 13:26:09 +02:00
gpg = {
format = cfg.signingKeyFormat;
ssh.allowedSignersFile = "~/.config/git/allowed_signers";
};
2022-09-06 13:26:09 +02:00
url = {
"ssh://git@repohost.bedum.horus.nu/" = {
insteadOf = "rh:";
pushInsteadOf = "rh:";
2022-09-06 13:27:55 +02:00
};
2022-09-06 13:26:09 +02:00
};
2024-07-12 10:28:24 +02:00
clangformat.binary = "${pkgs.clang-tools}/bin/clang-format";
2021-11-21 19:07:12 +01:00
};
};
programs.gh = {
enable = true;
settings = {
2024-04-23 16:32:30 +02:00
git_protocol = "https";
2021-12-06 09:58:39 +01:00
editor = "nvim";
prompt = "enabled";
pager = "bat";
http_unix_socket = "";
browser = "";
2023-12-20 11:24:48 +01:00
version = "1";
2021-11-21 19:07:12 +01:00
};
};
2023-07-04 20:25:31 +02:00
2024-04-04 16:41:46 +02:00
home.packages = [ pkgs.gitu ];
2021-11-21 19:07:12 +01:00
};
}