nixos/local/pkgs/rsshub/default.nix

58 lines
1.3 KiB
Nix
Raw Normal View History

2023-08-23 17:31:37 +08:00
{
2023-09-01 21:05:26 +08:00
lib, stdenv, mkPnpmPackage, fetchFromGitHub, nodejs, writeShellScript,
chromium, bash
2023-08-23 17:31:37 +08:00
}:
2023-08-23 07:22:53 +08:00
let
2023-10-05 11:30:12 +08:00
name = "rsshub";
2023-08-14 20:57:56 +08:00
src = fetchFromGitHub
2023-09-01 21:05:26 +08:00
{
owner = "DIYgod";
repo = "RSSHub";
2023-10-05 11:30:12 +08:00
rev = "67d4a7ed3f877a8ceac6caebe874c4ce5c210bd8";
sha256 = "baJQWGrr1RdZoI2uAGp2uJO9epbjAUjks76knJSwVdE=";
2023-09-01 21:05:26 +08:00
};
2023-10-05 11:30:12 +08:00
originalPnpmPackage = mkPnpmPackage { inherit name src nodejs; };
2023-09-01 21:05:26 +08:00
nodeModules = originalPnpmPackage.nodeModules.overrideAttrs { PUPPETEER_SKIP_DOWNLOAD = true; };
rsshub-unwrapped = stdenv.mkDerivation
{
2023-10-05 11:30:12 +08:00
inherit src;
name = "${name}-unwrapped";
2023-09-01 21:05:26 +08:00
configurePhase =
''
export HOME=$NIX_BUILD_TOP # Some packages need a writable HOME
export npm_config_nodedir=${nodejs}
2023-08-23 07:22:53 +08:00
2023-09-01 21:05:26 +08:00
runHook preConfigure
2023-08-23 07:22:53 +08:00
2023-09-01 21:05:26 +08:00
ln -s ${nodeModules}/. node_modules
2023-08-23 07:22:53 +08:00
2023-09-01 21:05:26 +08:00
runHook postConfigure
'';
installPhase =
''
runHook preInstall
mkdir -p $out
mv * .* $out
runHook postInstall
'';
};
startScript = writeShellScript "rsshub"
''
cd ${rsshub-unwrapped}
export PATH=${lib.makeBinPath [ bash nodejs nodejs.pkgs.pnpm chromium ]}:$PATH
export CHROMIUM_EXECUTABLE_PATH=chromium
pnpm start
'';
2023-10-05 11:30:12 +08:00
in stdenv.mkDerivation
2023-08-23 07:43:21 +08:00
{
2023-10-05 11:30:12 +08:00
inherit name;
2023-09-01 21:05:26 +08:00
phases = [ "installPhase" ];
installPhase =
''
runHook preInstall
mkdir -p $out/bin
cp ${startScript} $out/bin/rsshub
runHook postInstall
'';
2023-08-14 20:57:56 +08:00
}