From 408751cce53c1665870982dbc795ac64bbe94dd2 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Sun, 1 Oct 2023 22:54:00 +0200 Subject: [PATCH] pinwheel: Add `enable` option to `git` module And use it to check when to add work `gitconfig` --- hosts/pinwheel/configuration.nix | 6 +++++- hosts/pinwheel/modules/git/default.nix | 25 ++++++++++++++++++------- hosts/pinwheel/modules/work/default.nix | 3 ++- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/hosts/pinwheel/configuration.nix b/hosts/pinwheel/configuration.nix index 2819702..e9268fd 100644 --- a/hosts/pinwheel/configuration.nix +++ b/hosts/pinwheel/configuration.nix @@ -126,7 +126,11 @@ }; config-manager.flakePath = "/home/alex/config"; - mod.openvpn.enable = true; + + mod = { + git.enable = true; + openvpn.enable = true; + }; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/hosts/pinwheel/modules/git/default.nix b/hosts/pinwheel/modules/git/default.nix index 9e5206e..d1d1b0e 100644 --- a/hosts/pinwheel/modules/git/default.nix +++ b/hosts/pinwheel/modules/git/default.nix @@ -1,12 +1,23 @@ -{ ... }: +{ lib, config, ... }: +let + enabled = config.mod.git.enable; +in { - home-manager.users.alex = { - programs.git = { - enable = true; + options = { + mod.git = { + enable = lib.mkEnableOption "enable git module"; + }; + }; - includes = [ - { path = ./gitconfig; } - ]; + config = lib.mkIf enabled { + home-manager.users.alex = { + programs.git = { + enable = true; + + includes = [ + { path = ./gitconfig; } + ]; + }; }; }; } diff --git a/hosts/pinwheel/modules/work/default.nix b/hosts/pinwheel/modules/work/default.nix index 0dc0e4c..a2acbdd 100644 --- a/hosts/pinwheel/modules/work/default.nix +++ b/hosts/pinwheel/modules/work/default.nix @@ -1,5 +1,6 @@ { pkgs, lib, config, ... }: let + gitEnabled = config.mod.git.enable; openvpnEnabled = config.mod.openvpn.enable; work-vpn = let @@ -25,7 +26,7 @@ let in { home-manager.users.alex = { - programs.git = { + programs.git = lib.mkIf gitEnabled { includes = [ { path = ./work-gitconfig;