diff --git a/flake.lock b/flake.lock index ddae207..975f3a5 100644 --- a/flake.lock +++ b/flake.lock @@ -152,32 +152,6 @@ "type": "github" } }, - "pnpm2nix-nzbr": { - "inputs": { - "flake-utils": [ - "flake-lock", - "flake-utils" - ], - "nixpkgs": [ - "flake-lock", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1717937937, - "narHash": "sha256-bKoHjG5P15vCVpDndIXFfoJC65XhrBPQ9GWcXtXNuDA=", - "owner": "wrvsrx", - "repo": "pnpm2nix-nzbr", - "rev": "a2d285ad5718cb202f45e98a4f839a5b2608c4b1", - "type": "github" - }, - "original": { - "owner": "wrvsrx", - "ref": "adapt-to-v9", - "repo": "pnpm2nix-nzbr", - "type": "github" - } - }, "root": { "inputs": { "flake-lock": "flake-lock", @@ -190,8 +164,7 @@ "flake-lock", "nixpkgs" ], - "nvfetcher": "nvfetcher", - "pnpm2nix-nzbr": "pnpm2nix-nzbr" + "nvfetcher": "nvfetcher" } }, "systems": { diff --git a/flake.nix b/flake.nix index f3778e7..1074971 100644 --- a/flake.nix +++ b/flake.nix @@ -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 = { @@ -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) @@ -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 // { @@ -104,11 +99,23 @@ }; 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" ]; @@ -116,7 +123,7 @@ devShells.default = pkgs.mkShell { nativeBuildInputs = [ inputs.nvfetcher.packages."${system}".default - inputs.nix-update.packages."${system}".default + nix-update-patched.packages."${system}".default ]; }; }; diff --git a/pkgs/to-normal-packages/default.nix b/pkgs/to-normal-packages/default.nix index 37b17ee..a94d7ab 100644 --- a/pkgs/to-normal-packages/default.nix +++ b/pkgs/to-normal-packages/default.nix @@ -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 { }; @@ -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 { diff --git a/pkgs/to-normal-packages/metacubexd/default.nix b/pkgs/to-normal-packages/metacubexd/default.nix index 04032dc..b7aded3 100644 --- a/pkgs/to-normal-packages/metacubexd/default.nix +++ b/pkgs/to-normal-packages/metacubexd/default.nix @@ -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 + ''; } diff --git a/pkgs/to-normal-packages/rsshub/default.nix b/pkgs/to-normal-packages/rsshub/default.nix index c0a570f..0ffdcb4 100644 --- a/pkgs/to-normal-packages/rsshub/default.nix +++ b/pkgs/to-normal-packages/rsshub/default.nix @@ -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 + ''; +}