2020-03-13 21:18:08 +01:00
|
|
|
{ lib, pkgs, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.programs.git.custom;
|
2020-05-22 18:27:31 +02:00
|
|
|
defaultProfiles = {
|
|
|
|
private = {
|
|
|
|
name = "Felix Tenley";
|
|
|
|
email = "dev@felschr.com";
|
2020-07-12 17:26:32 +02:00
|
|
|
signingKey = "6AB3 7A28 5420 9A41 82D9 0068 910A CB9F 6BD2 6F58";
|
2020-05-22 18:27:31 +02:00
|
|
|
dirs = [ "/etc/nixos/" ];
|
|
|
|
};
|
|
|
|
work = {
|
|
|
|
name = "Felix Schröter";
|
|
|
|
email = "fs@upsquared.com";
|
2020-07-12 17:26:32 +02:00
|
|
|
signingKey = "F28B FB74 4421 7580 5A49 2930 BE85 F0D9 987F A014";
|
2020-05-22 18:27:31 +02:00
|
|
|
dirs = [ "~/dev/" ];
|
|
|
|
};
|
|
|
|
};
|
2020-03-13 21:18:08 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.programs.git.custom = {
|
2020-05-22 18:27:31 +02:00
|
|
|
profiles = mkOption {
|
|
|
|
type = types.attrsOf (types.submodule ({ name, config, ... }: {
|
|
|
|
options = {
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
email = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
signingKey = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
dirs = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
default = defaultProfiles;
|
2020-03-13 21:18:08 +01:00
|
|
|
};
|
2020-05-22 18:27:31 +02:00
|
|
|
defaultProfile = mkOption {
|
2020-03-13 21:18:08 +01:00
|
|
|
type = types.str;
|
2020-05-22 18:27:31 +02:00
|
|
|
default = "private";
|
2020-03-13 21:18:08 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-05-22 18:27:31 +02:00
|
|
|
config = let
|
|
|
|
profiles = cfg.profiles;
|
|
|
|
in {
|
2020-03-13 21:18:08 +01:00
|
|
|
programs.git = {
|
|
|
|
enable = true;
|
2020-05-22 18:27:31 +02:00
|
|
|
userName = profiles."${cfg.defaultProfile}".name;
|
|
|
|
userEmail = profiles."${cfg.defaultProfile}".email;
|
2020-03-13 21:18:08 +01:00
|
|
|
ignores = [".direnv"];
|
|
|
|
signing = {
|
2020-05-22 18:27:31 +02:00
|
|
|
key = profiles."${cfg.defaultProfile}".signingKey;
|
2020-03-13 21:18:08 +01:00
|
|
|
signByDefault = true;
|
|
|
|
};
|
|
|
|
extraConfig = {
|
|
|
|
pull = { rebase = true; };
|
|
|
|
rebase = { autoStash = true; };
|
|
|
|
};
|
2020-05-22 18:27:31 +02:00
|
|
|
includes = flatten (mapAttrsToList (name: profile: map (dir: {
|
|
|
|
condition = "gitdir:${dir}";
|
|
|
|
contents = {
|
|
|
|
user = {
|
|
|
|
name = profile.name;
|
|
|
|
email = profile.email;
|
|
|
|
signingkey = profile.signingKey;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}) profile.dirs) profiles);
|
2020-03-13 21:18:08 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|