Introduced a new file `lib.nix` containing helper functions to streamline user package management and attributes for multi-user configurations. Updated various modules to utilize these functions, enhancing code maintainability and readability.
60 lines
1.8 KiB
Nix
60 lines
1.8 KiB
Nix
{
|
|
config,
|
|
inputs,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
{
|
|
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" = let
|
|
userLib = import ../lib.nix { inherit lib; };
|
|
# Use first user for secret ownership
|
|
user = userLib.getFirstUser config.my.toggleUsers.shell;
|
|
in {
|
|
sopsFile = ../../secrets/gallery.yaml;
|
|
owner = user;
|
|
mode = "0400";
|
|
};
|
|
home-manager.users = let
|
|
userLib = import ../lib.nix { inherit lib; };
|
|
in userLib.mkHomeManagerUsers 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}";
|
|
};
|
|
};
|
|
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
|
|
userLib = import ../lib.nix { inherit lib; };
|
|
packages = builtins.attrValues {
|
|
inherit (pkgs)
|
|
ffmpeg # not ffmpreg, the coolest video conversion tool!
|
|
imagemagick # photoshop what??
|
|
ffpb # make ffmpeg encoding... a bit fun
|
|
;
|
|
};
|
|
in userLib.mkUserPackages config.my.toggleUsers.shell packages;
|
|
};
|
|
}
|