2022-07-04 11:31:01 +00:00
|
|
|
{ lib, stdenv, rustPlatform, fetchFromGitHub, callPackage, sqlcipher, nodejs, python3, yarn, fixup_yarn_lock, CoreServices, fetchYarnDeps, removeReferencesTo }:
|
2021-08-03 22:08:53 +00:00
|
|
|
|
2021-10-12 22:30:23 +00:00
|
|
|
let
|
2021-11-03 12:43:23 +00:00
|
|
|
pinData = lib.importJSON ./pin.json;
|
2021-10-12 22:30:23 +00:00
|
|
|
|
|
|
|
in rustPlatform.buildRustPackage rec {
|
2021-08-03 22:08:53 +00:00
|
|
|
pname = "seshat-node";
|
2023-07-08 06:02:22 +00:00
|
|
|
inherit (pinData) version cargoHash;
|
2021-08-03 22:08:53 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "matrix-org";
|
|
|
|
repo = "seshat";
|
|
|
|
rev = version;
|
2023-07-08 06:02:22 +00:00
|
|
|
hash = pinData.srcHash;
|
2021-08-03 22:08:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
sourceRoot = "source/seshat-node/native";
|
|
|
|
|
2022-07-04 11:31:01 +00:00
|
|
|
nativeBuildInputs = [ nodejs python3 yarn ];
|
2021-08-04 09:09:56 +00:00
|
|
|
buildInputs = [ sqlcipher ] ++ lib.optional stdenv.isDarwin CoreServices;
|
2021-08-03 22:08:53 +00:00
|
|
|
|
2022-07-04 11:31:01 +00:00
|
|
|
npm_config_nodedir = nodejs;
|
2021-08-03 22:08:53 +00:00
|
|
|
|
2021-10-12 22:30:23 +00:00
|
|
|
yarnOfflineCache = fetchYarnDeps {
|
|
|
|
yarnLock = src + "/seshat-node/yarn.lock";
|
|
|
|
sha256 = pinData.yarnHash;
|
|
|
|
};
|
2021-08-03 22:08:53 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
2022-02-11 13:26:07 +00:00
|
|
|
runHook preBuild
|
2021-08-03 22:08:53 +00:00
|
|
|
cd ..
|
|
|
|
chmod u+w . ./yarn.lock
|
2021-08-04 09:09:56 +00:00
|
|
|
export HOME=$PWD/tmp
|
|
|
|
mkdir -p $HOME
|
2022-09-26 15:11:44 +00:00
|
|
|
yarn config --offline set yarn-offline-mirror $yarnOfflineCache
|
2021-08-03 22:08:53 +00:00
|
|
|
${fixup_yarn_lock}/bin/fixup_yarn_lock yarn.lock
|
|
|
|
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
|
|
|
patchShebangs node_modules/
|
|
|
|
node_modules/.bin/neon build --release
|
2022-02-11 13:26:07 +00:00
|
|
|
runHook postBuild
|
2021-08-03 22:08:53 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
installPhase = ''
|
2022-02-11 13:26:07 +00:00
|
|
|
runHook preInstall
|
2021-08-03 22:08:53 +00:00
|
|
|
shopt -s extglob
|
|
|
|
rm -rf native/!(index.node)
|
2022-02-11 13:26:07 +00:00
|
|
|
rm -rf node_modules $HOME
|
2021-08-03 22:08:53 +00:00
|
|
|
cp -r . $out
|
2022-03-28 20:23:29 +00:00
|
|
|
${removeReferencesTo}/bin/remove-references-to -t ${stdenv.cc.cc} $out/native/index.node
|
2022-02-11 13:26:07 +00:00
|
|
|
runHook postInstall
|
2021-08-03 22:08:53 +00:00
|
|
|
'';
|
|
|
|
|
2022-03-28 20:23:29 +00:00
|
|
|
disallowedReferences = [ stdenv.cc.cc ];
|
2021-08-03 22:08:53 +00:00
|
|
|
}
|