nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 183 lines 6.0 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 php, 6 openssl, 7 hiredis, 8 libck, 9 zstd, 10 lz4, 11 autoPatchelfHook, 12 writeShellScript, 13 curl, 14 common-updater-scripts, 15}: 16 17let 18 version = "0.20.0"; 19 hashes = { 20 "aarch64-darwin" = { 21 platform = "darwin-arm64"; 22 hash = { 23 "8.1" = "sha256-v+28oH/7Dp7mSsIgC/IQAn3Pp0gZ43vBMHb/1xBhiVY="; 24 "8.2" = "sha256-OXWMn71XCECh5q1kPxKyo7v/dzCT2it7S8NIKbjBli8="; 25 "8.3" = "7mlpqSPI34DTMJe6gw+77aJGOr12CXHHw+kBmy/nBI4="; 26 "8.4" = "sha256-FpkzCsak8RZBOgOT90VA5iLcfp5FOxpaOqWQJoV0HEY="; 27 "8.5" = "bMHjDJf5/prqUjVR6xOTsHl9iFGrBTL6b42KxyogWbQ="; 28 }; 29 }; 30 "aarch64-linux" = { 31 platform = "debian-aarch64+libssl3"; 32 hash = { 33 "8.1" = "sha256-Bbm+KURBJbzdyuV2RvnxYnLXLS6VN1osME6ZYCJLBhs="; 34 "8.2" = "sha256-niNBiZYOQVBg8CA/HCHkXdVJKBbbb/64Z1tjVo0m/2M="; 35 "8.3" = "sha256-CcuZ36K6nEFVIrdqHMQ5zp1zDDRXP55VKfqT3vx2+NA="; 36 "8.4" = "rvySgiePXFOctBBJqamBgn2XYQSQzeZAU2i1yCa5/lI="; 37 "8.5" = "4nkaXp2ArpndcG4BlPU7IlBrVrOEb/Tn7hSZ+0Vsm7k="; 38 }; 39 }; 40 "x86_64-linux" = { 41 platform = "debian-x86-64+libssl3"; 42 hash = { 43 "8.1" = "sha256-1UJMs1lhXMVLbyxQIOIF8S+p9lMMx5WzMwdYUs3eN6U="; 44 "8.2" = "sha256-zg+LSZdm3qIJ6DoRPSGRSEmKkn5uNPErlC5kMUQhxmM="; 45 "8.3" = "sha256-kvE4MavRxqQgkWHjaSBwx87r336pmqEwsIpC9CYwPxI="; 46 "8.4" = "pvYJHfkKvdyIrSrvxezwX2QWQw3kj6nPe/sHlJKys+Q="; 47 "8.5" = "Aw3oQXYjVNaDHl/qffhTmNHLTWi5bTjF1r4SKyu8nC0="; 48 }; 49 }; 50 }; 51 52 makeSource = 53 { system, phpMajor }: 54 fetchurl { 55 url = 56 "https://builds.r2.relay.so/v${version}/relay-v${version}-php" 57 + phpMajor 58 + "-" 59 + hashes.${system}.platform 60 + ".tar.gz"; 61 sha256 = 62 hashes.${system}.hash.${phpMajor} 63 or (throw "Unsupported PHP version for relay ${phpMajor} on ${system}"); 64 }; 65in 66stdenv.mkDerivation (finalAttrs: { 67 inherit version; 68 pname = "relay"; 69 extensionName = "relay"; 70 71 src = makeSource { 72 system = stdenv.hostPlatform.system; 73 phpMajor = lib.versions.majorMinor php.version; 74 }; 75 nativeBuildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [ autoPatchelfHook ]; 76 buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [ 77 hiredis 78 libck 79 openssl 80 zstd 81 lz4 82 ]; 83 internalDeps = [ php.extensions.session ]; 84 installPhase = '' 85 runHook preInstall 86 install -Dm755 relay.so -t $out/lib/php/extensions 87 '' 88 + ( 89 if stdenv.hostPlatform.isDarwin then 90 let 91 args = 92 lib.strings.concatMapStrings 93 (v: " -change ${v.name}" + " ${lib.strings.makeLibraryPath [ v.value ]}/${baseNameOf v.name}") 94 ( 95 with lib.attrsets; 96 [ 97 (nameValuePair "/opt/homebrew/opt/hiredis/lib/libhiredis.1.1.0.dylib" hiredis) 98 (nameValuePair "/opt/homebrew/opt/hiredis/lib/libhiredis_ssl.dylib.1.1.0" hiredis) 99 (nameValuePair "/opt/homebrew/opt/concurrencykit/lib/libck.0.dylib" libck) 100 (nameValuePair "/opt/homebrew/opt/openssl@3/lib/libssl.3.dylib" openssl) 101 (nameValuePair "/opt/homebrew/opt/openssl@3/lib/libcrypto.3.dylib" openssl) 102 (nameValuePair "/opt/homebrew/opt/zstd/lib/libzstd.1.dylib" zstd) 103 (nameValuePair "/opt/homebrew/opt/lz4/lib/liblz4.1.dylib" lz4) 104 ] 105 ); 106 in 107 # fixDarwinDylibNames can't be used here because we need to completely remap .dylibs, not just add absolute paths 108 '' 109 install_name_tool${args} $out/lib/php/extensions/relay.so 110 '' 111 else 112 "" 113 ) 114 + '' 115 # Random UUID that's required by the extension. Can be anything, but must be different from default. 116 sed -i "s/00000000-0000-0000-0000-000000000000/aced680f-30e9-40cc-a868-390ead14ba0c/" $out/lib/php/extensions/relay.so 117 chmod -w $out/lib/php/extensions/relay.so 118 119 runHook postInstall 120 ''; 121 122 passthru = { 123 updateScript = writeShellScript "update-${finalAttrs.pname}" '' 124 set -o errexit 125 export PATH="$PATH:${ 126 lib.makeBinPath [ 127 curl 128 common-updater-scripts 129 ] 130 }" 131 NEW_VERSION=$(curl --silent https://builds.r2.relay.so/meta/builds | sort -V | tail -n1 | cut -c2-) 132 133 if [[ "${version}" = "$NEW_VERSION" ]]; then 134 echo "The new version same as the old version." 135 exit 0 136 fi 137 138 for source in ${lib.concatStringsSep " " (builtins.attrNames finalAttrs.passthru.updateables)}; do 139 update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION" --ignore-same-version --ignore-same-hash --print-changes 140 done 141 ''; 142 143 # All sources for updating by the update script. 144 updateables = 145 builtins.listToAttrs 146 # Collect all leaf attributes (containing hashes). 147 ( 148 lib.collect (attrs: attrs ? name) 149 # create an attr containing 150 ( 151 lib.mapAttrsRecursive ( 152 path: _value: 153 lib.nameValuePair (builtins.replaceStrings [ "." ] [ "_" ] (lib.concatStringsSep "_" path)) ( 154 finalAttrs.finalPackage.overrideAttrs (attrs: { 155 src = makeSource { 156 system = builtins.head path; 157 phpMajor = builtins.head (builtins.tail (builtins.tail path)); 158 }; 159 }) 160 ) 161 ) (lib.filterAttrsRecursive (name: _value: name != "platform") hashes) 162 ) 163 ); 164 }; 165 166 meta = { 167 description = "Next-generation Redis extension for PHP"; 168 changelog = "https://github.com/cachewerk/relay/releases/tag/v${version}"; 169 homepage = "https://relay.so/"; 170 sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; 171 license = lib.licenses.unfree; 172 maintainers = with lib.maintainers; [ 173 tillkruss 174 ostrolucky 175 ]; 176 platforms = [ 177 "x86_64-linux" 178 "aarch64-linux" 179 "x86_64-darwin" 180 "aarch64-darwin" 181 ]; 182 }; 183})