element-desktop: build native modules

This commit is contained in:
Milan Pässler 2021-08-04 00:08:53 +02:00
parent a79a5b880c
commit 55682979d2
No known key found for this signature in database
GPG Key ID: A6DC6A7CB0B97859
8 changed files with 10084 additions and 0 deletions

View File

@ -1,6 +1,7 @@
{ lib, fetchFromGitHub
, makeWrapper, makeDesktopItem, mkYarnPackage
, electron, element-web
, callPackage
}:
# Notes for maintainers:
# * versions of `element-web` and `element-desktop` should be kept in sync.
@ -24,6 +25,9 @@ in mkYarnPackage rec {
nativeBuildInputs = [ makeWrapper ];
seshat = callPackage ./seshat {};
keytar = callPackage ./keytar {};
buildPhase = ''
runHook preBuild
export HOME=$(mktemp -d)
@ -32,6 +36,9 @@ in mkYarnPackage rec {
yarn run i18n
node ./scripts/copy-res.js
popd
rm -rf node_modules/matrix-seshat node_modules/keytar
ln -s $keytar node_modules/keytar
ln -s $seshat node_modules/matrix-seshat
runHook postBuild
'';

View File

@ -0,0 +1,41 @@
{ stdenv, fetchFromGitHub, nodejs-14_x, python3, callPackage, fixup_yarn_lock, yarn, pkg-config, libsecret }:
stdenv.mkDerivation rec {
pname = "keytar";
version = "7.7.0";
src = fetchFromGitHub {
owner = "atom";
repo = "node-keytar";
rev = "v${version}";
sha256 = "0ajvr4kjbyw2shb1y14c0dsghdlnq30f19hk2sbzj6n9y3xa3pmi";
};
nativeBuildInputs = [ nodejs-14_x python3 yarn pkg-config];
buildInputs = [ libsecret ];
npm_config_nodedir = nodejs-14_x;
yarnOfflineCache = (callPackage ./yarn.nix {}).offline_cache;
buildPhase = ''
cp ${./yarn.lock} ./yarn.lock
chmod u+w . ./yarn.lock
export HOME=/tmp
yarn config --offline set yarn-offline-mirror ${yarnOfflineCache}
${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/node-gyp rebuild
'';
doCheck = false;
installPhase = ''
shopt -s extglob
rm -rf node_modules
mkdir -p $out
cp -r ./!(build) $out
install -D -t $out/build/Release build/Release/keytar.node
'';
}

View File

@ -0,0 +1,19 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../ -i bash -p wget yarn2nix yarn
set -euo pipefail
if [ "$#" -ne 1 ] || [[ "$1" == -* ]]; then
echo "Regenerates the Yarn dependency lock files."
echo "Usage: $0 <git release tag>"
exit 1
fi
SRC="https://raw.githubusercontent.com/atom/node-keytar/$1"
wget "$SRC/package-lock.json"
wget "$SRC/package.json"
rm -f yarn.lock
yarn import
yarn2nix > yarn.nix
rm -rf node_modules package.json package-lock.json

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,44 @@
{ rustPlatform, fetchFromGitHub, callPackage, sqlcipher, nodejs-14_x, python3, yarn, fixup_yarn_lock }:
rustPlatform.buildRustPackage rec {
pname = "seshat-node";
version = "2.3.0";
src = fetchFromGitHub {
owner = "matrix-org";
repo = "seshat";
rev = version;
sha256 = "0zigrz59mhih9asmbbh38z2fg0sii2342q6q0500qil2a0rssai7";
};
sourceRoot = "source/seshat-node/native";
nativeBuildInputs = [ nodejs-14_x python3 yarn ];
buildInputs = [ sqlcipher ];
npm_config_nodedir = nodejs-14_x;
yarnOfflineCache = (callPackage ./yarn.nix {}).offline_cache;
buildPhase = ''
cd ..
chmod u+w . ./yarn.lock
export HOME=/tmp
yarn config --offline set yarn-offline-mirror ${yarnOfflineCache}
${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
'';
doCheck = false;
installPhase = ''
shopt -s extglob
rm -rf native/!(index.node)
rm -rf node_modules
cp -r . $out
'';
cargoSha256 = "0habjf85mzqxwf8k15msm4cavd7ldq4zpxddkwd4inl2lkvlffqj";
}

View File

@ -0,0 +1,16 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../ -i bash -p wget yarn2nix
set -euo pipefail
if [ "$#" -ne 1 ] || [[ "$1" == -* ]]; then
echo "Regenerates the Yarn dependency lock files."
echo "Usage: $0 <git release tag>"
exit 1
fi
SRC="https://raw.githubusercontent.com/matrix-org/seshat/$1"
wget "$SRC/seshat-node/yarn.lock"
yarn2nix > yarn.nix
rm yarn.lock

File diff suppressed because it is too large Load Diff