From 0c32f807e63f5ed1e2446915bb17316ec3f0f2be Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 11 Mar 2023 10:12:17 +0000 Subject: [PATCH] pkgs/feeds: rework the update script so that it can be built ahead-of-time, as a package, instead of just-in-time --- pkgs/feeds/default.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pkgs/feeds/default.nix b/pkgs/feeds/default.nix index 9538e531..2e6954c5 100644 --- a/pkgs/feeds/default.nix +++ b/pkgs/feeds/default.nix @@ -1,5 +1,7 @@ { lib , callPackage +, python3 +, stdenv , writeShellScript }: @@ -17,8 +19,24 @@ let update-scripts = lib.mapAttrsToList (name: feed: builtins.concatStringsSep " " feed.passthru.updateScript) feed-pkgs; -in { +in rec { # TODO: make this a scope inherit feed-pkgs; + update = stdenv.mkDerivation { + pname = "update"; + version = "0.1.0"; + src = ./.; + patchPhase = + let + pyEnv = python3.withPackages (ps: [ ps.feedsearch-crawler ]); + in '' + substituteInPlace ./update.py \ + --replace "#!/usr/bin/env nix-shell" "#!${pyEnv.interpreter}" + ''; + installPhase = '' + mkdir -p $out/bin + mv update.py $out/bin/update.py + ''; + }; passthru = { updateScript = writeShellScript "feeds-update" @@ -43,7 +61,7 @@ in { # but in a way where the least could go wrong. pushd "$sources_dir"; mkdir -p "$name"; popd - ${./update.py} "$name" "$json_path" + ${update}/bin/update.py "$name" "$json_path" cat "$json_path" ''; };