multi-user toggle init

This commit is contained in:
Danilo Reyes
2026-01-16 10:19:36 -06:00
parent 597f9ee5b8
commit 4e835aca1b
31 changed files with 304 additions and 119 deletions

View File

@@ -8,41 +8,53 @@
{
options.my.shell.multimedia.enable = lib.mkEnableOption "multimedia CLI tools and codecs";
config = lib.mkIf config.my.shell.multimedia.enable {
sops.secrets."gallery-dl/secrets" = {
sops.secrets."gallery-dl/secrets" = let
# Use first user for secret ownership
user = if lib.isString config.my.toggleUsers.shell then config.my.toggleUsers.shell else (lib.head config.my.toggleUsers.shell);
in {
sopsFile = ../../secrets/gallery.yaml;
owner = "jawz";
owner = user;
mode = "0400";
};
home-manager.users.jawz.programs = {
yt-dlp = {
enable = true;
settings = {
embed-thumbnail = true;
embed-subs = true;
sub-langs = "all";
cookies-from-browser = "firefox+gnomekeyring:/home/jawz/.librewolf/jawz";
home-manager.users = let
users = if lib.isString config.my.toggleUsers.shell then [ config.my.toggleUsers.shell ] else config.my.toggleUsers.shell;
in lib.mkMerge (map (user: {
${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.jawz.packages = builtins.attrValues {
}) users);
users.users = let
users = if lib.isString config.my.toggleUsers.shell then [ config.my.toggleUsers.shell ] else config.my.toggleUsers.shell;
packages = builtins.attrValues {
inherit (pkgs)
ffmpeg # not ffmpreg, the coolest video conversion tool!
imagemagick # photoshop what??
ffpb # make ffmpeg encoding... a bit fun
;
};
};
in lib.mkMerge (map (user: {
${user}.packages = packages;
}) users);
};
}