nixos/local/pkgs/misskey/default.nix

126 lines
3.5 KiB
Nix
Raw Normal View History

2023-08-25 07:13:55 +08:00
{
2023-12-23 22:42:04 +08:00
lib, stdenv, mkPnpmPackage, fetchFromGitHub, fetchurl, nodejs, writeShellScript, buildFHSEnv,
2023-09-01 21:05:26 +08:00
bash, cypress, vips, pkg-config
2023-08-25 07:13:55 +08:00
}:
let
2023-09-01 21:05:26 +08:00
pname = "misskey";
2023-12-23 22:42:04 +08:00
version = "2023.12.0";
2023-08-25 07:13:55 +08:00
src = fetchFromGitHub
2023-09-01 21:05:26 +08:00
{
owner = "CHN-beta";
repo = "misskey";
2023-12-23 22:42:04 +08:00
rev = "bec1dc37598b71c377643ee77330d4d6f7eb31f2";
sha256 = "sha256-svLpG4xQ2mtsJ6gm+Ap8fZKTOl5V68XybGDvymsV4F4=";
2023-09-01 21:05:26 +08:00
fetchSubmodules = true;
};
originalPnpmPackage = mkPnpmPackage
{
2023-12-23 22:42:04 +08:00
inherit pname version src nodejs;
copyPnpmStore = true;
2023-09-01 21:05:26 +08:00
};
startScript = writeShellScript "misskey"
''
2023-12-23 22:42:04 +08:00
export PATH=${lib.makeBinPath [ bash nodejs nodejs.pkgs.pnpm nodejs.pkgs.gulp cypress ]}:$PATH
2023-09-01 21:05:26 +08:00
export CYPRESS_RUN_BINARY="${cypress}/bin/Cypress"
export NODE_ENV=production
pnpm run migrateandstart
'';
2023-09-24 23:23:35 +08:00
re2 = stdenv.mkDerivation rec
{
pname = "re2";
2023-11-17 22:35:15 +08:00
version = "1.20.8";
2023-09-24 23:23:35 +08:00
srcs =
[
(fetchurl
{
2023-11-17 22:35:15 +08:00
url = "https://github.com/uhop/node-re2/releases/download/1.20.8/linux-x64-120.br";
sha256 = "0f2l658xxc2112mbqpkyfic3vhjgdyafbfi14b6n40skyd6lijcq";
2023-09-24 23:23:35 +08:00
})
(fetchurl
{
2023-11-17 22:35:15 +08:00
url = "https://github.com/uhop/node-re2/releases/download/1.20.8/linux-x64-120.gz";
sha256 = "1v5n8i16188xpwx1jr8gcc1a99v83hlbh5hldl4i376vh0lwsxlq";
2023-09-24 23:23:35 +08:00
})
(fetchurl
{
2023-11-17 22:35:15 +08:00
url = "https://github.com/uhop/node-re2/releases/download/1.20.8/linux-x64-115.br";
sha256 = "0cyqmgqk5cwik27wh4ynaf94v4w6p1fsavm07xh8xfmdim2sr9kd";
2023-09-24 23:23:35 +08:00
})
(fetchurl
{
2023-11-17 22:35:15 +08:00
url = "https://github.com/uhop/node-re2/releases/download/1.20.8/linux-x64-115.gz";
sha256 = "0i3iykw13d5qfd5s6pq6kx6cbd64vfb3w65f9bnj87qz44la84ic";
2023-09-24 23:23:35 +08:00
})
(fetchurl
{
2023-11-17 22:35:15 +08:00
url = "https://github.com/uhop/node-re2/releases/download/1.20.8/linux-x64-108.br";
sha256 = "1467frfapqhi839r2v0p0wh76si3lihwzwgl9098mj7mwhjfl4lx";
2023-09-24 23:23:35 +08:00
})
(fetchurl
{
2023-11-17 22:35:15 +08:00
url = "https://github.com/uhop/node-re2/releases/download/1.20.8/linux-x64-108.gz";
sha256 = "0hykpqdrn55x83v1kzz6bdvrp24hgz3rwmwbdfl2saz576krzg1c";
2023-09-24 23:23:35 +08:00
})
];
phases = [ "installPhase" ];
installPhase =
''
mkdir -p $out/${version}
for i in $srcs
do
cp $i $out/${version}/''${i#*-}
done
'';
};
2023-08-25 18:25:34 +08:00
in
2023-09-24 21:42:40 +08:00
stdenv.mkDerivation rec
2023-09-01 21:05:26 +08:00
{
inherit version src pname;
2023-09-24 21:42:40 +08:00
buildInputs =
2023-09-24 23:23:35 +08:00
[
2023-12-23 22:42:04 +08:00
bash nodejs nodejs.pkgs.typescript nodejs.pkgs.pnpm nodejs.pkgs.gulp cypress vips pkg-config
2023-09-24 23:23:35 +08:00
];
2023-09-24 21:42:40 +08:00
nativeBuildInputs = buildInputs;
2023-09-01 21:05:26 +08:00
CYPRESS_RUN_BINARY = "${cypress}/bin/Cypress";
NODE_ENV = "production";
2023-09-24 23:23:35 +08:00
RE2_DOWNLOAD_MIRROR = "${re2}";
RE2_DOWNLOAD_SKIP_PATH = "true";
2023-09-01 21:05:26 +08:00
configurePhase =
''
export HOME=$NIX_BUILD_TOP # Some packages need a writable HOME
2023-12-23 22:42:04 +08:00
export npm_config_nodedir=${nodejs}
2023-08-25 07:13:55 +08:00
2023-09-01 21:05:26 +08:00
runHook preConfigure
2023-08-25 07:13:55 +08:00
2023-09-01 21:05:26 +08:00
store=$(pnpm store path)
mkdir -p $(dirname $store)
2023-08-25 07:13:55 +08:00
2023-09-01 21:05:26 +08:00
cp -f ${originalPnpmPackage.passthru.patchedLockfileYaml} pnpm-lock.yaml
cp -RL ${originalPnpmPackage.passthru.pnpmStore} $store
2023-09-01 21:05:26 +08:00
chmod -R +w $store
pnpm install --frozen-lockfile --offline
2023-08-25 07:13:55 +08:00
2023-09-01 21:05:26 +08:00
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 re2;
};
2023-09-01 21:05:26 +08:00
}