mastodon: use fetchYarnBerryDeps (#401777)

This commit is contained in:
Yureka
2025-04-28 20:04:14 +02:00
committed by GitHub
parent 9494a123d3
commit 84940e71a3
5 changed files with 16 additions and 61 deletions
+10 -19
View File
@@ -36,14 +36,15 @@ stdenv.mkDerivation rec {
pname = "${pname}-modules";
inherit src version;
yarnOfflineCache = callPackage ./yarn.nix {
inherit version src;
yarnOfflineCache = yarn-berry.fetchYarnBerryDeps {
inherit src;
hash = yarnHash;
};
nativeBuildInputs = [
nodejs-slim
yarn-berry
yarn-berry.yarnBerryConfigHook
mastodonGems
mastodonGems.wrappedRuby
brotli
@@ -56,38 +57,28 @@ stdenv.mkDerivation rec {
buildPhase = ''
runHook preBuild
export HOME=$PWD
export YARN_ENABLE_TELEMETRY=0
export npm_config_nodedir=${nodejs-slim}
export SECRET_KEY_BASE_DUMMY=1
mkdir -p ~/.yarn/berry
ln -s $yarnOfflineCache ~/.yarn/berry/cache
yarn install --immutable --immutable-cache
patchShebangs ~/bin
patchShebangs ~/node_modules
patchShebangs bin
bundle exec rails assets:precompile
yarn cache clean --all
rm -rf ~/node_modules/.cache
rm -rf node_modules/.cache
# Remove workspace "package" as it contains broken symlinks
# See https://github.com/NixOS/nixpkgs/issues/380366
rm -rf ~/node_modules/@mastodon
rm -rf node_modules/@mastodon
# Remove execute permissions
find ~/public/assets -type f ! -perm 0555 \
find public/assets -type f ! -perm 0555 \
-exec chmod 0444 {} ';'
# Create missing static gzip and brotli files
find ~/public/assets -type f -regextype posix-extended -iregex '.*\.(css|html|js|json|svg)' \
find public/assets -type f -regextype posix-extended -iregex '.*\.(css|html|js|json|svg)' \
-exec gzip --best --keep --force {} ';' \
-exec brotli --best --keep {} ';'
gzip --best --keep ~/public/packs/report.html
brotli --best --keep ~/public/packs/report.html
gzip --best --keep public/packs/report.html
brotli --best --keep public/packs/report.html
runHook postBuild
'';
+1 -1
View File
@@ -18,5 +18,5 @@ in
})
// {
inherit version;
yarnHash = "sha256-e5c04M6XplAgaVyldU5HmYMYtY3MAWs+a8Z/BGSyGBg=";
yarnHash = "sha256-IC4d/skIHEzJPuKlq4rMAqV+ydqquA6toq4WWCfuDxo=";
}
+4 -3
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p bundix coreutils diffutils nix-prefetch-github gnused jq prefetch-yarn-deps
#! nix-shell -i bash -p bundix coreutils diffutils nix-prefetch-github gnused jq yarn-berry_4.yarn-berry-fetcher
set -e
OWNER=mastodon
@@ -110,5 +110,6 @@ echo "Creating gemset.nix"
bundix --lockfile="$SOURCE_DIR/Gemfile.lock" --gemfile="$SOURCE_DIR/Gemfile"
echo "" >> gemset.nix # Create trailing newline to please EditorConfig checks
echo "Required manual update of yarn-hash"
exit 1
echo "Updating yarnHash"
YARN_HASH="$(yarn-berry-fetcher prefetch "$SOURCE_DIR/yarn.lock" 2>/dev/null)"
sed -i "s;sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=;$YARN_HASH;g" source.nix
-37
View File
@@ -1,37 +0,0 @@
{
stdenvNoCC,
yarn-berry,
cacert,
version,
src,
hash,
}:
stdenvNoCC.mkDerivation {
pname = "yarn-deps";
inherit version src;
nativeBuildInputs = [
yarn-berry
];
dontInstall = true;
NODE_EXTRA_CA_CERTS = "${cacert}/etc/ssl/certs/ca-bundle.crt";
buildPhase = ''
export HOME=$(mktemp -d)
export YARN_ENABLE_TELEMETRY=0
yarn config set --json supportedArchitectures.os '[ "linux" ]'
yarn config set --json supportedArchitectures.cpu '[ "arm64", "x64", "ia32" ]'
cache="$(yarn config get cacheFolder)"
yarn install --immutable --mode skip-build
mkdir -p $out
cp -r $cache/* $out/
'';
outputHash = hash;
outputHashMode = "recursive";
}
+1 -1
View File
@@ -11961,7 +11961,7 @@ with pkgs;
nodejs-slim = nodejs-slim_22;
python3 = python311;
ruby = ruby_3_3;
yarn-berry = yarn-berry.override { nodejs = nodejs-slim_22; };
yarn-berry = yarn-berry_4.override { nodejs = nodejs-slim_22; };
};
micro-full = micro.wrapper.override {