1{
2 buildPecl,
3 fetchFromGitHub,
4 fetchpatch,
5 lib,
6 php,
7 runCommand,
8 systemd,
9}:
10
11buildPecl {
12 pname = "systemd";
13 version = "0.1.2-unstable-2018-06-11";
14
15 src = fetchFromGitHub {
16 owner = "systemd";
17 repo = "php-systemd";
18 rev = "22cf92a6b54ef4c5c13c301fc97d7a7b1615ee62";
19 hash = "sha256-UhpE9QXChqKLBqutpQ2Y6neo/ULlJGNojf9DCYJfQMU=";
20 };
21
22 patches = [
23 # Add missing arginfo to suppress the warning
24 # https://github.com/systemd/php-systemd/issues/9
25 (fetchpatch {
26 url = "https://github.com/systemd/php-systemd/commit/0f25ec9aab7747e85445a48213020ea6adda3658.diff";
27 hash = "sha256-SNRYDRxaeP9LlHxfZOak0OSqZ3AJA+I9Ln0k+yO0DvE=";
28 })
29 # Define SD_JOURNAL_SUPPRESS_LOCATION so that the php source code location is used, instead of the C one
30 # https://github.com/systemd/php-systemd/issues/2
31 (fetchpatch {
32 url = "https://github.com/systemd/php-systemd/commit/23575461b8cc55fa9c4132a58393b6438c2aff5c.diff";
33 hash = "sha256-KBGWdNE7spXpqbeS4c2D5IU3Dz8zGxx4r22FDOA0KzM=";
34 })
35 ];
36
37 buildInputs = [ systemd.dev ];
38
39 configureFlags = [ "--with-systemd=${systemd.dev}" ];
40
41 # php will exit with a non-zero exit code, if the extension is not loaded
42 passthru.tests.smokeTest = runCommand "php-systemd-smoke-test" { } ''
43 echo "<?php sd_journal_send('MESSAGE=Hello world.'); ?>" |
44 ${lib.getExe (php.withExtensions ({ all, ... }: [ all.systemd ]))}
45 echo ok > $out
46 '';
47
48 meta = {
49 description = "PHP extension allowing native interaction with systemd and its journal";
50 homepage = "https://github.com/systemd/php-systemd";
51 license = lib.licenses.mit;
52 teams = [ lib.teams.php ];
53 };
54}