From 7e73a10b1e45b179a77f73cc606aa4fe89d47830 Mon Sep 17 00:00:00 2001 From: Yun Fachi Date: Wed, 22 Nov 2023 16:03:16 +0000 Subject: [PATCH] feat(core): add git configuration --- home/core.nix | 4 ++++ home/core/default.nix | 5 +++++ home/core/git.nix | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 home/core/default.nix create mode 100644 home/core/git.nix diff --git a/home/core.nix b/home/core.nix index 865c098..df4dfa1 100644 --- a/home/core.nix +++ b/home/core.nix @@ -4,6 +4,10 @@ nixosVersion, ... }: { + imports = [ + ./core + ]; + home = { username = username; homeDirectory = lib.mkForce "/home/${username}"; diff --git a/home/core/default.nix b/home/core/default.nix new file mode 100644 index 0000000..4993059 --- /dev/null +++ b/home/core/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./git.nix + ]; +} \ No newline at end of file diff --git a/home/core/git.nix b/home/core/git.nix new file mode 100644 index 0000000..8b4a79f --- /dev/null +++ b/home/core/git.nix @@ -0,0 +1,38 @@ +{ + config, + lib, + userfullname, + useremail, + ... +}: { + home.activation.removeExistingGitconfig = lib.hm.dag.entryBefore ["checkLinkTargets"] '' + rm -f ~/.gitconfig + ''; + + programs.git = { + enable = true; + lfs.enable = true; + + userName = userfullname; + userEmail = useremail; + + extraConfig = { + init.defaultBranch = "master"; + push.autoSetupRemote = true; + pull.rebase = true; + + # replace https with ssh + url = { + "ssh://git@github.com/" = { + insteadOf = "https://github.com/"; + }; + "ssh://git@gitlab.com/" = { + insteadOf = "https://gitlab.com/"; + }; + "ssh://git@bitbucket.com/" = { + insteadOf = "https://bitbucket.com/"; + }; + }; + }; + }; +} \ No newline at end of file