diff --git a/common/pkgs/mastodon/source.nix b/common/pkgs/mastodon/source.nix index ba46188..bbd0c01 100644 --- a/common/pkgs/mastodon/source.nix +++ b/common/pkgs/mastodon/source.nix @@ -1,5 +1,6 @@ # This file was generated by pkgs.mastodon.updateScript. -{ fetchFromGitHub, applyPatches, patches ? [ ] }: +{ lib, fetchFromGitHub, applyPatches, postPatch ? "", patches ? [ ], gawk +, gnused, yarn-berry }: let version = "f571dbe35dbc4876f9ca76b3f6d459839c67a2ef"; in (applyPatches { src = fetchFromGitHub { @@ -8,8 +9,19 @@ in (applyPatches { rev = "${version}"; sha256 = "3ZJMiciV0muv5j468hEKJUZGDhKcNCJnDFn6ZqKM1F4="; }; - patches = patches ++ [ ./yarn-typescript.patch ]; + inherit patches; + + nativeBuildInputs = [ gawk gnused ]; + postPatch = postPatch + + lib.optionalString (lib.versionAtLeast yarn-berry.version "4.1.0") '' + # this is for yarn starting with 4.1.0 because fuck everything amirite + # see also https://github.com/yarnpkg/berry/pull/6083 + echo "patching cachekey in yarn.lock" + cacheKey="$(awk -e '/cacheKey:/ {print $2}' yarn.lock)" + sed -i -Ee 's|^ checksum: ([^/]*)$| checksum: '$cacheKey'/\1|g;' yarn.lock + ''; + }) // { inherit version; - yarnHash = "sha256-qE1TBqa3BSEu1MC3Qw/k3h7QEicWd3AwJdA+U1v8924="; + yarnHash = "sha256-wdEunwUsV/IaJvNq+YIqRXNKLBrqPeeL5Ig+33dT/AY="; } diff --git a/common/pkgs/mastodon/update.sh b/common/pkgs/mastodon/update.sh index ff8d4ac..45733d4 100755 --- a/common/pkgs/mastodon/update.sh +++ b/common/pkgs/mastodon/update.sh @@ -66,7 +66,7 @@ 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) +HASH=$(echo "$JSON" | jq -r .sha256) cat > source.nix << EOF # This file was generated by pkgs.mastodon.updateScript. @@ -80,7 +80,7 @@ in owner = "$OWNER"; repo = "$REPO"; rev = "\${version}"; - hash = "$HASH"; + sha256 = "$HASH"; }; patches = patches ++ [$PATCHES]; }) // { @@ -94,7 +94,8 @@ 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 "Creating yarn-hash.nix" -YARN_HASH="$(prefetch-yarn-deps "$SOURCE_DIR/yarn.lock")" -YARN_HASH="$(nix hash to-sri --type sha256 "$YARN_HASH")" -sed -i "s/sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=/$YARN_HASH/g" source.nix +# echo "Creating yarn-hash.nix" +# YARN_HASH="$(prefetch-yarn-deps "$SOURCE_DIR/yarn.lock")" +# YARN_HASH="$(nix hash to-sri --type sha256 "$YARN_HASH")" +# sed -i "s/sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=/$YARN_HASH/g" source.nix +sed -i -Ee "s|^( *yarnHash = )\".*\";|\\1\"\";|g;" ./source.nix diff --git a/common/pkgs/mastodon/yarn-typescript.patch b/common/pkgs/mastodon/yarn-typescript.patch deleted file mode 100644 index e0f90bf..0000000 --- a/common/pkgs/mastodon/yarn-typescript.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/yarn.lock -+++ b/yarn.lock -@@ -16483,11 +16483,11 @@ - - "typescript@patch:typescript@npm%3A5#optional!builtin, typescript@patch:typescript@npm%3A^5.0.4#optional!builtin": - version: 5.3.3 -- resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7" -+ resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=29ae49" - bin: - tsc: bin/tsc - tsserver: bin/tsserver -- checksum: 1d0a5f4ce496c42caa9a30e659c467c5686eae15d54b027ee7866744952547f1be1262f2d40de911618c242b510029d51d43ff605dba8fb740ec85ca2d3f9500 -+ checksum: e22df47df9b2b2f2617b8bf511a29aea3d177f9f7a0756818230a76b01cbd7da988bf55f9463aaa1a4c1ff90b80f8dc5676460d4e9dfc010572cbba59b822b0c - languageName: node - linkType: hard diff --git a/common/pkgs/mastodon/yarn.nix b/common/pkgs/mastodon/yarn.nix index bdde07d..a1c63f4 100644 --- a/common/pkgs/mastodon/yarn.nix +++ b/common/pkgs/mastodon/yarn.nix @@ -20,7 +20,14 @@ stdenvNoCC.mkDerivation { export YARN_COMPRESSION_LEVEL=0 cache="$(yarn config get cacheFolder)" - yarn install --immutable --mode skip-build + if ! yarn install --immutable --mode skip-build; then + cp yarn.lock yarn.lock.bak + yarn install --mode skip-build + diff -u yarn.lock.bak yarn.lock + echo "yarn build failed! diff generated as yarn.lock.diff" + pwd + exit 1 + fi cp -r $cache/* $out/ '';