From 404f4a9294bfab01cba5f92d8a06d49a96d09ceb Mon Sep 17 00:00:00 2001 From: punkfairie Date: Mon, 6 Jan 2025 18:52:09 -0800 Subject: [PATCH] feat(nixos): Add marleyos.my module --- modules/nixos/base/users/default.nix | 17 ++++++++-- modules/nixos/options/my/default.nix | 48 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 modules/nixos/options/my/default.nix diff --git a/modules/nixos/base/users/default.nix b/modules/nixos/base/users/default.nix index 400bc96..65e5cb1 100644 --- a/modules/nixos/base/users/default.nix +++ b/modules/nixos/base/users/default.nix @@ -1,10 +1,21 @@ -{config, ...}: { +_: let + my = { + name = "marley"; + username = "punkfairie"; + fullName = "Marley Rae"; + email = "marley@punkfairie.net"; + }; +in { + marleyos.my = { + inherit (my) name username fullName email; + }; + users = { mutableUsers = false; - users.users."${config.marleyos.my.name}" = { + users.users."${my.name}" = { isNormalUser = true; - description = config.marleyos.my.fullName; + description = my.fullName; extraGroups = ["networkmanager" "wheel"]; hashedPassword = "$y$j9T$ztWf9WeUCENC2T12qS4mi1$51ihV/5cQ8mdJJrNe7MMguk4hPB61S5xHawsfi.1hL3"; }; diff --git a/modules/nixos/options/my/default.nix b/modules/nixos/options/my/default.nix new file mode 100644 index 0000000..8b67ce1 --- /dev/null +++ b/modules/nixos/options/my/default.nix @@ -0,0 +1,48 @@ +{ + lib, + config, + ... +}: let + inherit + (lib) + mkOption + types + ; +in { + options.marleyos.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"; + }; + }; + + config = let + cfg = config.marleyos.my; + in { + assertions = [ + { + assertion = cfg.name != null; + message = "marleyos.my.name must be set."; + } + ]; + }; +}