diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 695b37d9f..49c11eac9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -109,6 +109,9 @@ Makefile @thiagokokada /modules/services/fusuma.nix @iosmanthus /tests/modules/services/fusuma @iosmanthus +/modules/programs/gallery-dl.nix @marsam +/tests/modules/programs/gallery-dl @marsam + /modules/programs/gh.nix @Gerschtli @berbiche /tests/modules/programs/gh @Gerschtli @berbiche diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 4e5ee7724..7253b1ad2 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -689,6 +689,13 @@ in A new module is available: 'programs.yt-dlp'. ''; } + + { + time = "2022-09-09T09:55:50+00:00"; + message = '' + A new module is available: 'programs.gallery-dl'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 6c7fb5bf5..2c1e66019 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -74,6 +74,7 @@ let ./programs/fish.nix ./programs/foot.nix ./programs/fzf.nix + ./programs/gallery-dl.nix ./programs/getmail.nix ./programs/gh.nix ./programs/git.nix diff --git a/modules/programs/gallery-dl.nix b/modules/programs/gallery-dl.nix new file mode 100644 index 000000000..8c42d1e7d --- /dev/null +++ b/modules/programs/gallery-dl.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.gallery-dl; + + jsonFormat = pkgs.formats.json { }; + +in { + meta.maintainers = [ maintainers.marsam ]; + + options.programs.gallery-dl = { + enable = mkEnableOption "gallery-dl"; + + settings = mkOption { + type = jsonFormat.type; + default = { }; + example = literalExpression '' + { + extractor.base-directory = "~/Downloads"; + } + ''; + description = '' + Configuration written to + $XDG_CONFIG_HOME/gallery-dl/config.json. See + + for supported values. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.gallery-dl ]; + + xdg.configFile."gallery-dl/config.json" = mkIf (cfg.settings != { }) { + source = jsonFormat.generate "gallery-dl-settings" cfg.settings; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 362adebc9..5b173a7f0 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -70,6 +70,7 @@ import nmt { ./modules/programs/emacs ./modules/programs/feh ./modules/programs/fish + ./modules/programs/gallery-dl ./modules/programs/gh ./modules/programs/git ./modules/programs/gpg diff --git a/tests/modules/programs/gallery-dl/default.nix b/tests/modules/programs/gallery-dl/default.nix new file mode 100644 index 000000000..42caef2ff --- /dev/null +++ b/tests/modules/programs/gallery-dl/default.nix @@ -0,0 +1 @@ +{ gallery-dl = ./gallery-dl.nix; } diff --git a/tests/modules/programs/gallery-dl/gallery-dl.nix b/tests/modules/programs/gallery-dl/gallery-dl.nix new file mode 100644 index 000000000..43d0daa9f --- /dev/null +++ b/tests/modules/programs/gallery-dl/gallery-dl.nix @@ -0,0 +1,28 @@ +{ ... }: + +{ + programs.gallery-dl = { + enable = true; + + settings = { + cache.file = "~/gallery-dl/cache.sqlite3"; + extractor.base-directory = "~/gallery-dl/"; + }; + }; + + test.stubs.gallery-dl = { }; + + nmt.script = '' + assertFileContent home-files/.config/gallery-dl/config.json \ + ${builtins.toFile "gallery-dl-expected-settings.json" '' + { + "cache": { + "file": "~/gallery-dl/cache.sqlite3" + }, + "extractor": { + "base-directory": "~/gallery-dl/" + } + } + ''} + ''; +}