2024-05-15 15:35:15 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
fetchurl,
|
|
|
|
php,
|
|
|
|
openssl,
|
|
|
|
hiredis,
|
|
|
|
zstd,
|
|
|
|
lz4,
|
|
|
|
autoPatchelfHook,
|
|
|
|
writeShellScript,
|
|
|
|
curl,
|
|
|
|
common-updater-scripts,
|
2023-07-15 17:15:38 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-01-25 14:12:00 +00:00
|
|
|
version = "0.7.0";
|
2024-01-02 11:29:13 +00:00
|
|
|
hashes = {
|
2023-07-15 17:15:38 +00:00
|
|
|
"aarch64-darwin" = {
|
|
|
|
platform = "darwin-arm64";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = {
|
2024-01-25 14:12:00 +00:00
|
|
|
"8.0" = "sha256-pd/9TWZPgAfmVM0/QVYRHu5k4gANcxCSnfAl38irO0Y=";
|
|
|
|
"8.1" = "sha256-OpxE/nu8MZedTmKGQeyJm36pyyHlRpW11avuGcnGP68=";
|
|
|
|
"8.2" = "sha256-+CMPdXZotUr43Qda1FwGpuWPEE1K4RuBNE9fiokAtoY=";
|
|
|
|
"8.3" = "sha256-lbKVxOd5gK5VDGnJ42w7L5DFKsBQDZXgEZLR/Y0gP88=";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
"aarch64-linux" = {
|
|
|
|
platform = "debian-aarch64+libssl3";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = {
|
2024-01-25 14:12:00 +00:00
|
|
|
"8.0" = "sha256-NfeC3p0YLYz3NbjzjMRRuzMsnYe9JRwlBjddAG2WV7g=";
|
|
|
|
"8.1" = "sha256-kvO0PE3BSgFSfe1zHh3WnygQfVV+5V0YFfClBim1Kj4=";
|
|
|
|
"8.2" = "sha256-illxRqqwMKVNAp6BD+mktKDccM7B/Q1W1KF9UB6aMUQ=";
|
|
|
|
"8.3" = "sha256-QdB7g+ePJU8qt/BVo1CFnQ2vfkqR29WueBy3dLOOaR0=";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
"x86_64-darwin" = {
|
|
|
|
platform = "darwin-x86-64";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = {
|
2024-01-25 14:12:00 +00:00
|
|
|
"8.0" = "sha256-rd3pt2N22bF4a8OOwksI7KJjR91IoxHwk3LcKuHSpV0=";
|
|
|
|
"8.1" = "sha256-Y/moZrBe4rooQBSQKS8vPCTjviHKy4O7d4T1kD3udC4=";
|
|
|
|
"8.2" = "sha256-H3EWFk/ZmE+fSU98nLHyq1p1vtU/TYp28OzNLox6kYY=";
|
|
|
|
"8.3" = "sha256-vZTarrauo7U2JLOXUCwmu2h+vBtWZpm0Q39KkuLyVgY=";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
"x86_64-linux" = {
|
|
|
|
platform = "debian-x86-64+libssl3";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = {
|
2024-01-25 14:12:00 +00:00
|
|
|
"8.0" = "sha256-jq/nHC9IGevYBqbM08nF71P9jH6z4NB8s1NdjHOfXQA=";
|
|
|
|
"8.1" = "sha256-vbFONNHpuSTQsZMrAIdGEoBl5ySchcFkSuhW5uZKbWg=";
|
|
|
|
"8.2" = "sha256-mXUAMkxwtuPZbIyCybBcxpmaBplr5h59pZEdgJ3PWtA=";
|
|
|
|
"8.3" = "sha256-YL0P8GtFkV0cmJX1y6wd/HtA0LFzeuOcKDLUCagxHxE=";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
makeSource =
|
|
|
|
{ system, phpMajor }:
|
|
|
|
fetchurl {
|
|
|
|
url =
|
|
|
|
"https://builds.r2.relay.so/v${version}/relay-v${version}-php"
|
|
|
|
+ phpMajor
|
|
|
|
+ "-"
|
|
|
|
+ hashes.${system}.platform
|
|
|
|
+ ".tar.gz";
|
|
|
|
sha256 =
|
|
|
|
hashes.${system}.hash.${phpMajor}
|
|
|
|
or (throw "Unsupported PHP version for relay ${phpMajor} on ${system}");
|
|
|
|
};
|
2023-07-15 17:15:38 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
|
|
inherit version;
|
|
|
|
pname = "relay";
|
|
|
|
extensionName = "relay";
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
src = makeSource {
|
|
|
|
system = stdenv.hostPlatform.system;
|
|
|
|
phpMajor = lib.versions.majorMinor php.version;
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
2024-05-15 15:35:15 +00:00
|
|
|
nativeBuildInputs = lib.optionals (!stdenv.isDarwin) [ autoPatchelfHook ];
|
2023-07-15 17:15:38 +00:00
|
|
|
buildInputs = lib.optionals (!stdenv.isDarwin) [
|
|
|
|
openssl
|
|
|
|
zstd
|
|
|
|
lz4
|
|
|
|
];
|
2024-05-15 15:35:15 +00:00
|
|
|
installPhase =
|
2023-07-15 17:15:38 +00:00
|
|
|
''
|
2024-05-15 15:35:15 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/lib/php/extensions
|
|
|
|
cp relay-pkg.so $out/lib/php/extensions/relay.so
|
|
|
|
chmod +w $out/lib/php/extensions/relay.so
|
2023-07-15 17:15:38 +00:00
|
|
|
''
|
2024-05-15 15:35:15 +00:00
|
|
|
+ (
|
|
|
|
if stdenv.isDarwin then
|
|
|
|
let
|
|
|
|
args =
|
|
|
|
lib.strings.concatMapStrings
|
|
|
|
(
|
|
|
|
v:
|
|
|
|
" -change ${v.name}" + " ${lib.strings.makeLibraryPath [ v.value ]}/${builtins.baseNameOf v.name}"
|
|
|
|
)
|
|
|
|
(
|
|
|
|
with lib.attrsets;
|
|
|
|
[
|
|
|
|
(nameValuePair "/opt/homebrew/opt/hiredis/lib/libhiredis.1.1.0.dylib" hiredis)
|
|
|
|
(nameValuePair "/opt/homebrew/opt/hiredis/lib/libhiredis_ssl.dylib.1.1.0" hiredis)
|
|
|
|
(nameValuePair "/opt/homebrew/opt/openssl@3/lib/libssl.3.dylib" openssl)
|
|
|
|
(nameValuePair "/opt/homebrew/opt/openssl@3/lib/libcrypto.3.dylib" openssl)
|
|
|
|
(nameValuePair "/opt/homebrew/opt/zstd/lib/libzstd.1.dylib" zstd)
|
|
|
|
(nameValuePair "/opt/homebrew/opt/lz4/lib/liblz4.1.dylib" lz4)
|
|
|
|
]
|
|
|
|
);
|
|
|
|
in
|
|
|
|
# fixDarwinDylibNames can't be used here because we need to completely remap .dylibs, not just add absolute paths
|
|
|
|
''
|
|
|
|
install_name_tool${args} $out/lib/php/extensions/relay.so
|
|
|
|
''
|
|
|
|
else
|
|
|
|
""
|
|
|
|
)
|
|
|
|
+ ''
|
|
|
|
# Random UUID that's required by the extension. Can be anything, but must be different from default.
|
|
|
|
sed -i "s/00000000-0000-0000-0000-000000000000/aced680f-30e9-40cc-a868-390ead14ba0c/" $out/lib/php/extensions/relay.so
|
|
|
|
chmod -w $out/lib/php/extensions/relay.so
|
2023-07-15 17:15:38 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2023-07-15 17:15:38 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = writeShellScript "update-${finalAttrs.pname}" ''
|
|
|
|
set -o errexit
|
2024-05-15 15:35:15 +00:00
|
|
|
export PATH="$PATH:${
|
|
|
|
lib.makeBinPath [
|
|
|
|
curl
|
|
|
|
common-updater-scripts
|
|
|
|
]
|
|
|
|
}"
|
2024-01-02 11:29:13 +00:00
|
|
|
NEW_VERSION=$(curl --silent https://builds.r2.relay.so/meta/builds | tail -n1 | cut -c2-)
|
|
|
|
|
|
|
|
if [[ "${version}" = "$NEW_VERSION" ]]; then
|
|
|
|
echo "The new version same as the old version."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
for source in ${lib.concatStringsSep " " (builtins.attrNames finalAttrs.passthru.updateables)}; do
|
2024-06-20 14:57:18 +00:00
|
|
|
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION" --ignore-same-version
|
2024-01-02 11:29:13 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
# All sources for updating by the update script.
|
|
|
|
updateables =
|
|
|
|
builtins.listToAttrs
|
|
|
|
# Collect all leaf attributes (containing hashes).
|
2024-05-15 15:35:15 +00:00
|
|
|
(
|
|
|
|
lib.collect (attrs: attrs ? name)
|
|
|
|
# create an attr containing
|
2024-01-02 11:29:13 +00:00
|
|
|
(
|
2024-05-15 15:35:15 +00:00
|
|
|
lib.mapAttrsRecursive (
|
|
|
|
path: _value:
|
|
|
|
lib.nameValuePair (builtins.replaceStrings [ "." ] [ "_" ] (lib.concatStringsSep "_" path)) (
|
|
|
|
finalAttrs.finalPackage.overrideAttrs (attrs: {
|
2024-01-02 11:29:13 +00:00
|
|
|
src = makeSource {
|
|
|
|
system = builtins.head path;
|
|
|
|
phpMajor = builtins.head (builtins.tail (builtins.tail path));
|
|
|
|
};
|
2024-05-15 15:35:15 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
) (lib.filterAttrsRecursive (name: _value: name != "platform") hashes)
|
2024-01-02 11:29:13 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Next-generation Redis extension for PHP";
|
|
|
|
changelog = "https://github.com/cachewerk/relay/releases/tag/v${version}";
|
|
|
|
homepage = "https://relay.so/";
|
|
|
|
sourceProvenance = [ sourceTypes.binaryNativeCode ];
|
|
|
|
license = licenses.unfree;
|
2024-05-15 15:35:15 +00:00
|
|
|
maintainers = with maintainers; [
|
|
|
|
tillkruss
|
|
|
|
ostrolucky
|
|
|
|
];
|
|
|
|
platforms = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
"x86_64-darwin"
|
|
|
|
"aarch64-darwin"
|
|
|
|
];
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
})
|