2023-07-20 15:02:38 +03:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
myData,
|
|
|
|
...
|
2023-10-01 23:14:05 +03:00
|
|
|
}: let
|
|
|
|
cfg = config.mj.base.users;
|
2024-03-06 10:33:48 +02:00
|
|
|
props = with lib.types; {
|
|
|
|
hashedPasswordFile = lib.mkOption {
|
|
|
|
type = nullOr path;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
initialPassword = lib.mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
initialHashedPassword = lib.mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
extraGroups = lib.mkOption {
|
|
|
|
type = listOf str;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
};
|
2023-10-01 23:14:05 +03:00
|
|
|
in {
|
2023-07-20 15:02:38 +03:00
|
|
|
options.mj.base.users = with lib.types; {
|
2024-02-04 16:18:47 +02:00
|
|
|
enable = lib.mkEnableOption "enable motiejus and root";
|
2024-02-04 22:05:44 +02:00
|
|
|
devTools = lib.mkOption {
|
2023-10-09 22:07:42 +03:00
|
|
|
type = bool;
|
|
|
|
default = false;
|
|
|
|
};
|
2024-03-06 10:33:48 +02:00
|
|
|
user = props;
|
|
|
|
root = props;
|
2023-07-20 15:02:38 +03:00
|
|
|
};
|
|
|
|
|
2024-02-04 16:18:47 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
2023-07-20 15:02:38 +03:00
|
|
|
users = {
|
|
|
|
mutableUsers = false;
|
|
|
|
|
2023-10-01 23:14:05 +03:00
|
|
|
users = {
|
2024-03-06 10:33:48 +02:00
|
|
|
${config.mj.username} =
|
2023-07-20 15:02:38 +03:00
|
|
|
{
|
|
|
|
isNormalUser = true;
|
2024-03-06 10:33:48 +02:00
|
|
|
extraGroups = ["wheel" "dialout" "video"] ++ cfg.user.extraGroups;
|
2023-07-24 16:31:38 +03:00
|
|
|
uid = myData.uidgid.motiejus;
|
2023-10-06 08:58:28 +03:00
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
myData.people_pubkeys.motiejus
|
|
|
|
];
|
2023-07-20 15:02:38 +03:00
|
|
|
}
|
2023-09-14 13:07:39 +03:00
|
|
|
// lib.filterAttrs (
|
|
|
|
n: v:
|
2023-11-27 17:54:44 +02:00
|
|
|
(n == "hashedPasswordFile" || n == "initialPassword") && v != null
|
2023-09-14 13:07:39 +03:00
|
|
|
)
|
2024-03-06 10:33:48 +02:00
|
|
|
cfg.user or {};
|
2023-07-20 15:02:38 +03:00
|
|
|
|
2024-03-06 10:33:48 +02:00
|
|
|
root = lib.filterAttrs (_: v: v != null) cfg.root;
|
2023-07-20 15:02:38 +03:00
|
|
|
};
|
|
|
|
};
|
2023-08-18 16:26:00 +03:00
|
|
|
|
2023-08-18 16:30:26 +03:00
|
|
|
home-manager.useGlobalPkgs = true;
|
2024-03-06 10:33:48 +02:00
|
|
|
home-manager.users.${config.mj.username} = {pkgs, ...}:
|
2024-02-04 22:23:56 +02:00
|
|
|
import ../../../shared/home/default.nix {
|
|
|
|
inherit lib;
|
|
|
|
inherit pkgs;
|
2024-03-06 10:33:48 +02:00
|
|
|
inherit (config.mj) stateVersion username;
|
2024-02-04 22:23:56 +02:00
|
|
|
inherit (cfg) devTools;
|
|
|
|
hmOnly = false;
|
|
|
|
email = "motiejus@jakstys.lt";
|
|
|
|
};
|
2023-07-20 15:02:38 +03:00
|
|
|
};
|
|
|
|
}
|