mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
anime-downloader: add module
This commit is contained in:
parent
4889a25756
commit
95419fb985
4 changed files with 142 additions and 0 deletions
71
modules/programs/anime-downloader.nix
Normal file
71
modules/programs/anime-downloader.nix
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkIf
|
||||||
|
mkEnableOption
|
||||||
|
mkPackageOption
|
||||||
|
mkOption
|
||||||
|
;
|
||||||
|
|
||||||
|
cfg = config.programs.anime-downloader;
|
||||||
|
jsonFormat = pkgs.formats.json { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||||
|
options.programs.anime-downloader = {
|
||||||
|
enable = mkEnableOption "anime-downloader";
|
||||||
|
package = mkPackageOption pkgs "anime-downloader" { nullable = true; };
|
||||||
|
settings = mkOption {
|
||||||
|
inherit (jsonFormat) type;
|
||||||
|
default = { };
|
||||||
|
example = {
|
||||||
|
dl = {
|
||||||
|
aria2c_for_torrents = false;
|
||||||
|
chunk_size = "10";
|
||||||
|
download_dir = ".";
|
||||||
|
external_downloader = "{aria2}";
|
||||||
|
fallback_qualities = [
|
||||||
|
"720p"
|
||||||
|
"480p"
|
||||||
|
"360p"
|
||||||
|
];
|
||||||
|
file_format = "{anime_title}/{anime_title}_{ep_no}";
|
||||||
|
force_download = false;
|
||||||
|
player = null;
|
||||||
|
provider = "twist.moe";
|
||||||
|
quality = "1080p";
|
||||||
|
skip_download = false;
|
||||||
|
url = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Configuration settings for anime-downloader. All available options can be found here:
|
||||||
|
<https://anime-downlader.readthedocs.io/en/latest/usage/config.html#config-json>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
configDir =
|
||||||
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
"Library/Application Support/anime downloader"
|
||||||
|
else
|
||||||
|
"${lib.removePrefix config.home.homeDirectory config.xdg.configHome}/anime-downloader";
|
||||||
|
in
|
||||||
|
mkIf cfg.enable {
|
||||||
|
assertions = [
|
||||||
|
(lib.hm.assertions.assertPlatform "programs.anime-downloader" pkgs lib.platforms.linux)
|
||||||
|
];
|
||||||
|
|
||||||
|
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
home.file."${configDir}/config.json" = mkIf (cfg.settings != { }) {
|
||||||
|
source = jsonFormat.generate "config.json" cfg.settings;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
20
tests/modules/programs/anime-downloader/config.json
Normal file
20
tests/modules/programs/anime-downloader/config.json
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"dl": {
|
||||||
|
"aria2c_for_torrents": false,
|
||||||
|
"chunk_size": "10",
|
||||||
|
"download_dir": ".",
|
||||||
|
"external_downloader": "{aria2}",
|
||||||
|
"fallback_qualities": [
|
||||||
|
"720p",
|
||||||
|
"480p",
|
||||||
|
"360p"
|
||||||
|
],
|
||||||
|
"file_format": "{anime_title}/{anime_title}_{ep_no}",
|
||||||
|
"force_download": false,
|
||||||
|
"player": null,
|
||||||
|
"provider": "twist.moe",
|
||||||
|
"quality": "1080p",
|
||||||
|
"skip_download": false,
|
||||||
|
"url": false
|
||||||
|
}
|
||||||
|
}
|
||||||
5
tests/modules/programs/anime-downloader/default.nix
Normal file
5
tests/modules/programs/anime-downloader/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
|
||||||
|
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||||
|
anime-downloader-settings = ./settings.nix;
|
||||||
|
}
|
||||||
46
tests/modules/programs/anime-downloader/settings.nix
Normal file
46
tests/modules/programs/anime-downloader/settings.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.anime-downloader = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
dl = {
|
||||||
|
aria2c_for_torrents = false;
|
||||||
|
chunk_size = "10";
|
||||||
|
download_dir = ".";
|
||||||
|
external_downloader = "{aria2}";
|
||||||
|
fallback_qualities = [
|
||||||
|
"720p"
|
||||||
|
"480p"
|
||||||
|
"360p"
|
||||||
|
];
|
||||||
|
file_format = "{anime_title}/{anime_title}_{ep_no}";
|
||||||
|
force_download = false;
|
||||||
|
player = null;
|
||||||
|
provider = "twist.moe";
|
||||||
|
quality = "1080p";
|
||||||
|
skip_download = false;
|
||||||
|
url = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script =
|
||||||
|
let
|
||||||
|
configDir =
|
||||||
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
"Library/Application Support/anime downloader"
|
||||||
|
else
|
||||||
|
"${lib.removePrefix config.home.homeDirectory config.xdg.configHome}/anime-downloader";
|
||||||
|
in
|
||||||
|
''
|
||||||
|
assertFileExists "home-files/${configDir}/config.json"
|
||||||
|
assertFileContent "home-files/${configDir}/config.json" \
|
||||||
|
${./config.json}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue