Skip to content

Commit

Permalink
feat(pkgs/rsshub): improve packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
wrvsrx committed Apr 11, 2024
1 parent 32eef23 commit 3c559b4
Showing 1 changed file with 60 additions and 49 deletions.
109 changes: 60 additions & 49 deletions pkgs/to-normal-packages/rsshub/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
mkPnpmPackage,
stdenvNoCC,
nodePackages,
source,
writeText,
writeShellScriptBin,
bash,
source,
}:
let
node-modules =
Expand All @@ -12,52 +14,61 @@ let
installEnv.PUPPETEER_SKIP_DOWNLOAD = "1";
# noDevDependencies = true;
}).passthru.nodeModules;
rsshub-website = stdenvNoCC.mkDerivation {
inherit (source) pname version src;
patches = [
(writeText "git.patch" ''
diff --git a/lib/utils/git-hash.ts b/lib/utils/git-hash.ts
index 9a8131696..62afc27ec 100644
--- a/lib/utils/git-hash.ts
+++ b/lib/utils/git-hash.ts
@@ -1,14 +1,14 @@
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 = '${source.version}'.slice(0, 8);
+let gitDate: Date | undefined = new Date('${source.date}');
+// 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';
+// }
+// }
export { gitHash, gitDate };
'')
];
buildInputs = [ nodePackages.pnpm ];
buildPhase = ''
ln -s ${node-modules}/node_modules node_modules
pnpm build
'';
installPhase = ''
mkdir -p $out
mkdir -p $out/assets
ln -s ${node-modules}/node_modules $out/node_modules
cp -r assets/build $out/assets/build
cp -r lib package.json tsconfig.json $out
mkdir -p $out/bin
cat > $out/bin/rsshub <<- EOF
#!${bash}/bin/bash
TSX_TSCONFIG_PATH=$out/tsconfig.json ${nodePackages.nodejs}/bin/node $out/node_modules/tsx/dist/cli.mjs $out/lib/index.ts
EOF
chmod +x $out/bin/rsshub
'';
};
in
stdenvNoCC.mkDerivation {
inherit (source) pname version src;
patches = [
(writeText "git.patch" ''
diff --git a/lib/utils/git-hash.ts b/lib/utils/git-hash.ts
index 9a8131696..62afc27ec 100644
--- a/lib/utils/git-hash.ts
+++ b/lib/utils/git-hash.ts
@@ -1,14 +1,14 @@
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 = '${source.version}'.slice(0, 8);
+let gitDate: Date | undefined = new Date('${source.date}');
+// 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';
+// }
+// }
export { gitHash, gitDate };
'')
];
buildInputs = [ nodePackages.pnpm ];
buildPhase = ''
ln -s ${node-modules}/node_modules node_modules
pnpm build
'';
installPhase = ''
mkdir -p $out
mkdir -p $out/assets
ln -s ${node-modules}/node_modules $out/node_modules
cp -r assets/build $out/assets/build
cp -r lib package.json tsconfig.json $out
'';
}
rsshub-website

0 comments on commit 3c559b4

Please sign in to comment.