{ lib , newScope , python3 , sane-data , static-nix-shell , symlinkJoin , writeShellScript }: lib.makeScope newScope (self: with self; { mkFeed = callPackage ./template.nix {}; feed-pkgs = let byName = lib.mapAttrs (name: feed-details: mkFeed { feedName = name; jsonPath = "modules/data/feeds/sources/${name}/default.json"; inherit (feed-details) url; }) sane-data.feeds ; in symlinkJoin { # this meta package exists primarily to link all the feed updaters # into a single package which can *actually* be updated. # it's not critical whether the actual package itself builds. name = "feed-pkgs"; pname = "feed-pkgs"; version = "20230112"; paths = builtins.attrValues byName; passthru = byName // { updateScript = let update-all-feeds = writeShellScript "update-all-feeds" ( lib.concatStringsSep "\n" ( builtins.map (p: lib.concatStringsSep " " p.updateScript) (lib.attrValues byName) ) ); in [ update-all-feeds ]; }; }; update-feed = static-nix-shell.mkPython3Bin { pname = "update"; srcRoot = ./.; pyPkgs = [ "feedsearch-crawler" ]; srcPath = "update.py"; }; init-feed = writeShellScript "init-feed" '' # this is the `nix run '.#init-feed' ` script` sources_dir=modules/data/feeds/sources # prettify the URL, by default name=$( \ echo "$1" \ | sed 's|^https://||' \ | sed 's|^http://||' \ | sed 's|^www\.||' \ | sed 's|/+$||' \ ) json_path="$sources_dir/$name/default.json" # the name could have slashes in it, so we want to mkdir -p that # but in a way where the least could go wrong. pushd "$sources_dir"; mkdir -p "$name"; popd ${update-feed}/bin/update.py "$name" "$json_path" cat "$json_path" ''; })