2024-01-08 21:48:31 +01:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
{
|
|
|
|
config = lib.mkIf config.programs.git.enable {
|
|
|
|
home.packages = [
|
|
|
|
(pkgs.writeShellApplication {
|
2024-01-11 22:25:52 +01:00
|
|
|
name = "git-sync";
|
2024-01-08 21:48:31 +01:00
|
|
|
text = (lib.strings.concatLines
|
2024-01-11 22:25:52 +01:00
|
|
|
(map
|
|
|
|
(r: ''
|
|
|
|
echo "===== ${r.path}"
|
|
|
|
if [ ! -d "${r.path}" ]
|
|
|
|
then
|
|
|
|
${pkgs.git}/bin/git clone "${r.uri}" "${r.path}"
|
|
|
|
else
|
|
|
|
(
|
|
|
|
cd "${r.path}"
|
|
|
|
${pkgs.git}/bin/git diff --quiet || echo "Repository is dirty!"
|
|
|
|
${pkgs.git}/bin/git pull || true
|
|
|
|
${pkgs.git}/bin/git push || true
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
'')
|
2024-01-08 21:48:31 +01:00
|
|
|
(lib.attrsets.attrValues config.services.git-sync.repositories)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
})
|
|
|
|
];
|
|
|
|
programs.git = {
|
|
|
|
package = pkgs.gitFull;
|
|
|
|
aliases = {
|
|
|
|
"git" = "!exec git"; # In case I write one too many git
|
|
|
|
};
|
|
|
|
ignores = [
|
|
|
|
"*.swp"
|
|
|
|
"*.swo"
|
|
|
|
"*.ycm_extra_conf.py"
|
|
|
|
"tags"
|
|
|
|
".mypy_cache"
|
|
|
|
];
|
|
|
|
delta = {
|
|
|
|
enable = true;
|
|
|
|
options = {
|
|
|
|
line-numbers = true;
|
|
|
|
syntax-theme = "base16";
|
|
|
|
};
|
|
|
|
};
|
2024-01-09 20:00:12 +01:00
|
|
|
# Also tried difftastic, and while I like the default theme it's a bit
|
|
|
|
# less configurable
|
2024-01-08 21:48:31 +01:00
|
|
|
lfs.enable = true;
|
|
|
|
userEmail = lib.mkDefault "geoffrey@frogeye.fr";
|
|
|
|
userName = lib.mkDefault "Geoffrey Frogeye";
|
|
|
|
extraConfig = {
|
|
|
|
core = {
|
|
|
|
editor = "nvim";
|
|
|
|
};
|
|
|
|
push = {
|
|
|
|
default = "matching";
|
|
|
|
};
|
|
|
|
pull = {
|
|
|
|
ff = "only";
|
|
|
|
};
|
|
|
|
} // lib.optionalAttrs config.frogeye.desktop.xorg {
|
|
|
|
diff.tool = "meld";
|
|
|
|
difftool.prompt = false;
|
|
|
|
"difftool \"meld\"".cmd = "${pkgs.meld}/bin/meld \"$LOCAL\" \"$REMOTE\"";
|
|
|
|
# This escapes quotes, which isn't the case in the original, hoping this isn't an issue.
|
|
|
|
};
|
|
|
|
};
|
|
|
|
services = {
|
|
|
|
git-sync = {
|
|
|
|
enable = false; # The real thing syncs too quickly and asks for passphrase, which is annoying
|
|
|
|
# So for now it's just a way to park config which will be reused by git-sync-* commands
|
|
|
|
repositories = {
|
|
|
|
dotfiles = {
|
|
|
|
path = "${config.xdg.configHome}/dotfiles";
|
|
|
|
uri = lib.mkDefault "https://git.frogeye.fr/geoffrey/dotfiles.git";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|