From a0dfdb5125c5280f6b979c51e0e84b4133d78d32 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 24 Jun 2024 17:04:11 +0000 Subject: [PATCH] init-feed: lift out of pkgs/ and into scripts/ where its easier to invoke --- pkgs/additional/feeds/default.nix | 22 ---------------------- scripts/init-feed | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 22 deletions(-) create mode 100755 scripts/init-feed diff --git a/pkgs/additional/feeds/default.nix b/pkgs/additional/feeds/default.nix index 6d7a6c115..672027b66 100644 --- a/pkgs/additional/feeds/default.nix +++ b/pkgs/additional/feeds/default.nix @@ -44,26 +44,4 @@ lib.makeScope newScope (self: with self; { 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" - ''; }) diff --git a/scripts/init-feed b/scripts/init-feed new file mode 100755 index 000000000..3aaaf3ca5 --- /dev/null +++ b/scripts/init-feed @@ -0,0 +1,21 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p feeds.update-feed -p gnused + +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.py: from `feeds.update-feed` (TODO: rename the binary!) +update.py "$name" "$json_path" +cat "$json_path"