From 50e2588f76ef70c8ea14df13e313618c00d15dcb Mon Sep 17 00:00:00 2001 From: Isabella Bastaja Date: Sun, 22 Mar 2026 21:49:41 +0100 Subject: Add wrapper-manger, wrap gallery-dl --- default.nix | 9 ++++++ flake.lock | 18 ++++++++++- flake.nix | 4 ++- wrappers/gallery-dl/config.nix | 67 +++++++++++++++++++++++++++++++++++++++++ wrappers/gallery-dl/default.nix | 19 ++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 wrappers/gallery-dl/config.nix create mode 100644 wrappers/gallery-dl/default.nix diff --git a/default.nix b/default.nix index 4c0b1ab..3a871d5 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,6 @@ { pkgs ? import { }, + wrapper-manager, }: let @@ -36,10 +37,18 @@ let sorremacs = callPackage ./pkgs/sorremacs { }; lightnovel-crawler = callPackage ./pkgs/lightnovel-crawler.nix { }; }; + + wm-eval = wrapper-manager.lib { + inherit pkgs; + modules = [ + ./wrappers/gallery-dl + ]; + }; in { lib = import ./lib { inherit pkgs; }; modules = import ./modules; overlays = import ./overlays; + wrappers = wm-eval.config.build.packages; } // packages diff --git a/flake.lock b/flake.lock index eeb56d4..a8ff143 100644 --- a/flake.lock +++ b/flake.lock @@ -75,7 +75,8 @@ "inputs": { "emacs-overlay": "emacs-overlay", "futils": "futils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "wrapper-manager": "wrapper-manager" } }, "systems": { @@ -92,6 +93,21 @@ "repo": "default", "type": "github" } + }, + "wrapper-manager": { + "locked": { + "lastModified": 1772780728, + "narHash": "sha256-fCm4sOeTDf3kBtYMmU4OHsviI/oF8rMbPkUMcQf6lw4=", + "owner": "viperML", + "repo": "wrapper-manager", + "rev": "51ad0422b925d830bf4af36979fed51209f79c0a", + "type": "github" + }, + "original": { + "owner": "viperML", + "repo": "wrapper-manager", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 9677751..0f99bea 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,7 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; futils.url = "git+https://git.sorre.xyz/isabella/futils"; + wrapper-manager.url = "github:viperML/wrapper-manager"; emacs-overlay = { url = "github:nix-community/emacs-overlay"; inputs.nixpkgs.follows = "nixpkgs"; @@ -16,6 +17,7 @@ nixpkgs, futils, emacs-overlay, + wrapper-manager, }: futils.lib.eachSystem ( system: @@ -26,7 +28,7 @@ }; in { - legacyPackages = import ./default.nix { inherit pkgs; }; + legacyPackages = import ./default.nix { inherit pkgs wrapper-manager; }; packages = nixpkgs.lib.filterAttrs (_: v: nixpkgs.lib.isDerivation v) self.legacyPackages.${system}; } ); diff --git a/wrappers/gallery-dl/config.nix b/wrappers/gallery-dl/config.nix new file mode 100644 index 0000000..649eeda --- /dev/null +++ b/wrappers/gallery-dl/config.nix @@ -0,0 +1,67 @@ +{ + postprocessors = [ + { + name = "metadata"; + mode = "json"; + whitelist = [ + "danbooru" + "moebooru" + "gelbooru" + "sankaku" + "nhentai" + "rule34" + ]; + } + { + name = "zip"; + compression = "store"; + extension = "cbz"; + filter = "extension not in ('zip', 'rar')"; + whitelist = [ + "nhentai" + "mangadex" + ]; + } + ]; + + Danbooru.metadata = true; + + reddit = { + archive-format = "s_{subreddit}{filename}"; + directory = { + "locals().get('is_gallery')" = [ + "Reddit" + "S" + "{subreddit!C}" + "{title[:120]!t:?/_/R /_/}{id}" + ]; + "" = [ + "Reddit" + "S" + "{subreddit!C}" + ]; + }; + + filename = { + "locals().get('is_gallery')" = "{title[:120]!t:?/_/R /_/}{id}{num:?_//>02}.{extension}"; + "" = "{title[:120]!t:?/_/R /_/}{id}.{extension}"; + }; + }; + + artstation.external = true; # Try to follow external URLs of embedded players. + + ao3.formats = [ + "pdf" + "epub" + "html" + ]; + + bluesky = { + include = [ "all" ]; # List of subcategories to include when processing a **user profile**. + metadata = [ + "facets" + "user" + ]; + quoted = true; # Fetch media from quoted posts. + }; +} diff --git a/wrappers/gallery-dl/default.nix b/wrappers/gallery-dl/default.nix new file mode 100644 index 0000000..1c640f8 --- /dev/null +++ b/wrappers/gallery-dl/default.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: +let + jsonFormat = pkgs.formats.json { }; + config = (import ./config.nix); + jsonConfig = jsonFormat.generate "gallery-dl-config" config; +in +{ + wrappers.gallery-dl = { + basePackage = pkgs.gallery-dl; + prependFlags = [ + "--config" + jsonConfig + "--option" + # NOTE: escape the $ here because makeCWrapper otherwise expands it, + # evaluating to `/homeless-shelter` + "base-directory=\\$HOME/Pictures/gallery-dl" # TODO: maybe mandate XDG + ]; + }; +} -- cgit v1.3.1