download modularized

This commit is contained in:
Danilo Reyes 2024-06-13 12:38:12 -06:00
parent 17c3d7a98f
commit 5475527ef3

View File

@ -1,7 +1,21 @@
{ pkgs, lib, config, ... }: { { pkgs, lib, config, ... }: {
imports = [ ./base.nix ]; imports = [ ./base.nix ];
options.my.units.download.enable = lib.mkEnableOption "enable"; options.my.units.download.enable = lib.mkEnableOption "enable";
config = { config = let
download = pkgs.python3Packages.buildPythonApplication {
pname = "download";
version = "2.5";
src = ../../scripts/download/.;
buildInputs = [ pkgs.python3Packages.setuptools ];
propagatedBuildInputs = with pkgs; [
python3Packages.pyyaml
python3Packages.types-pyyaml
yt-dlp
gallery-dl
ffmpeg
];
};
in {
home-manager.users.jawz = { home-manager.users.jawz = {
xdg.configFile."gallery-dl/config.json".source = xdg.configFile."gallery-dl/config.json".source =
../../dotfiles/gallery-dl/config.json; ../../dotfiles/gallery-dl/config.json;
@ -27,23 +41,20 @@
restartIfChanged = true; restartIfChanged = true;
description = "Downloads ${desc}"; description = "Downloads ${desc}";
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];
path = [ pkgs.bash ]; path = [ pkgs.bash download ];
serviceConfig = { serviceConfig = {
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 30; RestartSec = 30;
ExecStart = execStartCmd; ExecStart = "${download}/bin/download ${execStartCmd}";
}; };
}; };
in { in {
tuhmayto = mkDownloadService "tuhmayto stuff" '' tuhmayto = mkDownloadService "tuhmayto stuff" ''
/etc/profiles/per-user/jawz/bin/download \ -u jawz -i https://x.com/tuhmayto/media \
-u jawz -i https://twitter.com/tuhmayto/media \ https://www.furaffinity.net/user/tuhmayto/'';
https://www.furaffinity.net/user/tuhmayto/''; "download@" = mkDownloadService "post from multiple sources" "%I";
"download@" = mkDownloadService "post from multiple sources" "instagram@" = mkDownloadService "post types from instagram"
"/etc/profiles/per-user/jawz/bin/download %I"; "instagram -u jawz -t %I";
"instagram@" = mkDownloadService "post types from instagram" ''
/etc/profiles/per-user/jawz/bin/download \
instagram -u jawz -t %I'';
}; };
timers = let timers = let
downloadTimer = time: delay: { downloadTimer = time: delay: {
@ -76,18 +87,7 @@
install = true; install = true;
service = false; service = false;
name = "download"; name = "download";
package = pkgs.python3Packages.buildPythonApplication { package = download;
pname = "download";
version = "2.5";
src = ../../scripts/download/.;
buildInputs =
[ pkgs.python3Packages.setuptools pkgs.gallery-dl pkgs.ffmpeg ];
propagatedBuildInputs = with pkgs.python3Packages; [
pyyaml
types-pyyaml
yt-dlp
];
};
}; };
}; };
} }