about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2022-05-12 20:46:39 +0200
committerGitHub <noreply@github.com>2022-05-12 20:46:39 +0200
commitfd5082695297c4ab4e551ff771b8fe9e2f110d0c (patch)
tree191d6d050ab5150c14529c2d85465bc21a4d0ec9 /pkgs
parent914c76f1004c6e0770e6129b6c2b3673fb2c887f (diff)
parentfd2616c92c81ba72ac72e433b2e3a055e324a97d (diff)
downloadnixlib-fd5082695297c4ab4e551ff771b8fe9e2f110d0c.tar
nixlib-fd5082695297c4ab4e551ff771b8fe9e2f110d0c.tar.gz
nixlib-fd5082695297c4ab4e551ff771b8fe9e2f110d0c.tar.bz2
nixlib-fd5082695297c4ab4e551ff771b8fe9e2f110d0c.tar.lz
nixlib-fd5082695297c4ab4e551ff771b8fe9e2f110d0c.tar.xz
nixlib-fd5082695297c4ab4e551ff771b8fe9e2f110d0c.tar.zst
nixlib-fd5082695297c4ab4e551ff771b8fe9e2f110d0c.zip
Merge pull request #104457 from ju1m/public-inbox
Update public-inbox to 1.8.0 and add systemd services
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/pkgs-lib/formats.nix11
-rw-r--r--pkgs/servers/mail/public-inbox/0002-msgtime-drop-Date-Parse-for-RFC2822.patch172
-rw-r--r--pkgs/servers/mail/public-inbox/default.nix143
3 files changed, 126 insertions, 200 deletions
diff --git a/pkgs/pkgs-lib/formats.nix b/pkgs/pkgs-lib/formats.nix
index 6495b024b008..cb46b63dd0c4 100644
--- a/pkgs/pkgs-lib/formats.nix
+++ b/pkgs/pkgs-lib/formats.nix
@@ -135,6 +135,17 @@ rec {
 
   };
 
