diff --git a/pkgs/servers/mastodon/default.nix b/pkgs/servers/mastodon/default.nix index f1f96a2d0b4b..54e0c8624d94 100644 --- a/pkgs/servers/mastodon/default.nix +++ b/pkgs/servers/mastodon/default.nix @@ -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 ''; diff --git a/pkgs/servers/mastodon/source.nix b/pkgs/servers/mastodon/source.nix index 58563cc2a07a..15a415f21ba3 100644 --- a/pkgs/servers/mastodon/source.nix +++ b/pkgs/servers/mastodon/source.nix @@ -18,5 +18,5 @@ in }) // { inherit version; - yarnHash = "sha256-e5c04M6XplAgaVyldU5HmYMYtY3MAWs+a8Z/BGSyGBg="; + yarnHash = "sha256-IC4d/skIHEzJPuKlq4rMAqV+ydqquA6toq4WWCfuDxo="; } diff --git a/pkgs/servers/mastodon/update.sh b/pkgs/servers/mastodon/update.sh index b9e3c6453f6d..330e53676b7a 100755 --- a/pkgs/servers/mastodon/update.sh +++ b/pkgs/servers/mastodon/update.sh @@ -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 diff --git a/pkgs/servers/mastodon/yarn.nix b/pkgs/servers/mastodon/yarn.nix deleted file mode 100644 index e38eb739737f..000000000000 --- a/pkgs/servers/mastodon/yarn.nix +++ /dev/null @@ -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"; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bb5d067c88fd..428a72e02e45 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 {