From 9a5413f1dcc82d4238fda7d73ba8b8b78e298940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Sun, 6 Mar 2022 08:55:08 +0100 Subject: [PATCH] Add git-mit as a repository template --- config/programs/git.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/config/programs/git.nix b/config/programs/git.nix index b65b68be..1052ad0e 100644 --- a/config/programs/git.nix +++ b/config/programs/git.nix @@ -1,4 +1,23 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +let gitTemplate = pkgs.stdenv.mkDerivation { + name = "git-template"; + src = pkgs.writeFile "dummy" ""; + nativeBuildInputs = with pkgs; with rust-binaries; [ + git + mit-commit-msg + mit-pre-commit + mit-prepare-commit-msg + ]; + buildPhase = "true"; + installPhase = '' + git init $out + ln -s $out/.git/hooks/commit-msg ${mit-commit-msg}/bin/mit-commit-msg + ln -s $out/.git/hooks/pre-commit ${mit-pre-commit}/bin/mit-pre-commit + ln -s $out/.git/hooks/prepare-commit-msg ${mit-prepare-commit-msg}/bin/mit-prepare-commit-msg + ''; +}; +in +{ programs.git = { enable = true; package = pkgs.gitAndTools.gitFull; @@ -7,6 +26,9 @@ signing.key = "AB2BD8DAF2E37122"; userEmail = "lotte@chir.rs"; userName = "Charlotte 🦝 Delenk"; + extraConfig = { + init.templatedir = "${gitTemplate}"; + }; }; home.packages = with pkgs.rust-binaries; [ git-mit