From 6b2f088cadb0439ed43d0b84205836b4fefe61b0 Mon Sep 17 00:00:00 2001 From: chn Date: Wed, 23 Aug 2023 07:43:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=89=93=E5=8C=85=20rsshub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.lock | 6 ++-- local/pkgs/rsshub/default.nix | 60 +++++++++++++++++++++++------------ 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/flake.lock b/flake.lock index 8ba2704b..56255337 100644 --- a/flake.lock +++ b/flake.lock @@ -686,11 +686,11 @@ ] }, "locked": { - "lastModified": 1692705959, - "narHash": "sha256-mdgBp7MoW8CBfbCNRI3WpyWOtWUCSrxbYVxN3pJOHPs=", + "lastModified": 1692747783, + "narHash": "sha256-yLObNmu3KF1okPqzIRd9bQ0OZCtQvwXg8Q5ETyLxkts=", "owner": "CHN-beta", "repo": "pnpm2nix-nzbr", - "rev": "b03c76371017588dba0ba3059fdf2640066ee385", + "rev": "d8470b9a8295795016e78f0340a91febbc9549aa", "type": "github" }, "original": { diff --git a/local/pkgs/rsshub/default.nix b/local/pkgs/rsshub/default.nix index 1e0f7ee0..37f112fb 100644 --- a/local/pkgs/rsshub/default.nix +++ b/local/pkgs/rsshub/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, mkPnpmPackage, fetchFromGitHub, nodejs }: +{ lib, stdenv, mkPnpmPackage, fetchFromGitHub, nodejs, writeShellScript, chromium }: let pname = "rsshub"; version = "20230823"; @@ -10,27 +10,45 @@ let hash = "sha256-oqcEZs6XLyz/iUZLhzaj/aO1re/V+hy8ij45Y6L1uKA="; }; originalPnpmPackage = mkPnpmPackage { inherit pname version src nodejs; }; -in stdenv.mkDerivation -{ - inherit pname version src; nodeModules = originalPnpmPackage.nodeModules.overrideAttrs { PUPPETEER_SKIP_DOWNLOAD = true; }; - configurePhase = + rsshub-unwrapped = stdenv.mkDerivation + { + inherit version src; + pname = "${pname}-unwrapped"; + configurePhase = + '' + export HOME=$NIX_BUILD_TOP # Some packages need a writable HOME + export npm_config_nodedir=${nodejs} + + runHook preConfigure + + ln -s ${nodeModules}/. node_modules + + runHook postConfigure + ''; + installPhase = + '' + runHook preInstall + mkdir -p $out + mv * .* $out + runHook postInstall + ''; + }; + startScript = writeShellScript "rsshub" '' - export HOME=$NIX_BUILD_TOP # Some packages need a writable HOME - export npm_config_nodedir=${nodejs} - - runHook preConfigure - - ${if installInPlace - then passthru.nodeModules.buildPhase - else '' - ${if !copyNodeModules - then "ln -s" - else "cp -r" - } ${passthru.nodeModules}/. node_modules - '' - } - - runHook postConfigure + cd ${rsshub-unwrapped} + export CHROMIUM_EXECUTABLE_PATH=$${chromium}/bin/chromium + ${nodejs.pkgs.pnpm}/bin/pnpm start + ''; +in stdenv.mkDerivation rec +{ + inherit pname version; + phases = [ "installPhase" ]; + installPhase = + '' + runHook preInstall + mkdir -p $out/bin + cp ${startScript} $out/bin/rsshub + runHook postInstall ''; }