From 0b27c74eb2517d307b1c1bbd04567157fba7cb63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Czy=C5=BC?= Date: Sun, 26 Feb 2017 10:14:32 +0000 Subject: [PATCH] pgjwt: init at 0.0.1 (#22644) --- nixos/release.nix | 1 + nixos/tests/pgjwt.nix | 42 +++++++++++++++++++ pkgs/servers/sql/postgresql/pgjwt/default.nix | 25 +++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 70 insertions(+) create mode 100644 nixos/tests/pgjwt.nix create mode 100644 pkgs/servers/sql/postgresql/pgjwt/default.nix diff --git a/nixos/release.nix b/nixos/release.nix index 0f93deddf263..2bfe8eada0b8 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -286,6 +286,7 @@ in rec { tests.pam-oath-login = callTest tests/pam-oath-login.nix {}; #tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; }); tests.peerflix = callTest tests/peerflix.nix {}; + tests.pgjwt = callTest tests/pgjwt.nix {}; tests.postgresql = callTest tests/postgresql.nix {}; tests.printing = callTest tests/printing.nix {}; tests.proxy = callTest tests/proxy.nix {}; diff --git a/nixos/tests/pgjwt.nix b/nixos/tests/pgjwt.nix new file mode 100644 index 000000000000..2cf2963ae316 --- /dev/null +++ b/nixos/tests/pgjwt.nix @@ -0,0 +1,42 @@ +import ./make-test.nix ({ pkgs, ...} : +let + test = pkgs.writeText "test.sql" '' + CREATE EXTENSION pgcrypto; + CREATE EXTENSION pgjwt; + select sign('{"sub":"1234567890","name":"John Doe","admin":true}', 'secret'); + select * from verify('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ', 'secret'); + ''; +in +{ + name = "pgjwt"; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ spinus ]; + }; + + nodes = { + master = + { pkgs, config, ... }: + + { + services.postgresql = let mypg = pkgs.postgresql95; in { + enable = true; + package = mypg; + extraPlugins =[pkgs.pgjwt]; + initialScript = pkgs.writeText "postgresql-init.sql" + '' + CREATE ROLE postgres WITH superuser login createdb; + ''; + }; + }; + }; + + testScript = '' + startAll; + $master->waitForUnit("postgresql"); + $master->succeed("timeout 10 bash -c 'while ! psql postgres -c \"SELECT 1;\";do sleep 1;done;'"); + $master->succeed("cat ${test} | psql postgres"); + # I can't make original test working :[ + # $master->succeed("${pkgs.perlPackages.TAPParserSourceHandlerpgTAP}/bin/pg_prove -d postgres ${pkgs.pgjwt.src}/test.sql"); + + ''; +}) diff --git a/pkgs/servers/sql/postgresql/pgjwt/default.nix b/pkgs/servers/sql/postgresql/pgjwt/default.nix new file mode 100644 index 000000000000..b4955f8184c2 --- /dev/null +++ b/pkgs/servers/sql/postgresql/pgjwt/default.nix @@ -0,0 +1,25 @@ +{ stdenv, fetchFromGitHub }: +stdenv.mkDerivation rec { + name = "pgjwt-${version}"; + version = "0.0.1"; + src = fetchFromGitHub { + owner = "michelp"; + repo = "pgjwt"; + rev = "12a41eef15e6d3a22399e03178560d5174d496a3"; + sha256 = "1dgx7kqkf9d7j5qj3xykx238xm8jg0s6c8h7zyl4lx8dmbz9sgsv"; + }; + dontBuild = true; + installPhase = '' + mkdir -p $out/bin # current postgresql extension mechanism in nixos requires bin directory + mkdir -p $out/share/extension + cp pg*sql *.control $out/share/extension + ''; + meta = with stdenv.lib; { + description = "PostgreSQL implementation of JSON Web Tokens"; + longDescription = '' + sign() and verify() functions to create and verify JSON Web Tokens. + ''; + license = licenses.mit; + maintainers = with maintainers; [spinus]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2a5d95916ee2..a02327d81852 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2141,6 +2141,8 @@ with pkgs; pgf_graphics = callPackage ../tools/graphics/pgf { }; + pgjwt = callPackage ../servers/sql/postgresql/pgjwt {}; + pigz = callPackage ../tools/compression/pigz { }; pixz = callPackage ../tools/compression/pixz { };