mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-03-13 10:30:18 +08:00
* feat(nix): add flake module and offline-friendly build * chore(nix): upgrade to Node.js 24 and pnpm 10 Update devenv.nix to match project dependencies: - Upgrade Node.js from 22 to 24 (aligns with Dockerfile node:24-bookworm) - Upgrade pnpm from 9 to 10 (aligns with package.json pnpm@10.22.0) * test: fix buffer-get test timeout Replace external URL with mock server endpoint to prevent test timeout. The test was trying to fetch from http://example.com which is not mocked, causing it to timeout. Now uses http://rsshub.test/headers which is properly mocked in the test setup.
109 lines
2.9 KiB
Nix
109 lines
2.9 KiB
Nix
{ pkgs, lib, config, ... }:
|
|
|
|
{
|
|
# https://devenv.sh/basics/
|
|
env = {
|
|
NODE_ENV = "dev";
|
|
NODE_OPTIONS = "--max-http-header-size=32768";
|
|
};
|
|
|
|
# https://devenv.sh/packages/
|
|
packages = with pkgs; [
|
|
git
|
|
|
|
# Optional: Uncomment if you need browser automation
|
|
# chromium
|
|
];
|
|
|
|
# https://devenv.sh/languages/
|
|
languages.javascript = {
|
|
enable = true;
|
|
package = pkgs.nodejs_24;
|
|
pnpm = {
|
|
enable = true;
|
|
package = pkgs.pnpm_10;
|
|
};
|
|
};
|
|
|
|
# https://devenv.sh/services/
|
|
services.redis = {
|
|
enable = lib.mkDefault false; # Disabled by default, users can enable in devenv.local.nix
|
|
port = 6379;
|
|
};
|
|
|
|
# https://devenv.sh/scripts/
|
|
scripts.rsshub-dev.exec = ''
|
|
pnpm run dev
|
|
'';
|
|
|
|
scripts.rsshub-build.exec = ''
|
|
pnpm run build
|
|
'';
|
|
|
|
scripts.rsshub-start.exec = ''
|
|
pnpm start
|
|
'';
|
|
|
|
scripts.rsshub-test.exec = ''
|
|
pnpm test
|
|
'';
|
|
|
|
# https://devenv.sh/processes/
|
|
processes = {
|
|
# Uncomment to auto-start RSSHub in dev mode when entering the shell
|
|
# rsshub.exec = "pnpm run dev";
|
|
|
|
# Example: Auto-start with Redis
|
|
# rsshub.exec = "pnpm run dev";
|
|
};
|
|
|
|
# https://devenv.sh/pre-commit-hooks/
|
|
pre-commit.hooks = {
|
|
# Lint staged files
|
|
eslint = {
|
|
enable = true;
|
|
entry = lib.mkForce "pnpm run format:staged";
|
|
};
|
|
};
|
|
|
|
enterShell = ''
|
|
echo ""
|
|
echo "🚀 RSSHub Development Environment"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
echo "Node.js: $(node --version)"
|
|
echo "pnpm: $(pnpm --version)"
|
|
${lib.optionalString config.services.redis.enable ''
|
|
echo "Redis: Running on port ${toString config.services.redis.port}"
|
|
''}
|
|
echo ""
|
|
echo "Available commands:"
|
|
echo " rsshub-dev - Start development server (pnpm run dev)"
|
|
echo " rsshub-build - Build the project (pnpm run build)"
|
|
echo " rsshub-start - Start production server (pnpm start)"
|
|
echo " rsshub-test - Run tests (pnpm test)"
|
|
${lib.optionalString (!config.services.redis.enable) ''
|
|
echo ""
|
|
echo "💡 Tip: Enable Redis by creating devenv.local.nix:"
|
|
echo " { services.redis.enable = true; }"
|
|
''}
|
|
echo ""
|
|
echo "Documentation: https://docs.rsshub.app"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
|
|
# Install dependencies if node_modules doesn't exist
|
|
if [ ! -d "node_modules" ]; then
|
|
echo "📦 Installing dependencies..."
|
|
pnpm install
|
|
fi
|
|
'';
|
|
|
|
# https://devenv.sh/integrations/dotenv/
|
|
dotenv.enable = true; # Automatically load .env file
|
|
|
|
# Load local overrides if they exist
|
|
# Users can create devenv.local.nix for personal customizations
|
|
imports = lib.optional (builtins.pathExists ./devenv.local.nix) ./devenv.local.nix;
|
|
}
|