mastodon: reduce the amount of files information is spread across

This commit is contained in:
Sandro Jäckel 2023-09-28 00:42:07 +02:00 committed by Weijia Wang
parent a6fd03427d
commit 591d32cdb1
5 changed files with 19 additions and 24 deletions

View File

@ -1,29 +1,27 @@
{ lib, stdenv, nodejs-slim, mkYarnPackage, fetchFromGitHub, bundlerEnv, nixosTests
{ lib, stdenv, nodejs-slim, bundlerEnv, nixosTests
, yarn, callPackage, imagemagick, ffmpeg, file, ruby_3_0, writeShellScript
, fetchYarnDeps, fixup_yarn_lock
, brotli
# Allow building a fork or custom version of Mastodon:
, pname ? "mastodon"
, version ? import ./version.nix
, srcOverride ? null
, dependenciesDir ? ./. # Expected to contain gemset.nix
, yarnHash ? import ./yarn-hash.nix
, version ? srcOverride.version
# src is a package
, srcOverride ? callPackage ./source.nix {}
, gemset ? ./. + "/gemset.nix"
, yarnHash ? srcOverride.yarnHash
}:
stdenv.mkDerivation rec {
inherit pname version;
# Using overrideAttrs on src does not build the gems and modules with the overridden src.
# Putting the callPackage up in the arguments list also does not work.
src = if srcOverride != null then srcOverride else callPackage ./source.nix {};
src = srcOverride;
mastodonGems = bundlerEnv {
name = "${pname}-gems-${version}";
inherit version;
inherit version gemset;
ruby = ruby_3_0;
gemdir = src;
gemset = dependenciesDir + "/gemset.nix";
# This fix (copied from https://github.com/NixOS/nixpkgs/pull/76765) replaces the gem
# symlinks with directories, resolving this error when running rake:
# /nix/store/451rhxkggw53h7253izpbq55nrhs7iv0-mastodon-gems-3.0.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/settings.rb:6:in `<module:Bundler>': uninitialized constant Bundler::Settings (NameError)

View File

@ -1,12 +1,13 @@
# This file was generated by pkgs.mastodon.updateScript.
{ fetchFromGitHub, applyPatches }: let
{ fetchFromGitHub, applyPatches }:
applyPatches {
version = "4.1.9";
src = fetchFromGitHub {
owner = "mastodon";
repo = "mastodon";
rev = "v4.1.9";
hash = "sha256-xpE/mg2AeioW6NThUjLS+SBxGavG4w1xtp3BOMADfYo=";
};
in applyPatches {
inherit src;
patches = [];
yarnHash = "sha256-e3rl/WuKXaUdeDEYvo1sSubuIwtBjkbguCYdAijwXOA=";
}

View File

@ -56,7 +56,7 @@ if [[ -z "$REVISION" ]]; then
VERSION="$(echo "$REVISION" | cut -c2-)"
fi
rm -f gemset.nix version.nix source.nix
rm -f gemset.nix source.nix
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
WORK_DIR=$(mktemp -d)
@ -77,23 +77,21 @@ trap cleanup EXIT
echo "Fetching source code $REVISION"
JSON=$(nix-prefetch-github "$OWNER" "$REPO" --rev "$REVISION" 2> $WORK_DIR/nix-prefetch-git.out)
HASH="$(echo "$JSON" | jq -r .hash)"
echo "Creating version.nix"
echo "\"$VERSION\"" | sed 's/^"v/"/' > version.nix
HASH=$(echo "$JSON" | jq -r .hash)
cat > source.nix << EOF
# This file was generated by pkgs.mastodon.updateScript.
{ fetchFromGitHub, applyPatches }: let
{ fetchFromGitHub, applyPatches }:
applyPatches {
version = "$VERSION";
src = fetchFromGitHub {
owner = "$OWNER";
repo = "$REPO";
rev = "$REVISION";
hash = "$HASH";
};
in applyPatches {
inherit src;
patches = [$PATCHES];
yarnHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
}
EOF
SOURCE_DIR="$(nix-build --no-out-link -E '(import <nixpkgs> {}).callPackage ./source.nix {}')"
@ -105,4 +103,4 @@ echo "" >> gemset.nix # Create trailing newline to please EditorConfig checks
echo "Creating yarn-hash.nix"
YARN_HASH="$(prefetch-yarn-deps "$SOURCE_DIR/yarn.lock")"
YARN_HASH="$(nix hash to-sri --type sha256 "$YARN_HASH")"
printf '"%s"\n' "$YARN_HASH" > yarn-hash.nix
sed -i "s/sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=/$YARN_HASH/g" source.nix

View File

@ -1 +0,0 @@
"4.1.9"

View File

@ -1 +0,0 @@
"sha256-e3rl/WuKXaUdeDEYvo1sSubuIwtBjkbguCYdAijwXOA="