Add multi-user support for various applications and services
Enhanced the configuration files to support multi-user management by introducing user options for multiple applications, including art, gaming, multimedia, and development tools. Updated existing modules to utilize these new user options, improving flexibility and maintainability in user package installations.
This commit is contained in:
@@ -13,6 +13,11 @@
|
||||
enable = lib.mkEnableOption "Whether to enable this script";
|
||||
install = lib.mkEnableOption "Whether to install the script package";
|
||||
service = lib.mkEnableOption "Whether to enable the script service";
|
||||
users = lib.mkOption {
|
||||
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
|
||||
default = config.my.toggleUsers.scripts;
|
||||
description = "Users to install this script for";
|
||||
};
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Name of the script.";
|
||||
@@ -39,12 +44,27 @@
|
||||
config = lib.mkIf (lib.any (s: s.enable) (lib.attrValues config.my.scripts)) {
|
||||
users.users =
|
||||
let
|
||||
packages =
|
||||
scriptList =
|
||||
config.my.scripts
|
||||
|> lib.mapAttrsToList (_name: script: lib.optional (script.enable && script.install) script.package)
|
||||
|> lib.mapAttrsToList (_name: script: lib.optional (script.enable && script.install) script)
|
||||
|> lib.flatten;
|
||||
userMap = lib.foldl' (
|
||||
acc: script:
|
||||
let
|
||||
users = inputs.self.lib.normalizeUsers script.users;
|
||||
in
|
||||
lib.foldl' (
|
||||
acc': user:
|
||||
acc'
|
||||
// {
|
||||
${user} = (acc'.${user} or [ ]) ++ [ script.package ];
|
||||
}
|
||||
) acc users
|
||||
) { } scriptList;
|
||||
in
|
||||
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.scripts packages;
|
||||
lib.mkMerge (
|
||||
lib.mapAttrsToList (user: packages: inputs.self.lib.mkUserPackages lib user packages) userMap
|
||||
);
|
||||
systemd.user.services =
|
||||
config.my.scripts
|
||||
|> lib.mapAttrs' (
|
||||
|
||||
Reference in New Issue
Block a user