2023-01-10 10:53:55 +00:00
|
|
|
{ lib
|
|
|
|
, pkgs
|
|
|
|
}:
|
|
|
|
|
|
|
|
(lib.makeScope pkgs.newScope (self:
|
|
|
|
let
|
|
|
|
# TODO: dependency-inject this.
|
|
|
|
sane-data = import ../../modules/data { inherit lib; };
|
|
|
|
template = self.callPackage ./template.nix;
|
2023-01-11 10:31:00 +00:00
|
|
|
feed-pkgs = lib.mapAttrs
|
|
|
|
(name: feed-details: template {
|
|
|
|
feedName = name;
|
|
|
|
jsonPath = "modules/data/feeds/sources/${name}/default.json";
|
|
|
|
inherit (feed-details) url;
|
|
|
|
})
|
|
|
|
sane-data.feeds;
|
|
|
|
update-scripts = lib.mapAttrsToList
|
|
|
|
(name: feed: builtins.concatStringsSep " " feed.passthru.updateScript)
|
|
|
|
feed-pkgs;
|
|
|
|
in
|
|
|
|
feed-pkgs // {
|
|
|
|
passthru.updateScript = pkgs.writeShellScript
|
|
|
|
"feeds-update"
|
|
|
|
(builtins.concatStringsSep "\n" update-scripts);
|
2023-01-11 10:41:39 +00:00
|
|
|
|
|
|
|
passthru.initFeedScript = pkgs.writeShellScript
|
|
|
|
"init-feed"
|
|
|
|
''
|
2023-01-11 13:16:26 +00:00
|
|
|
sources_dir=modules/data/feeds/sources
|
2023-01-11 10:41:39 +00:00
|
|
|
name="$1"
|
2023-01-11 10:49:56 +00:00
|
|
|
url="https://$name"
|
2023-01-11 13:16:26 +00:00
|
|
|
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
|
|
|
|
|
2023-01-13 08:59:39 +00:00
|
|
|
${./update.py} "$url" "$json_path"
|
2023-01-11 13:16:26 +00:00
|
|
|
cat "$json_path"
|
2023-01-11 10:41:39 +00:00
|
|
|
'';
|
2023-01-11 10:31:00 +00:00
|
|
|
}
|
2023-01-10 10:53:55 +00:00
|
|
|
))
|