Merge pull request #257731 from SuperSandro2000/mastodon-less-files

mastodon: reduce the amount of files information is spread across
This commit is contained in:
Weijia Wang 2023-09-28 23:40:43 +02:00 committed by GitHub
commit 1d66912dec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 26 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,16 @@
# This file was generated by pkgs.mastodon.updateScript.
{ fetchFromGitHub, applyPatches }: let
{ fetchFromGitHub, applyPatches }:
let
version = "4.1.9";
in
applyPatches {
inherit version;
src = fetchFromGitHub {
owner = "mastodon";
repo = "mastodon";
rev = "v4.1.9";
rev = "${version}";
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,24 @@ 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 }:
let
version = "$VERSION";
in
applyPatches {
inherit version;
src = fetchFromGitHub {
owner = "$OWNER";
repo = "$REPO";
rev = "$REVISION";
rev = "\${version}";
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 +106,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="