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:
@@ -6,19 +6,26 @@
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.my.shell.type = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"bash"
|
||||
"zsh"
|
||||
];
|
||||
default = "bash";
|
||||
description = "The shell to use system-wide (bash or zsh)";
|
||||
options.my.shell = {
|
||||
type = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"bash"
|
||||
"zsh"
|
||||
];
|
||||
default = "bash";
|
||||
description = "The shell to use system-wide (bash or zsh)";
|
||||
};
|
||||
users = lib.mkOption {
|
||||
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
|
||||
default = config.my.toggleUsers.shell;
|
||||
description = "Users to configure shell for";
|
||||
};
|
||||
};
|
||||
config = {
|
||||
users.users = lib.mkMerge (
|
||||
map (user: {
|
||||
${user}.shell = pkgs.${config.my.shell.type};
|
||||
}) (inputs.self.lib.normalizeUsers config.my.toggleUsers.shell)
|
||||
}) (inputs.self.lib.normalizeUsers config.my.shell.users)
|
||||
);
|
||||
programs.zsh.enable = config.my.shell.type == "zsh";
|
||||
};
|
||||
|
||||
@@ -6,7 +6,14 @@
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.my.shell.exercism.enable = lib.mkEnableOption "Exercism coding practice platform";
|
||||
options.my.shell.exercism = {
|
||||
enable = lib.mkEnableOption "Exercism coding practice platform";
|
||||
users = lib.mkOption {
|
||||
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
|
||||
default = config.my.toggleUsers.shell;
|
||||
description = "Users to install Exercism for";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf config.my.shell.exercism.enable {
|
||||
users.users =
|
||||
let
|
||||
@@ -17,6 +24,6 @@
|
||||
;
|
||||
};
|
||||
in
|
||||
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.shell packages;
|
||||
inputs.self.lib.mkUserPackages lib config.my.shell.exercism.users packages;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,44 +6,52 @@
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.my.shell.multimedia.enable = lib.mkEnableOption "multimedia CLI tools and codecs";
|
||||
options.my.shell.multimedia = {
|
||||
enable = lib.mkEnableOption "multimedia CLI tools and codecs";
|
||||
users = lib.mkOption {
|
||||
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
|
||||
default = config.my.toggleUsers.shell;
|
||||
description = "Users to install multimedia shell tools for";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf config.my.shell.multimedia.enable {
|
||||
sops.secrets."gallery-dl/secrets" =
|
||||
let
|
||||
# Use first user for secret ownership
|
||||
user = inputs.self.lib.getFirstUser config.my.toggleUsers.shell;
|
||||
user = inputs.self.lib.getFirstUser config.my.shell.multimedia.users;
|
||||
in
|
||||
{
|
||||
sopsFile = ../../secrets/gallery.yaml;
|
||||
owner = user;
|
||||
mode = "0400";
|
||||
};
|
||||
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.shell (user: {
|
||||
programs = {
|
||||
yt-dlp = {
|
||||
enable = true;
|
||||
settings = {
|
||||
embed-thumbnail = true;
|
||||
embed-subs = true;
|
||||
sub-langs = "all";
|
||||
cookies-from-browser = "firefox+gnomekeyring:/home/${user}/.librewolf/${user}";
|
||||
home-manager.users =
|
||||
inputs.self.lib.mkHomeManagerUsers lib config.my.shell.multimedia.users
|
||||
(user: {
|
||||
programs = {
|
||||
yt-dlp = {
|
||||
enable = true;
|
||||
settings = {
|
||||
embed-thumbnail = true;
|
||||
embed-subs = true;
|
||||
sub-langs = "all";
|
||||
cookies-from-browser = "firefox+gnomekeyring:/home/${user}/.librewolf/${user}";
|
||||
};
|
||||
};
|
||||
gallery-dl = {
|
||||
enable = true;
|
||||
settings = inputs.self.lib.importDotfile ../../dotfiles/gallery-dl.nix;
|
||||
};
|
||||
${config.my.shell.type} = {
|
||||
initExtra = lib.mkAfter ''
|
||||
if [ -r "${config.sops.secrets."gallery-dl/secrets".path}" ]; then
|
||||
set -a # automatically export all variables
|
||||
source "${config.sops.secrets."gallery-dl/secrets".path}"
|
||||
set +a # stop automatically exporting
|
||||
fi
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
gallery-dl = {
|
||||
enable = true;
|
||||
settings = inputs.self.lib.importDotfile ../../dotfiles/gallery-dl.nix;
|
||||
};
|
||||
${config.my.shell.type} = {
|
||||
initExtra = lib.mkAfter ''
|
||||
if [ -r "${config.sops.secrets."gallery-dl/secrets".path}" ]; then
|
||||
set -a # automatically export all variables
|
||||
source "${config.sops.secrets."gallery-dl/secrets".path}"
|
||||
set +a # stop automatically exporting
|
||||
fi
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
users.users =
|
||||
let
|
||||
packages = builtins.attrValues {
|
||||
@@ -54,6 +62,6 @@
|
||||
;
|
||||
};
|
||||
in
|
||||
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.shell packages;
|
||||
inputs.self.lib.mkUserPackages lib config.my.shell.multimedia.users packages;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,9 +9,16 @@ let
|
||||
shellType = config.my.shell.type;
|
||||
in
|
||||
{
|
||||
options.my.shell.tools.enable = lib.mkEnableOption "shell tools and utilities";
|
||||
options.my.shell.tools = {
|
||||
enable = lib.mkEnableOption "shell tools and utilities";
|
||||
users = lib.mkOption {
|
||||
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
|
||||
default = config.my.toggleUsers.shell;
|
||||
description = "Users to install shell tools for";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf config.my.shell.tools.enable {
|
||||
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.shell (user: {
|
||||
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.shell.tools.users (user: {
|
||||
programs = {
|
||||
hstr.enable = true;
|
||||
htop = {
|
||||
@@ -114,7 +121,7 @@ in
|
||||
;
|
||||
};
|
||||
in
|
||||
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.shell packages;
|
||||
inputs.self.lib.mkUserPackages lib config.my.shell.tools.users packages;
|
||||
environment.variables = {
|
||||
HISTFILE = "\${XDG_STATE_HOME}/bash/history";
|
||||
LESSHISTFILE = "-";
|
||||
|
||||
Reference in New Issue
Block a user