Merge pull request #325798 from Guanran928/rsshub

This commit is contained in:
Sandro
2024-07-19 13:47:57 +02:00
committed by GitHub
2 changed files with 116 additions and 0 deletions
@@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Guanran Wang <guanran928@outlook.com>
Date: Tue, 9 Jul 2024 16:49:41 +0800
Subject: [PATCH] fix git hash
---
lib/utils/git-hash.ts | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/lib/utils/git-hash.ts b/lib/utils/git-hash.ts
index 9a8131696..f1f568fb4 100644
--- a/lib/utils/git-hash.ts
+++ b/lib/utils/git-hash.ts
@@ -1,14 +1,6 @@
import { execSync } from 'child_process';
-let gitHash = process.env.HEROKU_SLUG_COMMIT?.slice(0, 8) || process.env.VERCEL_GIT_COMMIT_SHA?.slice(0, 8);
-let gitDate: Date | undefined;
-if (!gitHash) {
- try {
- gitHash = execSync('git rev-parse HEAD').toString().trim().slice(0, 8);
- gitDate = new Date(execSync('git log -1 --format=%cd').toString().trim());
- } catch {
- gitHash = 'unknown';
- }
-}
+let gitHash = '@GIT_HASH@'.slice(0, 8);
+let gitDate = new Date('Thu Jan 1 00:00:00 1970 +0000');
export { gitHash, gitDate };
+86
View File
@@ -0,0 +1,86 @@
{
lib,
fetchFromGitHub,
makeBinaryWrapper,
nodejs,
pnpm,
stdenv,
substitute,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "rsshub";
version = "0-unstable-2024-07-08";
src = fetchFromGitHub {
owner = "DIYgod";
repo = "RSSHub";
rev = "6a29ca395191e745f991b9a0643a2fa9a66c8730";
hash = "sha256-K7qNPF1vdqhNEjWcysnj20Qaltu3rnhi1bVnIEOTiuk=";
};
patches = [
(substitute {
src = ./0001-fix-git-hash.patch;
substitutions = [
"--subst-var-by"
"GIT_HASH"
finalAttrs.src.rev
];
})
];
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-1Djef4QRLiEKr6ERtL0/IQSYp9dMq3cOCHPW4QnfaZU=";
};
nativeBuildInputs = [
makeBinaryWrapper
nodejs
pnpm.configHook
];
buildPhase = ''
runHook preBuild
pnpm build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/lib/rsshub
cp -r lib node_modules assets api package.json tsconfig.json $out/lib/rsshub
runHook postInstall
'';
preFixup = ''
makeWrapper ${lib.getExe nodejs} $out/bin/rsshub \
--chdir "$out/lib/rsshub" \
--set "NODE_ENV" "production" \
--set "NO_LOGFILES" "true" \
--set "TSX_TSCONFIG_PATH" "$out/lib/rsshub/tsconfig.json" \
--append-flags "$out/lib/rsshub/node_modules/tsx/dist/cli.mjs" \
--append-flags "$out/lib/rsshub/lib/index.ts"
'';
meta = {
description = "RSS feed generator";
longDescription = ''
RSSHub is an open source, easy to use, and extensible RSS feed generator.
It's capable of generating RSS feeds from pretty much everything.
RSSHub delivers millions of contents aggregated from all kinds of sources,
our vibrant open source community is ensuring the deliver of RSSHub's new routes,
new features and bug fixes.
'';
homepage = "https://docs.rsshub.app";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ Guanran928 ];
mainProgram = "rsshub";
platforms = lib.platforms.all;
};
})