user/git: add additional configs by condition

This commit is contained in:
Dmitriy Pleshevskiy 2023-04-01 00:33:43 +03:00
parent e0a3b1bf15
commit 6dd94a9fcc
Signed by: pleshevskiy
GPG Key ID: 79C4487B44403985
5 changed files with 67 additions and 89 deletions

View File

@ -1,80 +0,0 @@
{ lib, config, pkgs, ... }:
let
cfg = config.local.git;
in
{
options.local.git = with lib; {
userName = mkOption {
type = types.str;
description = "Set your global name";
};
userEmail = mkOption {
type = types.str;
description = "Set your global email";
};
gpgKey = mkOption {
type = types.nullOr types.str;
default = null;
description = "The default GnuPG signing key fingerprint";
};
git-crypt = {
enable = mkEnableOption "Add git-crypt package";
};
};
config = {
home.packages = lib.mkIf cfg.git-crypt.enable [ pkgs.git-crypt ];
programs.git = {
enable = true;
inherit (cfg) userName userEmail;
signing = lib.mkIf (cfg.gpgKey != null) {
key = cfg.gpgKey;
signByDefault = true;
};
ignores = [ ".nlsp-settings" ];
extraConfig = {
init.defaultBranch = "main";
pull.rebase = true;
};
aliases = {
co = "switch";
cob = "switch -c";
cobf = "switch -C";
st = "status -sb";
d = "diff";
dc = "diff --cached";
aa = "add .";
ai = "add -i";
c = "commit";
cm = "commit -m";
ca = "commit --amend";
cam = "commit --amend -m";
can = "commit --amend --no-edit";
p = "push";
po = "push origin";
pf = "push --force-with-lease";
pfo = "push --force-with-lease origin";
pl = "pull";
plo = "pull origin";
rb = "rebase";
rbi = "rebase -i";
rbc = "rebase --continue";
lo = "log --pretty=oneline";
sma = "submodule add";
smui = "submodule update --init";
s = "stash push";
sm = "stash push -m";
sl = "stash list";
sa = "stash apply";
sai = "stash apply --index";
sp = "stash pop";
spi = "stash pop --index";
};
};
};
}

View File

@ -0,0 +1,65 @@
{ pkgs, ... }:
{
home.packages = [ pkgs.git-crypt ];
programs.git = {
enable = true;
userEmail = "dmitriy@pleshevski.ru";
userName = "Dmitriy Pleshevskiy";
signing = {
key = "43669288EC334989";
signByDefault = true;
};
includes = [
# My main account was suspended due to sanctions
{
condition = "hasconfig:remote.*.url:git@github.com:**/**";
contents = import ./github.secret.nix;
}
# Work account
{
condition = "hasconfig:remote.*.url:git@gitlab.com:**/**";
contents = import ./gitlab.secret.nix;
}
];
ignores = [ ".nlsp-settings" ];
extraConfig = {
init.defaultBranch = "main";
pull.rebase = true;
};
aliases = {
co = "switch";
cob = "switch -c";
cobf = "switch -C";
st = "status -sb";
d = "diff";
dc = "diff --cached";
aa = "add .";
ai = "add -i";
c = "commit";
cm = "commit -m";
ca = "commit --amend";
cam = "commit --amend -m";
can = "commit --amend --no-edit";
p = "push";
po = "push origin";
pf = "push --force-with-lease";
pfo = "push --force-with-lease origin";
pl = "pull";
plo = "pull origin";
rb = "rebase";
rbi = "rebase -i";
rbc = "rebase --continue";
lo = "log --pretty=oneline";
sma = "submodule add";
smui = "submodule update --init";
s = "stash push";
sm = "stash push -m";
sl = "stash list";
sa = "stash apply";
sai = "stash apply --index";
sp = "stash pop";
spi = "stash pop --index";
};
};
}

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }:
{ pkgs, ... }:
{
imports = [
./accounts.secret.nix
./git
../../modules/window_manager
../../modules/terminal.nix
@ -13,7 +14,6 @@
../../modules/mail
../../modules/pass.nix
../../modules/git.nix
../../modules/dev_tools.nix
../../modules/editor.nix
@ -54,13 +54,6 @@
woodpecker-cli
];
local.git = {
gpgKey = "43669288EC334989";
userEmail = "dmitriy@pleshevski.ru";
userName = "Dmitriy Pleshevskiy";
git-crypt.enable = true;
};
home.file = {
"pictures/wallpapers" = {
source = ./wallpapers;