depot/pkgs/servers/sql/postgresql/ext/pgsodium.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

61 lines
1.6 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, libsodium
, postgresql
, postgresqlTestExtension
}:
stdenv.mkDerivation (finalAttrs: {
pname = "pgsodium";
version = "3.1.9";
src = fetchFromGitHub {
owner = "michelp";
repo = "pgsodium";
rev = "v${finalAttrs.version}";
hash = "sha256-Y8xL3PxF1GQV1JIgolMI1e8oGcUvWAgrPv84om7wKP8=";
};
buildInputs = [
libsodium
postgresql
];
installPhase = ''
runHook preInstall
install -D -t $out/lib pgsodium${postgresql.dlSuffix}
install -D -t $out/share/postgresql/extension sql/pgsodium-*.sql
install -D -t $out/share/postgresql/extension pgsodium.control
install -D -t $out/share/pgsodium/getkey_scripts getkey_scripts/*
ln -s $out/share/pgsodium/getkey_scripts/pgsodium_getkey_urandom.sh $out/share/postgresql/extension/pgsodium_getkey
runHook postInstall
'';
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
postgresqlExtraSettings = ''
shared_preload_libraries=pgsodium
'';
sql = ''
CREATE EXTENSION pgsodium;
SELECT pgsodium.version();
SELECT pgsodium.crypto_auth_keygen();
SELECT pgsodium.randombytes_random() FROM generate_series(0, 5);
SELECT * FROM pgsodium.crypto_box_new_keypair();
'';
};
meta = with lib; {
description = "Modern cryptography for PostgreSQL using libsodium";
homepage = "https://github.com/michelp/pgsodium";
changelog = "https://github.com/michelp/pgsodium/releases/tag/v${finalAttrs.version}";
license = licenses.postgresql;
maintainers = [ ];
platforms = postgresql.meta.platforms;
};
})