nixos/local/pkgs/misskey/default.nix

68 lines
1.7 KiB
Nix
Raw Normal View History

2023-08-25 07:13:55 +08:00
{
2024-01-18 14:45:50 +08:00
lib, stdenv, mkPnpmPackage, fetchurl, nodejs, writeShellScript, buildFHSEnv,
2024-01-23 13:02:19 +08:00
bash, cypress, vips, pkg-config, src
2023-08-25 07:13:55 +08:00
}:
let
2024-01-23 13:02:19 +08:00
name = "misskey";
2023-09-01 21:05:26 +08:00
originalPnpmPackage = mkPnpmPackage
{
2024-01-23 13:02:19 +08:00
inherit name 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-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
{
2024-01-23 13:02:19 +08:00
inherit src name;
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";
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 =
{
2023-12-24 14:39:33 +08:00
inherit originalPnpmPackage startScript;
};
2023-09-01 21:05:26 +08:00
}