From 6c9bbc27a033389cc335624c457717f294dd0abc Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Fri, 22 May 2026 10:57:51 +0200 Subject: [PATCH] feat(git): add enable option --- home/hosts/andromache/default.nix | 1 + home/hosts/astyanax/default.nix | 1 + home/hosts/work/default.nix | 7 ++++-- home/modules/git/default.nix | 3 ++- modules/git/default.nix | 42 ++++++++++++++++--------------- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/home/hosts/andromache/default.nix b/home/hosts/andromache/default.nix index 8989fbd6..7d5c3142 100644 --- a/home/hosts/andromache/default.nix +++ b/home/hosts/andromache/default.nix @@ -56,6 +56,7 @@ browser.primary = "librewolf"; cloud.hetzner.enable = true; comms.signal.enable = true; + git.enable = true; git.github.enable = true; shell = { enable = true; diff --git a/home/hosts/astyanax/default.nix b/home/hosts/astyanax/default.nix index 5699a3e7..923f5539 100644 --- a/home/hosts/astyanax/default.nix +++ b/home/hosts/astyanax/default.nix @@ -52,6 +52,7 @@ browser.primary = "librewolf"; cloud.hetzner.enable = true; comms.signal.enable = true; + git.enable = true; git.github.enable = true; shell = { enable = true; diff --git a/home/hosts/work/default.nix b/home/hosts/work/default.nix index 649d4e83..bd1f3054 100644 --- a/home/hosts/work/default.nix +++ b/home/hosts/work/default.nix @@ -94,8 +94,11 @@ k8s.enable = true; shell.enable = true; my.stylix.enable = true; - git.github.enable = true; - git.gitlab.enable = true; + git = { + enable = true; + github.enable = true; + gitlab.enable = true; + }; secrets.enable = true; secrets.vault.enable = true; bruno.enable = true; diff --git a/home/modules/git/default.nix b/home/modules/git/default.nix index d15fb2e6..bfaac16c 100644 --- a/home/modules/git/default.nix +++ b/home/modules/git/default.nix @@ -8,11 +8,12 @@ { options.git = { + enable = lib.mkEnableOption "git"; github.enable = lib.mkEnableOption "Github CLI"; gitlab.enable = lib.mkEnableOption "Gitlab CLI"; }; - config = { + config = lib.mkIf config.git.enable { programs.git.enable = true; home.file = { ".gitconfig".source = dotsPath + "/.gitconfig"; diff --git a/modules/git/default.nix b/modules/git/default.nix index 80306c90..692da914 100644 --- a/modules/git/default.nix +++ b/modules/git/default.nix @@ -1,29 +1,31 @@ -{ - config, - ... -}: +{ lib, config, ... }: let + cfg = config.git; inherit (config.host) username; owner = config.users.users.${username}.name; in { - config.sops.templates = { - ".gitconfig.email" = { - inherit owner; - path = "/home/${username}/.gitconfig.email"; - content = '' - [user] - email = ${config.sops.placeholder."email/personal"} - ''; - }; - ".gitconfig.work.email" = { - inherit owner; - path = "/home/${username}/.gitconfig.work.email"; - content = '' - [user] - email = ${config.sops.placeholder."email/work"} - ''; + options.git.enable = lib.mkEnableOption "git"; + + config = lib.mkIf cfg.enable { + sops.templates = { + ".gitconfig.email" = { + inherit owner; + path = "/home/${username}/.gitconfig.email"; + content = '' + [user] + email = ${config.sops.placeholder."email/personal"} + ''; + }; + ".gitconfig.work.email" = { + inherit owner; + path = "/home/${username}/.gitconfig.work.email"; + content = '' + [user] + email = ${config.sops.placeholder."email/work"} + ''; + }; }; }; }