+  gitIni = { listsAsDuplicateKeys ? false, ... }@args: {
+
+    type = with lib.types; let
+
+      iniAtom = (ini args).type/*attrsOf*/.functor.wrapped/*attrsOf*/.functor.wrapped;
+
+    in attrsOf (attrsOf (either iniAtom (attrsOf iniAtom)));
+
+    generate = name: value: pkgs.writeText name (lib.generators.toGitINI value);
+  };
+
   toml = {}: json {} // {
     type = with lib.types; let
       valueType = oneOf [
diff --git a/pkgs/servers/mail/public-inbox/0002-msgtime-drop-Date-Parse-for-RFC2822.patch b/pkgs/servers/mail/public-inbox/0002-msgtime-drop-Date-Parse-for-RFC2822.patch
deleted file mode 100644
index ebc9a6f22379..000000000000
--- a/pkgs/servers/mail/public-inbox/0002-msgtime-drop-Date-Parse-for-RFC2822.patch
+++ /dev/null
@@ -1,172 +0,0 @@
-From c9b5164c954cd0de80d971f1c4ced16bf41ea81b Mon Sep 17 00:00:00 2001
-From: Eric Wong <e@80x24.org>
-Date: Fri, 29 Nov 2019 12:25:07 +0000
-Subject: [PATCH 2/2] msgtime: drop Date::Parse for RFC2822
-
-Date::Parse is not optimized for RFC2822 dates and isn't
-packaged on OpenBSD.  It's still useful for historical
-email when email clients were less conformant, but is
-less relevant for new emails.
----
- lib/PublicInbox/MsgTime.pm | 115 ++++++++++++++++++++++++++++++++-----
- t/msgtime.t                |   6 ++
- 2 files changed, 107 insertions(+), 14 deletions(-)
-
-diff --git a/lib/PublicInbox/MsgTime.pm b/lib/PublicInbox/MsgTime.pm
-index 58e11d72..e9b27a49 100644
---- a/lib/PublicInbox/MsgTime.pm
-+++ b/lib/PublicInbox/MsgTime.pm
-@@ -7,24 +7,114 @@ use strict;
- use warnings;
- use base qw(Exporter);
- our @EXPORT_OK = qw(msg_timestamp msg_datestamp);
--use Date::Parse qw(str2time strptime);
-+use Time::Local qw(timegm);
-+my @MoY = qw(january february march april may june
-+		july august september october november december);
-+my %MoY;
-+@MoY{@MoY} = (0..11);
-+@MoY{map { substr($_, 0, 3) } @MoY} = (0..11);
-+
-+my %OBSOLETE_TZ = ( # RFC2822 4.3 (Obsolete Date and Time)
-+	EST => '-0500', EDT => '-0400',
-+	CST => '-0600', CDT => '-0500',
-+	MST => '-0700', MDT => '-0600',
-+	PST => '-0800', PDT => '-0700',
-+	UT => '+0000', GMT => '+0000', Z => '+0000',
-+
-+	# RFC2822 states:
-+	#   The 1 character military time zones were defined in a non-standard
-+	#   way in [RFC822] and are therefore unpredictable in their meaning.
-+);
-+my $OBSOLETE_TZ = join('|', keys %OBSOLETE_TZ);
- 
- sub str2date_zone ($) {
- 	my ($date) = @_;
-+	my ($ts, $zone);
-+
-+	# RFC822 is most likely for email, but we can tolerate an extra comma
-+	# or punctuation as long as all the data is there.
-+	# We'll use '\s' since Unicode spaces won't affect our parsing.
-+	# SpamAssassin ignores commas and redundant spaces, too.
-+	if ($date =~ /(?:[A-Za-z]+,?\s+)? # day-of-week
-+			([0-9]+),?\s+  # dd
-+			([A-Za-z]+)\s+ # mon
-+			([0-9]{2,})\s+ # YYYY or YY (or YYY :P)
-+			([0-9]+)[:\.] # HH:
-+				((?:[0-9]{2})|(?:\s?[0-9])) # MM
-+				(?:[:\.]((?:[0-9]{2})|(?:\s?[0-9])))? # :SS
-+			\s+	# a TZ offset is required:
-+				([\+\-])? # TZ sign
-+				[\+\-]* # I've seen extra "-" e.g. "--500"
-+				([0-9]+|$OBSOLETE_TZ)(?:\s|$) # TZ offset
-+			/xo) {
-+		my ($dd, $m, $yyyy, $hh, $mm, $ss, $sign, $tz) =
-+					($1, $2, $3, $4, $5, $6, $7, $8);
-+		# don't accept non-English months
-+		defined(my $mon = $MoY{lc($m)}) or return;
-+
-+		if (defined(my $off = $OBSOLETE_TZ{$tz})) {
-+			$sign = substr($off, 0, 1);
-+			$tz = substr($off, 1);
-+		}
-+
-+		# Y2K problems: 3-digit years, follow RFC2822
-+		if (length($yyyy) <= 3) {
-+			$yyyy += 1900;
-+
-+			# and 2-digit years from '09 (2009) (0..49)
-+			$yyyy += 100 if $yyyy < 1950;
-+		}
-+
-+		$ts = timegm($ss // 0, $mm, $hh, $dd, $mon, $yyyy);
- 
--	my $ts = str2time($date);
--	return undef unless(defined $ts);
-+		# Compute the time offset from [+-]HHMM
-+		$tz //= 0;
-+		my ($tz_hh, $tz_mm);
-+		if (length($tz) == 1) {
-+			$tz_hh = $tz;
-+			$tz_mm = 0;
-+		} elsif (length($tz) == 2) {
-+			$tz_hh = 0;
-+			$tz_mm = $tz;
-+		} else {
-+			$tz_hh = $tz;
-+			$tz_hh =~ s/([0-9]{2})\z//;
-+			$tz_mm = $1;
-+		}
-+		while ($tz_mm >= 60) {
-+			$tz_mm -= 60;
-+			$tz_hh += 1;
-+		}
-+		$sign //= '+';
-+		my $off = $sign . ($tz_mm * 60 + ($tz_hh * 60 * 60));
-+		$ts -= $off;
-+		$sign = '+' if $off == 0;
-+		$zone = sprintf('%s%02d%02d', $sign, $tz_hh, $tz_mm);
- 
--	# off is the time zone offset in seconds from GMT
--	my ($ss,$mm,$hh,$day,$month,$year,$off) = strptime($date);
--	return undef unless(defined $off);
-+	# Time::Zone and Date::Parse are part of the same distibution,
-+	# and we need Time::Zone to deal with tz names like "EDT"
-+	} elsif (eval { require Date::Parse }) {
-+		$ts = Date::Parse::str2time($date);
-+		return undef unless(defined $ts);
- 
--	# Compute the time zone from offset
--	my $sign = ($off < 0) ? '-' : '+';
--	my $hour = abs(int($off / 3600));
--	my $min  = ($off / 60) % 60;
--	my $zone = sprintf('%s%02d%02d', $sign, $hour, $min);
-+		# off is the time zone offset in seconds from GMT
-+		my ($ss,$mm,$hh,$day,$month,$year,$off) =
-+					Date::Parse::strptime($date);
-+		return undef unless(defined $off);
-+
-+		# Compute the time zone from offset
-+		my $sign = ($off < 0) ? '-' : '+';
-+		my $hour = abs(int($off / 3600));
-+		my $min  = ($off / 60) % 60;
-+
-+		$zone = sprintf('%s%02d%02d', $sign, $hour, $min);
-+	} else {
-+		warn "Date::Parse missing for non-RFC822 date: $date\n";
-+		return undef;
-+	}
- 
-+	# Note: we've already applied the offset to $ts at this point,
-+	# but we want to keep "git fsck" happy.
- 	# "-1200" is the furthest westermost zone offset,
- 	# but git fast-import is liberal so we use "-1400"
- 	if ($zone >= 1400 || $zone <= -1400) {
-@@ -59,9 +149,6 @@ sub msg_date_only ($) {
- 	my @date = $hdr->header_raw('Date');
- 	my ($ts);
- 	foreach my $d (@date) {
--		# Y2K problems: 3-digit years
--		$d =~ s!([A-Za-z]{3}) ([0-9]{3}) ([0-9]{2}:[0-9]{2}:[0-9]{2})!
--			my $yyyy = $2 + 1900; "$1 $yyyy $3"!e;
- 		$ts = eval { str2date_zone($d) } and return $ts;
- 		if ($@) {
- 			my $mid = $hdr->header_raw('Message-ID');
-diff --git a/t/msgtime.t b/t/msgtime.t
-index 6b396602..d9643b65 100644
---- a/t/msgtime.t
-+++ b/t/msgtime.t
-@@ -84,4 +84,10 @@ is_deeply(datestamp('Fri, 28 Jun 2002 12:54:40 -700'), [1025294080, '-0700']);
- is_deeply(datestamp('Sat, 12 Jan 2002 12:52:57 -200'), [1010847177, '-0200']);
- is_deeply(datestamp('Mon, 05 Nov 2001 10:36:16 -800'), [1004985376, '-0800']);
- 
-+# obsolete formats described in RFC2822
-+for (qw(UT GMT Z)) {
-+	is_deeply(datestamp('Fri, 02 Oct 1993 00:00:00 '.$_), [ 749520000, '+0000']);
-+}
-+is_deeply(datestamp('Fri, 02 Oct 1993 00:00:00 EDT'), [ 749534400, '-0400']);
-+
- done_testing();
--- 
-2.24.1
-
diff --git a/pkgs/servers/mail/public-inbox/default.nix b/pkgs/servers/mail/public-inbox/default.nix
index affcb0e8b237..8ffbab1eac19 100644
--- a/pkgs/servers/mail/public-inbox/default.nix
+++ b/pkgs/servers/mail/public-inbox/default.nix
@@ -1,19 +1,73 @@
-{ buildPerlPackage, lib, fetchurl, fetchpatch, makeWrapper
-, DBDSQLite, EmailMIME, IOSocketSSL, IPCRun, Plack, PlackMiddlewareReverseProxy
-, SearchXapian, TimeDate, URI
-, git, highlight, openssl, xapian
+{ stdenv, lib, fetchurl, makeWrapper, nixosTests
+, buildPerlPackage
+, coreutils
+, curl
+, git
+, gnumake
+, highlight
+, libgit2
+, man
+, openssl
+, pkg-config
+, sqlite
+, xapian
+, AnyURIEscape
+, DBDSQLite
+, DBI
+, EmailAddressXS
+, EmailMIME
+, IOSocketSSL
+, IPCRun
+, Inline
+, InlineC
+, LinuxInotify2
+, MailIMAPClient
+, ParseRecDescent
+, Plack
+, PlackMiddlewareReverseProxy
+, SearchXapian
+, TimeDate
+, URI
 }:
 
 let
 
-  # These tests would fail, and produce "Operation not permitted"
-  # errors from git, because they use git init --shared.  This tries
-  # to set the setgid bit, which isn't permitted inside build
-  # sandboxes.
-  #
-  # These tests were indentified with
-  #     grep -r shared t/
-  skippedTests = [ "convert-compact" "search" "v2writable" "www_listing" ];
+  skippedTests = [
+    # These tests would fail, and produce "Operation not permitted"
+    # errors from git, because they use git init --shared.  This tries
+    # to set the setgid bit, which isn't permitted inside build
+    # sandboxes.
+    #
+    # These tests were indentified with
+    #     grep -r shared t/
+    "convert-compact" "search" "v2writable" "www_listing"
+    # perl5.32.0-public-inbox> t/eml.t ...................... 1/? Cannot parse parameter '=?ISO-8859-1?Q?=20charset=3D=1BOF?=' at t/eml.t line 270.
+    # perl5.32.0-public-inbox> #   Failed test 'got wide character by assuming utf-8'
+    # perl5.32.0-public-inbox> #   at t/eml.t line 272.
+    # perl5.32.0-public-inbox> Wide character in print at /nix/store/38vxlxrvg3yji3jms44qn94lxdysbj5j-perl-5.32.0/lib/perl5/5.32.0/Test2/Formatter/TAP.pm line 125.
+    "eml"
+    # Failed test 'Makefile OK'
+    # at t/hl_mod.t line 19.
+    #        got: 'makefile'
+    #   expected: 'make'
+    "hl_mod"
+    # Failed test 'clone + index v1 synced ->created_at'
+    # at t/lei-mirror.t line 175.
+    #        got: '1638378723'
+    #   expected: undef
+    # Failed test 'clone + index v1 synced ->created_at'
+    # at t/lei-mirror.t line 178.
+    #        got: '1638378723'
+    #   expected: undef
+    # May be due to the use of $ENV{HOME}.
+    "lei-mirror"
+    # Failed test 'child error (pure-Perl)'
+    # at t/spawn.t line 33.
+    #        got: '0'
+    #   expected: anything else
+    # waiting for child to reap grandchild...
+    "spawn"
+  ];
 
   testConditions = with lib;
     concatMapStringsSep " " (n: "! -name ${escapeShellArg n}.t") skippedTests;
@@ -22,53 +76,86 @@ in
 
 buildPerlPackage rec {
   pname = "public-inbox";
-  version = "1.2.0";
+  version = "1.8.0";
 
   src = fetchurl {
-    url = "https://public-inbox.org/releases/public-inbox-${version}.tar.gz";
-    sha256 = "0sa2m4f2x7kfg3mi4im7maxqmqvawafma8f7g92nyfgybid77g6s";
+    url = "https://public-inbox.org/public-inbox.git/snapshot/public-inbox-${version}.tar.gz";
+    sha256 = "sha256-laJOOCk5NecIGWesv4D30cLGfijQHVkeo55eNqNKzew=";
   };
 
-  patches = [
-    (fetchpatch {
-      url = "https://public-inbox.org/meta/20200101032822.GA13063@dcvr/raw";
-      sha256 = "0ncxqqkvi5lwi8zaa7lk7l8mf8h278raxsvbvllh3z7jhfb48r3l";
-    })
-    ./0002-msgtime-drop-Date-Parse-for-RFC2822.patch
-  ];
-
   outputs = [ "out" "devdoc" "sa_config" ];
 
   postConfigure = ''
     substituteInPlace Makefile --replace 'TEST_FILES = t/*.t' \
         'TEST_FILES = $(shell find t -name *.t ${testConditions})'
+    substituteInPlace lib/PublicInbox/TestCommon.pm \
+      --replace /bin/cp ${coreutils}/bin/cp
   '';
 
   nativeBuildInputs = [ makeWrapper ];
 
   buildInputs = [
-    DBDSQLite EmailMIME IOSocketSSL IPCRun Plack PlackMiddlewareReverseProxy
-    SearchXapian TimeDate URI highlight
+    AnyURIEscape
+    DBDSQLite
+    DBI
+    EmailAddressXS
+    EmailMIME
+    highlight
+    IOSocketSSL
+    IPCRun
+    Inline
+    InlineC
+    ParseRecDescent
+    Plack
+    PlackMiddlewareReverseProxy
+    SearchXapian
+    TimeDate
+    URI
+    libgit2 # For Gcf2
+    man
   ];
 
-  checkInputs = [ git openssl xapian ];
+  doCheck = !stdenv.isDarwin;
+  checkInputs = [
+    MailIMAPClient
+    curl
+    git
+    openssl
+    pkg-config
+    sqlite
+    xapian
+  ] ++ lib.optionals stdenv.isLinux [
+    LinuxInotify2
+  ];
   preCheck = ''
     perl certs/create-certs.perl
+    export TEST_LEI_ERR_LOUD=1
+    export HOME="$NIX_BUILD_TOP"/home
+    mkdir -p "$HOME"/.cache/public-inbox/inline-c
   '';
 
   installTargets = [ "install" ];
   postInstall = ''
     for prog in $out/bin/*; do
-        wrapProgram $prog --prefix PATH : ${lib.makeBinPath [ git ]}
+        wrapProgram $prog --prefix PATH : ${lib.makeBinPath [
+          git
+          /* for InlineC */
+          gnumake
+          stdenv.cc.cc
+        ]}
     done
 
     mv sa_config $sa_config
   '';
 
+  passthru.tests = {
+    nixos-public-inbox = nixosTests.public-inbox;
+  };
+
   meta = with lib; {
     homepage = "https://public-inbox.org/";
     license = licenses.agpl3Plus;
-    maintainers = with maintainers; [ qyliss ];
+    maintainers = with maintainers; [ julm qyliss ];
     platforms = platforms.all;
   };
 }