os/modules/user/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

107 lines
2.7 KiB
Nix
Raw Normal View History

2021-05-30 19:10:28 +00:00
{
2022-11-20 22:28:23 +00:00
config,
pkgs,
2023-09-12 20:07:05 +00:00
lib,
2024-03-19 18:29:57 +00:00
flake,
2022-11-20 22:28:23 +00:00
...
2023-09-12 20:07:05 +00:00
}: let
psCfg = config.pub-solar;
in
2024-08-18 22:22:59 +00:00
with lib; {
imports = [
./home.nix
];
2023-09-12 20:07:05 +00:00
2024-08-18 22:22:59 +00:00
options.pub-solar = {
user = {
name = mkOption {
description = "User login name";
type = types.nullOr types.str;
default = "nixos";
};
description = mkOption {
description = "User description";
type = types.nullOr types.str;
default = "The main PubSolarOS user";
};
password = mkOption {
description = "User password";
type = types.nullOr types.str;
default = null;
};
passwordlessSudo = mkOption {
description = "Whether this user can use sudo without entering a password";
type = types.bool;
default = false;
};
publicKeys = mkOption {
description = "User SSH public keys";
type = types.listOf types.str;
default = [];
};
fullName = mkOption {
description = "User full name";
type = types.nullOr types.str;
default = null;
};
email = mkOption {
description = "User email address";
type = types.nullOr types.str;
default = null;
};
gpgKeyId = mkOption {
description = "GPG Key ID";
type = types.nullOr types.str;
default = null;
};
2021-05-30 19:10:28 +00:00
};
};
2023-09-12 20:07:05 +00:00
2024-08-18 22:22:59 +00:00
config = {
users = {
mutableUsers = false;
2023-09-12 20:07:05 +00:00
2024-08-18 22:22:59 +00:00
users."${psCfg.user.name}" = {
# Indicates whether this is an account for a “real” user.
# This automatically sets group to users, createHome to true,
# home to /home/username, useDefaultShell to true, and isSystemUser to false.
isNormalUser = true;
description = psCfg.user.description;
extraGroups = [
"input"
"lp"
"networkmanager"
"scanner"
"video"
"dialout"
"wheel"
];
shell = pkgs.bash;
initialHashedPassword =
if psCfg.user.password != null
then psCfg.user.password
else "";
openssh.authorizedKeys.keys =
flake.self.publicKeys
++ (
if psCfg.user.publicKeys != null
then psCfg.user.publicKeys
else []
);
};
};
2023-10-26 12:09:11 +00:00
2024-08-18 22:22:59 +00:00
security.sudo.extraRules = mkIf psCfg.user.passwordlessSudo [
{
users = ["${psCfg.user.name}"];
commands = [
{
command = "ALL";
options = ["NOPASSWD"];
}
];
}
];
};
}