- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
{ pkgs, lib, config, ... }:
let
cfg = config.features.scm;
in
{
options = {
features.scm = {
enable = lib.mkEnableOption "SCM";
};
};
config = lib.mkIf cfg.enable {
programs.git =
let
difftasticConfig =
if config.features.dev.enable then
{
# https://difftastic.wilfred.me.uk/git.html
diff = {
tool = "difftastic";
};
difftool = {
prompt = false;
};
"difftool \"difftastic\"" = {
cmd = ''difft "$LOCAL" "$REMOTE"'';
};
pager = {
difftool = true;
};
}
else
{ };
in
{
enable = true;
userName = config.features.identity.name;
userEmail = config.features.identity.email;
signing =
if (config.features.identity.gpgSigningKeyId != null) then {
key = config.features.identity.gpgSigningKeyId;
signByDefault = true;
} else null;
extraConfig = {
core = {
editor = if config.programs.neovim.enable then "nvim" else "vim";
};
init = {
defaultBranch = "master";
};
} // difftasticConfig;
ignores =
let
# # Ignore all bazel-* symlinks. There is no full list since this can change
# based on the name of the directory bazel is cloned into.
bazel = [ "/bazel-*" ];
# Swap file
nvim = if config.programs.neovim.enable then [ ".*.swp" ] else [ ];
# https://github.com/github/gitignore/blob/main/Global/macOS.gitignore
darwin =
if pkgs.stdenv.isDarwin
then [
".DS_Store"
".AppleDouble"
".LSOverride"
]
else [ ];
in
nvim ++ darwin ++ bazel;
};
# https://github.com/martinvonz/jj
programs.jujutsu = {
enable = true;
settings = {
user = {
name = config.features.identity.name;
email = config.features.identity.email;
};
signing =
if (config.features.identity.gpgSigningKeyId != null) then {
sign-all = true;
backend = "gpg";
key = config.features.identity.gpgSigningKeyId;
} else null;
ui = lib.mkIf config.features.dev.enable {
diff = {
tool = [ "difft" "--color=always" "$left" "$right" ];
};
};
};
};
home.packages = [
pkgs.fossil
(
# Fossil derivation in Nixpkgs install bash completion only, while Fossil provides zsh's one too.
# Creating a new derivation is so much effective compared to using `lib.overrideAttrs` because
# of build cache.
pkgs.stdenv.mkDerivation {
pname = "fossil-zsh-completion";
version = pkgs.fossil.version;
src = pkgs.fossil.src;
phases = [ "unpackPhase" "installPhase" ];
nativeBuildInputs = [ pkgs.installShellFiles ];
installPhase = ''
installShellCompletion --zsh --name _fossil tools/fossil-autocomplete.zsh
'';
}
)
];
};
}