element-desktop.seshat: use fetchYarnDeps

This commit is contained in:
Yureka 2021-10-13 00:30:23 +02:00 committed by Yuka
parent 9c36092389
commit fcec99feec
4 changed files with 60 additions and 4572 deletions

View file

@ -1,14 +1,17 @@
{ lib, stdenv, rustPlatform, fetchFromGitHub, callPackage, sqlcipher, nodejs-14_x, python3, yarn, fixup_yarn_lock, CoreServices }:
{ lib, stdenv, rustPlatform, fetchFromGitHub, callPackage, sqlcipher, nodejs-14_x, python3, yarn, fixup_yarn_lock, CoreServices, fetchYarnDeps }:
rustPlatform.buildRustPackage rec {
let
pinData = (builtins.fromJSON (builtins.readFile ./pin.json));
in rustPlatform.buildRustPackage rec {
pname = "seshat-node";
version = "2.3.0";
inherit (pinData) version;
src = fetchFromGitHub {
owner = "matrix-org";
repo = "seshat";
rev = version;
sha256 = "0zigrz59mhih9asmbbh38z2fg0sii2342q6q0500qil2a0rssai7";
sha256 = pinData.srcHash;
};
sourceRoot = "source/seshat-node/native";
@ -18,7 +21,10 @@ rustPlatform.buildRustPackage rec {
npm_config_nodedir = nodejs-14_x;
yarnOfflineCache = (callPackage ./yarn.nix {}).offline_cache;
yarnOfflineCache = fetchYarnDeps {
yarnLock = src + "/seshat-node/yarn.lock";
sha256 = pinData.yarnHash;
};
buildPhase = ''
cd ..
@ -42,5 +48,5 @@ rustPlatform.buildRustPackage rec {
cp -r . $out
'';
cargoSha256 = "0habjf85mzqxwf8k15msm4cavd7ldq4zpxddkwd4inl2lkvlffqj";
cargoSha256 = pinData.cargoHash;
}

View file

@ -0,0 +1,6 @@
{
"version": "2.3.0",
"srcHash": "JyqtM1CCRgxAAdhgQYaIUYPnxEcDrlW1SjDCmsrPL34=",
"yarnHash": "0bym6i1f0i3bs4fncbiwzwmbxp7j14rz1v4kyvsl02qs97qw1jac",
"cargoHash": "sha256-EjtH96SC2kgan631+wlu9LStGKm6ljCR4x3/WpCTS0E="
}

View file

@ -1,16 +1,49 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../ -i bash -p wget yarn2nix
#!nix-shell -I nixpkgs=../../../../../../ -i bash -p wget prefetch-yarn-deps yarn nix-prefetch
set -euo pipefail
if [ "$#" -ne 1 ] || [[ "$1" == -* ]]; then
echo "Regenerates the Yarn dependency lock files."
echo "Usage: $0 <git release tag>"
if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
echo "Regenerates packaging data for the seshat package."
echo "Usage: $0 [git release tag]"
exit 1
fi
SRC="https://raw.githubusercontent.com/matrix-org/seshat/$1"
version="$1"
set -euo pipefail
if [ -z "$version" ]; then
version="$(wget -O- "https://api.github.com/repos/matrix-org/seshat/tags" | jq -r '.[] | .name' | sort --version-sort | tail -1)"
fi
SRC="https://raw.githubusercontent.com/matrix-org/seshat/$version"
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
pushd $tmpdir
wget "$SRC/seshat-node/yarn.lock"
yarn2nix > yarn.nix
rm yarn.lock
yarn_hash=$(prefetch-yarn-deps yarn.lock)
popd
src_hash=$(nix-prefetch-github matrix-org seshat --rev ${version} | jq -r .sha256)
cat > pin.json << EOF
{
"version": "$version",
"srcHash": "$src_hash",
"yarnHash": "$yarn_hash",
"cargoHash": "0000000000000000000000000000000000000000000000000000"
}
EOF
cargo_hash=$(nix-prefetch "{ sha256 }: (import ../../../../../.. {}).element-desktop.seshat.cargoDeps")
cat > pin.json << EOF
{
"version": "$version",
"srcHash": "$src_hash",
"yarnHash": "$yarn_hash",
"cargoHash": "$cargo_hash"
}
EOF