2023-01-10 10:53:55 +00:00
|
|
|
{ lib
|
2023-09-24 12:11:28 +00:00
|
|
|
, newScope
|
2023-03-11 10:12:17 +00:00
|
|
|
, python3
|
2023-05-03 05:59:48 +00:00
|
|
|
, sane-data
|
2023-03-22 21:21:00 +00:00
|
|
|
, static-nix-shell
|
2023-03-11 09:59:53 +00:00
|
|
|
, writeShellScript
|
2023-01-10 10:53:55 +00:00
|
|
|
}:
|
|
|
|
|
2023-09-24 12:11:28 +00:00
|
|
|
lib.makeScope newScope (self: with self; {
|
|
|
|
mkFeed = callPackage ./template.nix {};
|
|
|
|
feed-pkgs = lib.recurseIntoAttrs (lib.mapAttrs
|
|
|
|
(name: feed-details: mkFeed {
|
2023-03-11 09:59:53 +00:00
|
|
|
feedName = name;
|
|
|
|
jsonPath = "modules/data/feeds/sources/${name}/default.json";
|
|
|
|
inherit (feed-details) url;
|
|
|
|
})
|
2023-09-24 12:11:28 +00:00
|
|
|
sane-data.feeds
|
|
|
|
);
|
|
|
|
update-feed = static-nix-shell.mkPython3Bin {
|
2023-03-11 10:12:17 +00:00
|
|
|
pname = "update";
|
2024-02-25 17:37:38 +00:00
|
|
|
srcRoot = ./.;
|
2023-03-22 21:21:00 +00:00
|
|
|
pyPkgs = [ "feedsearch-crawler" ];
|
|
|
|
srcPath = "update.py";
|
2023-03-11 10:12:17 +00:00
|
|
|
};
|
2023-03-11 10:29:02 +00:00
|
|
|
init-feed = writeShellScript
|
|
|
|
"init-feed"
|
|
|
|
''
|
|
|
|
# this is the `nix run '.#init-feed' <url>` 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
|
|
|
|
|
2023-09-24 12:11:28 +00:00
|
|
|
${update-feed}/bin/update.py "$name" "$json_path"
|
2023-03-11 10:29:02 +00:00
|
|
|
cat "$json_path"
|
|
|
|
'';
|
2023-09-24 12:11:28 +00:00
|
|
|
})
|