Compare commits

...

1 Commits
root ... rsshub

Author SHA1 Message Date
chn
23ff0f7788 switch to upstream pnpm2nix-nzbr 2024-02-04 23:50:47 +08:00
4 changed files with 36 additions and 111 deletions

10
flake.lock generated
View File

@@ -1724,15 +1724,15 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1705976239, "lastModified": 1706694632,
"narHash": "sha256-pHeHvy4Dq3veNtzL/oojh0KEAzZRZOSqgX1RT0kqM2s=", "narHash": "sha256-ytyTwNPiUR8aq74QlxFI+Wv3MyvXz5POO1xZxQIoi0c=",
"owner": "CHN-beta", "owner": "nzbr",
"repo": "pnpm2nix-nzbr", "repo": "pnpm2nix-nzbr",
"rev": "a71234b70e90ac147b5ae1f35f07b95ba60ca59e", "rev": "0366b7344171accc2522525710e52a8abbf03579",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "CHN-beta", "owner": "nzbr",
"repo": "pnpm2nix-nzbr", "repo": "pnpm2nix-nzbr",
"type": "github" "type": "github"
} }

View File

@@ -29,7 +29,7 @@
napalm = { url = "github:nix-community/napalm"; inputs.nixpkgs.follows = "nixpkgs"; }; napalm = { url = "github:nix-community/napalm"; inputs.nixpkgs.follows = "nixpkgs"; };
nixpak = { url = "github:nixpak/nixpak"; inputs.nixpkgs.follows = "nixpkgs"; }; nixpak = { url = "github:nixpak/nixpak"; inputs.nixpkgs.follows = "nixpkgs"; };
deploy-rs = { url = "github:serokell/deploy-rs"; inputs.nixpkgs.follows = "nixpkgs"; }; deploy-rs = { url = "github:serokell/deploy-rs"; inputs.nixpkgs.follows = "nixpkgs"; };
pnpm2nix-nzbr = { url = "github:CHN-beta/pnpm2nix-nzbr"; inputs.nixpkgs.follows = "nixpkgs"; }; pnpm2nix-nzbr = { url = "github:nzbr/pnpm2nix-nzbr"; inputs.nixpkgs.follows = "nixpkgs"; };
# oneapi # oneapi
lmix = { url = "github:CHN-beta/lmix"; inputs.nixpkgs.follows = "nixpkgs"; }; lmix = { url = "github:CHN-beta/lmix"; inputs.nixpkgs.follows = "nixpkgs"; };
# nvhpc # nvhpc

View File

@@ -1,67 +1,22 @@
{ {
lib, stdenv, mkPnpmPackage, fetchurl, nodejs, writeShellScript, buildFHSEnv, lib, mkPnpmPackage, nodejs, writeShellScriptBin,
bash, cypress, vips, pkg-config, src bash, cypress, vips, pkg-config, src
}: }:
let let
name = "misskey"; unwrapped = mkPnpmPackage
originalPnpmPackage = mkPnpmPackage
{ {
inherit name src nodejs; inherit src nodejs;
name = "misskey-unwrapped";
installEnv = { CYPRESS_RUN_BINARY = "${cypress}/bin/Cypress"; NODE_ENV = "production"; };
copyPnpmStore = true; copyPnpmStore = true;
distDir = ".";
noDevDependencies = true;
}; };
startScript = writeShellScript "misskey" in writeShellScriptBin "misskey"
'' ''
export PATH=${lib.makeBinPath [ bash nodejs nodejs.pkgs.pnpm nodejs.pkgs.gulp cypress ]}:$PATH cd ${unwrapped}
export CYPRESS_RUN_BINARY="${cypress}/bin/Cypress" export PATH=${lib.makeBinPath [ bash nodejs nodejs.pkgs.pnpm nodejs.pkgs.gulp cypress ]}:$PATH
export NODE_ENV=production export CYPRESS_RUN_BINARY="${cypress}/bin/Cypress"
pnpm run migrateandstart export NODE_ENV=production
''; pnpm run migrateandstart
in ''
stdenv.mkDerivation rec
{
inherit src name;
buildInputs =
[
bash nodejs nodejs.pkgs.typescript nodejs.pkgs.pnpm nodejs.pkgs.gulp cypress vips pkg-config
];
nativeBuildInputs = buildInputs;
CYPRESS_RUN_BINARY = "${cypress}/bin/Cypress";
NODE_ENV = "production";
configurePhase =
''
export HOME=$NIX_BUILD_TOP # Some packages need a writable HOME
export npm_config_nodedir=${nodejs}
runHook preConfigure
store=$(pnpm store path)
mkdir -p $(dirname $store)
cp -f ${originalPnpmPackage.passthru.patchedLockfileYaml} pnpm-lock.yaml
cp -RL ${originalPnpmPackage.passthru.pnpmStore} $store
chmod -R +w $store
pnpm install --frozen-lockfile --offline
runHook postConfigure
'';
buildPhase =
''
runHook preBuild
pnpm run build
runHook postBuild
'';
installPhase =
''
runHook preInstall
mkdir -p $out
mv * .* $out
mkdir -p $out/bin
cp ${startScript} $out/bin/misskey
mkdir -p $out/files
runHook postInstall
'';
passthru =
{
inherit originalPnpmPackage startScript;
};
}

View File

@@ -1,50 +1,20 @@
{ {
lib, stdenv, mkPnpmPackage, nodejs, writeShellScript, lib, mkPnpmPackage, nodejs, writeShellScriptBin, src,
chromium, bash, src chromium, bash
}: }:
let let
name = "rsshub"; unwrapped = mkPnpmPackage
originalPnpmPackage = mkPnpmPackage { inherit name src nodejs; };
nodeModules = originalPnpmPackage.nodeModules.overrideAttrs { PUPPETEER_SKIP_DOWNLOAD = true; };
rsshub-unwrapped = stdenv.mkDerivation
{ {
inherit src; name = "rsshub-unwrapped";
name = "${name}-unwrapped"; inherit src nodejs;
configurePhase = installEnv.PUPPETEER_SKIP_DOWNLOAD = "1";
'' script = "build:all";
export HOME=$NIX_BUILD_TOP # Some packages need a writable HOME distDir = ".";
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" in writeShellScriptBin "rsshub"
'' ''
cd ${rsshub-unwrapped} cd ${unwrapped}
export PATH=${lib.makeBinPath [ bash nodejs nodejs.pkgs.pnpm chromium ]}:$PATH export PATH=${lib.makeBinPath [ bash nodejs nodejs.pkgs.pnpm chromium ]}:$PATH
export CHROMIUM_EXECUTABLE_PATH=chromium export CHROMIUM_EXECUTABLE_PATH=chromium
pnpm start pnpm start
''; ''
in stdenv.mkDerivation
{
inherit name;
phases = [ "installPhase" ];
installPhase =
''
runHook preInstall
mkdir -p $out/bin
cp ${startScript} $out/bin/rsshub
runHook postInstall
'';
}