From 61b923505f0ce72eb7c6ff100809c172c5c235b1 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 23 Aug 2024 18:40:24 +0200 Subject: [PATCH] Move git options to separate module --- lib/modules/git.nix | 64 +++++++++++++++++++++++++++++++++---- lib/modules/git/options.nix | 33 ------------------- lib/modules/users.nix | 2 -- 3 files changed, 58 insertions(+), 41 deletions(-) delete mode 100644 lib/modules/git/options.nix diff --git a/lib/modules/git.nix b/lib/modules/git.nix index dd3bd8fd..7d98b739 100644 --- a/lib/modules/git.nix +++ b/lib/modules/git.nix @@ -1,7 +1,59 @@ -{ lib, ... }: { - options = { - valhalla = { - git = (import ./git/options.nix) { inherit lib; }; +{ lib, ... }: + let + inherit (lib) + mkOption + types + ; + + gitType = types.submodule ( + { ... }: { + options = { + defaultBranch = mkOption { + type = types.nullOr types.str; + description = "The name of the default branch in newly created repositories."; + default = null; + }; + + flow = { + mainBranch = mkOption { + type = types.nullOr types.str; + description = "The name of the stable branch in git flow."; + default = null; + }; + + devBranch = mkOption { + type = types.nullOr types.str; + description = "The name of the development branch in git flow."; + default = null; + }; + }; + + aliases = mkOption { + type = types.attrsOf types.str; + description = "The git command aliases to install."; + default = {}; + }; + }; + }); + + gitOption = mkOption { + type = gitType; + description = "The git related options."; + default = {}; }; - }; -} + in { + options = { + valhalla = { + git = gitOption; + + users = mkOption { + type = types.attrsOf (types.submodule ( + { ... }: { + options = { + git = gitOption; + }; + })); + }; + }; + }; + } diff --git a/lib/modules/git/options.nix b/lib/modules/git/options.nix deleted file mode 100644 index e063e034..00000000 --- a/lib/modules/git/options.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ lib, ... }: - let - inherit (lib) - mkOption - types - ; - in { - defaultBranch = mkOption { - type = types.nullOr types.str; - description = "The name of the default branch in git."; - default = null; - }; - - flow = { - mainBranch = mkOption { - type = types.nullOr types.str; - description = "The name of the stable branch in git flow."; - default = null; - }; - - devBranch = mkOption { - type = types.nullOr types.str; - description = "The name of the development branch in git flow."; - default = null; - }; - }; - - aliases = mkOption { - type = types.attrsOf types.str; - description = "Git command aliases to install."; - default = {}; - }; - } diff --git a/lib/modules/users.nix b/lib/modules/users.nix index 439e01da..f43bbc2c 100644 --- a/lib/modules/users.nix +++ b/lib/modules/users.nix @@ -47,8 +47,6 @@ description = "The additional groups of the user."; default = []; }; - - git = (import ./git/options.nix) { inherit lib; }; }; })); description = "The users to create on the machine.";