Reorganized
This commit is contained in:
1 parent
c3c61ce654
commit
760815da50
145 files changed
-1444
No files matched your search
@@ -0,0 +1,79 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
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.";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
# Import systemwide configuration
|
||||
./systemwide.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
machine.sudo-groups = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "Groups assigned to sudo users.";
|
||||
};
|
||||
machine.users = mkOption {
|
||||
type = types.attrsOf userModule;
|
||||
default = { };
|
||||
description = "Users configured on this system.";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
# Add required home manager modules
|
||||
home-manager.sharedModules = [
|
||||
# Modules
|
||||
../../user-modules/default.nix
|
||||
|
||||
# Custom packages
|
||||
../../pkgs/default.nix
|
||||
];
|
||||
|
||||
# Create users
|
||||
users.users = attrsets.concatMapAttrs (name: value: {
|
||||
${name} = {
|
||||
isNormalUser = true;
|
||||
extraGroups = mkIf value.sudo (
|
||||
[
|
||||
"wheel"
|
||||
]
|
||||
++ config.machine.sudo-groups
|
||||
);
|
||||
};
|
||||
}) config.machine.users;
|
||||
|
||||
# Create home manager configuration for users
|
||||
home-manager.users = attrsets.concatMapAttrs (name: value: {
|
||||
${name} = value.configuration;
|
||||
}) config.machine.users;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
moduleFiles = [
|
||||
../../user-modules/desktop/systemwide.nix
|
||||
../../user-modules/development/systemwide.nix
|
||||
../../user-modules/gaming/systemwide.nix
|
||||
../../user-modules/keyring/systemwide.nix
|
||||
];
|
||||
|
||||
moduleConfig = lists.foldr (file: acc: recursiveUpdate acc (import file)) { } moduleFiles;
|
||||
|
||||
moduleNames = attrNames moduleConfig;
|
||||
|
||||
mkModule =
|
||||
name: moduleConfig:
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
config =
|
||||
mkIf
|
||||
(any (
|
||||
user:
|
||||
(
|
||||
config.home-manager.users.${user}.modules.${name}.enable
|
||||
|| (any (specialisation: specialisation.configuration.modules.${name}.enable) (
|
||||
attrValues config.home-manager.users.${user}.specialisation
|
||||
))
|
||||
)
|
||||
) (attrNames config.home-manager.users))
|
||||
(if (isAttrs moduleConfig) then moduleConfig else (moduleConfig { inherit config pkgs; }));
|
||||
};
|
||||
|
||||
imports = map (name: mkModule name moduleConfig."${name}") moduleNames;
|
||||
in
|
||||
{
|
||||
imports = imports;
|
||||
}
|
||||
Reference in new issue
Block a user