Skip to content

Commit

Permalink
feat(pkgs/rsshub,metacubexd): use nix-update to update them
Browse files Browse the repository at this point in the history
  • Loading branch information
wrvsrx committed Jun 10, 2024
1 parent 20cc50a commit 75e2635
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 146 deletions.
29 changes: 1 addition & 28 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 17 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
description = "My personal NUR repository";
inputs = {
flake-lock.url = "github:wrvsrx/flake-lock";
pnpm2nix-nzbr = {
url = "github:wrvsrx/pnpm2nix-nzbr/adapt-to-v9";
inputs.nixpkgs.follows = "flake-lock/nixpkgs";
inputs.flake-utils.follows = "flake-lock/flake-utils";
};
nixpkgs.follows = "flake-lock/nixpkgs";
flake-parts.follows = "flake-lock/flake-parts";
nvfetcher = {
Expand All @@ -22,8 +17,8 @@
};
};
outputs =
inputs':
inputs'.flake-parts.lib.mkFlake { inputs = inputs'; } (
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } (
{ withSystem, inputs, ... }:
let
inherit (import ./pkgs)
Expand Down Expand Up @@ -93,7 +88,7 @@
final: prev:
let
# it seems that using `extend` cause infinite evaluation of overlays
pkgs = prev // (inputs.pnpm2nix-nzbr.overlays.default { } prev);
pkgs = prev;
in
pkgs-to-flat-packages pkgs
// {
Expand All @@ -104,19 +99,31 @@
};
perSystem =
{ system, pkgs, ... }:
let
# support pnpmDeps
nix-update-patched = inputs.self.lib.patchFlake {
flake = inputs.nix-update;
patchesToFetch = [
{
url = "https://github.com/Mic92/nix-update/compare/19f968327336e1e438b5b42714ad578605c49d49...43b10443ed4ef38d3ea3907d8d2930f5846246b1.diff";
hash = "sha256-kj9XJBjRC9ZaFgk7KCS76xfr236rRs+qh5Um2xNqSzE=";
}
];
inherit system;
};
in
rec {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ inputs.pnpm2nix-nzbr.overlays.default ];
};
packages = pkgs-to-packages pkgs;
checks = builtins.removeAttrs packages [ "yuzu" ];
formatter = pkgs.nixfmt-rfc-style;
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
inputs.nvfetcher.packages."${system}".default
inputs.nix-update.packages."${system}".default
nix-update-patched.packages."${system}".default
];
};
};
Expand Down
14 changes: 6 additions & 8 deletions pkgs/to-normal-packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ let
sources = to-sources { inherit pkgs; };
callIFD = import ../callIFD.nix;
mkNotoCJK = callPackage ./noto-fonts-cjk { };
pnpm_9_1_4 = pkgs.callPackage "${pkgs.path}/pkgs/development/tools/pnpm/generic.nix" {
version = "9.1.4";
hash = "sha256-MKGAGsTnI3ee/tE6IfTDn562yfu0ztEBvOBrQiWT18k=";
};
in
rec {
auth-thu = callPackage ./auth-thu { };
Expand All @@ -30,14 +34,8 @@ rec {
source = sources.cmdlime;
inherit sfun seal_lake;
};
rsshub = callPackage ./rsshub {
source = sources.rsshub;
inherit (pkgs) mkPnpmPackage;
};
metacubexd = callPackage ./metacubexd {
# source = sources.metacubexd;
inherit (pkgs) mkPnpmPackage;
};
rsshub = callPackage ./rsshub { };
metacubexd = callPackage ./metacubexd { pnpm = pnpm_9_1_4; };
yalantinglibs = callPackage ./yalantinglibs { source = sources.yalantinglibs; };
baikal = callPackage ./baikal { };
yuzu = import ./yuzu {
Expand Down
44 changes: 27 additions & 17 deletions pkgs/to-normal-packages/metacubexd/default.nix
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
{
source,
nodePackages,
nodejs,
pnpm,
vips,
lib,
pkg-config,
python3,
zlib,
mkPnpmPackage,
stdenvNoCC,
fetchFromGitHub,
}:
let
version = lib.removePrefix "v" source.version;
in
mkPnpmPackage {
inherit (source) pname src;
inherit version pnpm nodejs;
installEnv = {
# otherwise, node-gyp will try to download node headers from internet
npm_config_nodedir = "${nodejs}";
COREPACK_ENABLE_STRICT = "0";
stdenvNoCC.mkDerivation rec {
pname = "metacubexd";
version = "1.140.0";
src = fetchFromGitHub {
owner = "MetaCubeX";
repo = "metacubexd";
rev = "v1.140.0";
fetchSubmodules = false;
sha256 = "sha256-OVLG+MHgwWTorPuBTHsHUAY1FSN91j7xWgRDJ7FiO7E=";
};
env = {
COREPACK_ENABLE_STRICT = "0";
pnpmDeps = pnpm.fetchDeps {
inherit pname version src;
hash = "sha256-24PkWT5UZJwMtL3y8qdf3XFuf3v5PjiP9XESbw3oppY=";
env = {
# otherwise, node-gyp will try to download node headers from internet
# It see
npm_config_nodedir = "${nodejs}";
};
};
extraBuildInputs = [
nativeBuildInputs = [
pnpm.configHook
nodePackages.node-gyp
nodejs
pkg-config
python3
vips
zlib
];
noDevDependencies = true;
buildPhase = "pnpm build";
installPhase = ''
mkdir -p $out
cp -r dist/* $out
'';
}
150 changes: 67 additions & 83 deletions pkgs/to-normal-packages/rsshub/default.nix
Original file line number Diff line number Diff line change
@@ -1,92 +1,76 @@
{
mkPnpmPackage,
fetchFromGitHub,
pnpm,
stdenvNoCC,
nodejs,
writeText,
writeShellScriptBin,
bash,
fetchpatch,
applyPatches,
source,
}:
let
node-modules =
(mkPnpmPackage {
inherit (source) pname version src;
inherit pnpm;
installEnv.PUPPETEER_SKIP_DOWNLOAD = "1";
installEnv.COREPACK_ENABLE_STRICT = "0";
noDevDependencies = true;
}).passthru.nodeModules.overrideAttrs
(old: {
installPhase =
old.installPhase
+ ''
rm -f $out/node_modules/.pnpm/lock.yaml
'';
});
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 };
'')
];
passthru = {
inherit node-modules;
};
nativeBuildInputs = [
pnpm
nodejs
];
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
stdenvNoCC.mkDerivation rec {
pname = "rsshub";
version = "9fd5c42951983918e488ff364d7e07e1bd64fe5d";
src = fetchFromGitHub {
owner = "DIYGod";
repo = "RSSHub";
rev = "9fd5c42951983918e488ff364d7e07e1bd64fe5d";
fetchSubmodules = false;
sha256 = "sha256-C0RME1RCdjcThUQbqsIobmVQDViJcBSAL46z2E95M0E=";
};
pnpmDeps = pnpm.fetchDeps {
inherit pname version src;
hash = "sha256-PWLINjZ2dJHILLAXHIXJORxpI8V3CdZ61lcS5v7fCUI=";
};
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 = '${version}'.slice(0, 8);
+let gitDate: Date | undefined = new Date('1970-01-01');
+// 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 };
'')
];
nativeBuildInputs = [
pnpm.configHook
nodejs
];
buildPhase = "pnpm build";
installPhase = ''
mkdir -p $out
mkdir -p $out/assets
mv 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
mkdir -p $out/bin
cat > $out/bin/rsshub <<- EOF
#!${bash}/bin/bash
TSX_TSCONFIG_PATH=$out/tsconfig.json ${nodejs}/bin/node $out/node_modules/tsx/dist/cli.mjs $out/lib/index.ts
EOF
chmod +x $out/bin/rsshub
'';
};
in
rsshub-website
TSX_TSCONFIG_PATH=$out/tsconfig.json ${nodejs}/bin/node $out/node_modules/tsx/dist/cli.mjs $out/lib/index.ts
EOF
chmod +x $out/bin/rsshub
'';
}

0 comments on commit 75e2635

Please sign in to comment.