From 6ef9ec385af50f4ec6a240b7c5f09410b5ec7b0d Mon Sep 17 00:00:00 2001 From: punkfairie Date: Fri, 15 Nov 2024 17:44:46 -0800 Subject: [PATCH] feat(home): My module --- modules/home/me/default.nix | 4 -- modules/home/my/default.nix | 73 +++++++++++++++++++++++++++++++++++++ old/modules/home/me.nix | 69 ----------------------------------- 3 files changed, 73 insertions(+), 73 deletions(-) delete mode 100644 modules/home/me/default.nix create mode 100644 modules/home/my/default.nix delete mode 100644 old/modules/home/me.nix diff --git a/modules/home/me/default.nix b/modules/home/me/default.nix deleted file mode 100644 index 5e946b8..0000000 --- a/modules/home/me/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ namespace, lib, ... }: -{ - -} diff --git a/modules/home/my/default.nix b/modules/home/my/default.nix new file mode 100644 index 0000000..46eb655 --- /dev/null +++ b/modules/home/my/default.nix @@ -0,0 +1,73 @@ +{ + namespace, + lib, + config, + ... +}: +let + inherit (lib) + mkOption + types + mkDefault + mkIf + ; +in +{ + options.${namespace}.my = rec { + name = mkOption { + type = with types; str; + default = config.snowfallorg.user.name or "marley"; + description = "Your username, for use as your login name."; + }; + + username = mkOption { + type = with types; str; + default = name; + description = "Your username, for external profiles."; + }; + + fullName = mkOption { + type = with types; str; + default = name; + description = "Your full name, for display purposes."; + }; + + email = mkOption { + type = with types; nullOr str; + default = null; + description = "Your email"; + }; + + git.name = mkOption { + type = with types; str; + default = name; + description = "Your git committer name."; + }; + + git.email = mkOption { + type = with types; nullOr str; + default = email; + description = "Your git committer email."; + }; + }; + + config = + let + cfg = config.${namespace}.my; + in + { + assertions = [ + { + assertion = cfg.name != null; + message = "${namespace}.my.name must be set."; + } + ]; + + home.username = mkDefault cfg.name; + + programs.git = mkIf config.programs.git.enable { + userName = mkDefault cfg.git.name; + userEmail = mkDefault cfg.git.email; + }; + }; +} diff --git a/old/modules/home/me.nix b/old/modules/home/me.nix deleted file mode 100644 index d3ff045..0000000 --- a/old/modules/home/me.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ - lib, - config, - pkgs, - ... -}: -with lib; -{ - options = { - me = rec { - name = mkOption { - type = types.str; - default = builtins.getEnv "HOME"; - defaultText = - # nix - literalExpression '' - builtins.getEnv "HOME" - ''; - description = '' - Your username, for use as your home folder and login name. - ''; - }; - - username = mkOption { - type = types.str; - default = name; - defaultText = literalMD "{option}`home.me.name`"; - description = '' - Your username, for external profiles. - ''; - }; - - email = mkOption { - type = with types; nullOr str; - default = null; - description = '' - Your email. - ''; - }; - - git.name = mkOption { - type = with types; nullOr str; - default = null; - description = '' - Your git committer name. - ''; - }; - - git.email = mkOption { - type = with types; nullOr str; - default = email; - defaultText = literalMD "{option}`home.me.email`"; - description = '' - Your git committer email. - ''; - }; - }; - }; - - config = - let - cfg = config.me; - homeDir = if pkgs.stdenv.isDarwin then "Users" else "home"; - in - { - home.username = cfg.name; - home.homeDirectory = "/${homeDir}/${cfg.name}"; - }; -}