Unverified Commit 1d66912d authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

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

mastodon: reduce the amount of files information is spread across
parents d0db7ea5 300a6fda
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
{ 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)
+8 −4
Original line number Diff line number Diff line
# 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=";
}
+11 −10
Original line number Diff line number Diff line
@@ -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

pkgs/servers/mastodon/version.nix

deleted100644 → 0
+0 −1
Original line number Diff line number Diff line
"4.1.9"
+0 −1
Original line number Diff line number Diff line
"sha256-e3rl/WuKXaUdeDEYvo1sSubuIwtBjkbguCYdAijwXOA="