2024-07-19 12:00:55 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-07-18 04:08:27 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
# User configuration
|
|
|
|
userModule = types.submodule {
|
|
|
|
options = {
|
|
|
|
sudo = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
example = true;
|
|
|
|
description = "Whether the user is allowed sudo access.";
|
|
|
|
};
|
|
|
|
configuration = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = ./users/base.nix;
|
|
|
|
description = "What home manager configuration to use for this user.";
|
|
|
|
};
|
|
|
|
desktopInit = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = "Bash script to execute after initial log in.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-07-19 12:00:55 +00:00
|
|
|
in
|
|
|
|
{
|
2024-07-18 04:08:27 +00:00
|
|
|
imports = [
|
|
|
|
# Import home manager
|
2025-01-23 23:50:13 +00:00
|
|
|
# <home-manager/nixos>
|
2024-07-18 04:08:27 +00:00
|
|
|
|
2024-07-18 05:09:56 +00:00
|
|
|
# Import system wide configuration required for user modules
|
2025-01-23 23:50:13 +00:00
|
|
|
../../user-modules/systemwide/default.nix
|
2024-07-18 04:08:27 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
options = {
|
2025-01-23 23:28:22 +00:00
|
|
|
machine.sudo-groups = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
description = "Groups assigned to sudo users.";
|
|
|
|
};
|
2024-07-18 04:08:27 +00:00
|
|
|
machine.users = mkOption {
|
|
|
|
type = types.attrsOf userModule;
|
2024-07-19 12:00:55 +00:00
|
|
|
default = { };
|
2024-07-18 04:08:27 +00:00
|
|
|
description = "Users configured on this system.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
# Add required home manager modules
|
|
|
|
home-manager.sharedModules = [
|
|
|
|
# Modules
|
2025-01-23 23:50:13 +00:00
|
|
|
../../user-modules/default.nix
|
2024-07-18 21:36:50 +00:00
|
|
|
|
|
|
|
# Custom packages
|
|
|
|
../../pkgs/default.nix
|
2024-07-18 04:08:27 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Create users
|
|
|
|
users.users = attrsets.concatMapAttrs (name: value: {
|
|
|
|
${name} = {
|
|
|
|
isNormalUser = true;
|
2025-01-23 23:28:22 +00:00
|
|
|
extraGroups = mkIf value.sudo (
|
|
|
|
[
|
|
|
|
"wheel"
|
|
|
|
]
|
|
|
|
++ config.machine.sudo-groups
|
|
|
|
);
|
2024-07-18 04:08:27 +00:00
|
|
|
};
|
|
|
|
}) config.machine.users;
|
|
|
|
|
|
|
|
# Create home manager configuration for users
|
|
|
|
home-manager.users = attrsets.concatMapAttrs (name: value: {
|
|
|
|
${name} = value.configuration;
|
|
|
|
}) config.machine.users;
|
|
|
|
};
|
|
|
|
}
|