diff options
author | Alyssa Ross <hi@alyssa.is> | 2020-07-13 22:00:09 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2020-07-13 23:10:03 +0000 |
commit | add8759f14c9ebb65bca21a95e317e4316d3f6be (patch) | |
tree | 3a67356df4b197a7add4034478499bc91d2258dc /overlays/patches/public-inbox | |
parent | 424dfb57297d0d1af4467571b8d739b08b02fca8 (diff) | |
download | nixlib-add8759f14c9ebb65bca21a95e317e4316d3f6be.tar nixlib-add8759f14c9ebb65bca21a95e317e4316d3f6be.tar.gz nixlib-add8759f14c9ebb65bca21a95e317e4316d3f6be.tar.bz2 nixlib-add8759f14c9ebb65bca21a95e317e4316d3f6be.tar.lz nixlib-add8759f14c9ebb65bca21a95e317e4316d3f6be.tar.xz nixlib-add8759f14c9ebb65bca21a95e317e4316d3f6be.tar.zst nixlib-add8759f14c9ebb65bca21a95e317e4316d3f6be.zip |
overlays: don't apply to all nixpkgs trees
Since the nixlib root is the NIX_PATH root, overlays were in the NIX_PATH as "nixpkgs-overlays". Nixpkgs imports that by default to look for overlays. This meant that an arbitrary Nixpkgs tree would end up trying to use the Nixlib overlays, which wouldn't always work. It would also mean that derivations built from those trees wouldn't match the ones other people would try to build, which is undesirable for working on nixpkgs. I think this is unfortunate behaviour for anybody working on nixpkgs, and nixpkgs probably shouldn't load overlays from impurely at all by default, but it is what it is. Since I can't really change what upstream nixpkgs does here, the best I can do is change the nixpkgs in nixlib. It will now load overlays from a sibling "overlays" directory. Renaming the "nixpkgs-overlays" directory at the nixlib root to "overlays" means that it will be loaded by default _only_ by the nixpkgs it is colocated with. It also means that it is still accessible in the NIX_PATH as <overlays>, which is fine and convenient as long as nothing starts looking at that by default.
Diffstat (limited to 'overlays/patches/public-inbox')
4 files changed, 173 insertions, 0 deletions
diff --git a/overlays/patches/public-inbox/0003-view-don-t-show-page-if-no-links-follow-it.patch b/overlays/patches/public-inbox/0003-view-don-t-show-page-if-no-links-follow-it.patch new file mode 100644 index 000000000000..811d6149d994 --- /dev/null +++ b/overlays/patches/public-inbox/0003-view-don-t-show-page-if-no-links-follow-it.patch @@ -0,0 +1,27 @@ +From 054697a5129725f900a84bbdfee356a4f5373376 Mon Sep 17 00:00:00 2001 +From: Alyssa Ross <hi@alyssa.is> +Date: Thu, 16 Jan 2020 18:08:33 +0000 +Subject: [PATCH 3/5] view: don't show `page:' if no links follow it + +--- + lib/PublicInbox/View.pm | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm +index 39b04174..aebf7fe9 100644 +--- a/lib/PublicInbox/View.pm ++++ b/lib/PublicInbox/View.pm +@@ -1157,7 +1157,9 @@ sub pagination_footer ($$) { + $next = $next ? "$next " : ' '; + $prev .= qq! <a\nhref='$latest'>latest</a>!; + } +- "<hr><pre>page: $next$prev</pre>"; ++ if ($prev || $next) { ++ "<hr><pre>page: $next$prev</pre>"; ++ } + } + + sub index_nav { # callback for WwwStream +-- +2.26.1 + diff --git a/overlays/patches/public-inbox/0004-view-don-t-500-if-no-mail-received-yet.patch b/overlays/patches/public-inbox/0004-view-don-t-500-if-no-mail-received-yet.patch new file mode 100644 index 000000000000..eb33468e1992 --- /dev/null +++ b/overlays/patches/public-inbox/0004-view-don-t-500-if-no-mail-received-yet.patch @@ -0,0 +1,25 @@ +From 2712913f07d83a6a33bbdc55a1edee0a008e5b2e Mon Sep 17 00:00:00 2001 +From: Alyssa Ross <hi@alyssa.is> +Date: Thu, 16 Jan 2020 18:09:12 +0000 +Subject: [PATCH 4/5] view: don't 500 if no mail received yet + +--- + lib/PublicInbox/View.pm | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm +index aebf7fe9..b40108bc 100644 +--- a/lib/PublicInbox/View.pm ++++ b/lib/PublicInbox/View.pm +@@ -1083,7 +1083,7 @@ sub acc_topic { + sub dump_topics { + my ($ctx) = @_; + my $order = delete $ctx->{order}; # [ ds, subj1, subj2, subj3, ... ] +- if (!@$order) { ++ if (!defined $order || !@$order) { + $ctx->{-html_tip} = '<pre>[No topics in range]</pre>'; + return 404; + } +-- +2.26.1 + diff --git a/overlays/patches/public-inbox/0005-wwwstream-make-source-info-configurable.patch b/overlays/patches/public-inbox/0005-wwwstream-make-source-info-configurable.patch new file mode 100644 index 000000000000..605100cd38ae --- /dev/null +++ b/overlays/patches/public-inbox/0005-wwwstream-make-source-info-configurable.patch @@ -0,0 +1,112 @@ +From f119d4315be998de65d5a1b56fa643fb9084410b Mon Sep 17 00:00:00 2001 +From: Alyssa Ross <hi@alyssa.is> +Date: Fri, 17 Jan 2020 15:21:42 +0000 +Subject: [PATCH 5/5] wwwstream: make source info configurable + +--- + Documentation/public-inbox-config.pod | 6 ++++++ + lib/PublicInbox/WwwListing.pm | 9 +++++---- + lib/PublicInbox/WwwStream.pm | 28 +++++++++++++++++++++++---- + 3 files changed, 35 insertions(+), 8 deletions(-) + +diff --git a/Documentation/public-inbox-config.pod b/Documentation/public-inbox-config.pod +index 1c5ba015..5ae23924 100644 +--- a/Documentation/public-inbox-config.pod ++++ b/Documentation/public-inbox-config.pod +@@ -186,6 +186,12 @@ and the path may be "/dev/null" or any empty file. + Multiple files may be specified and will be included in the + order specified. + ++=item publicinbox.sourceinfo ++ ++Path to a file containing HTML instructions for downloading the ++public-inbox source code. Useful for AGPL compliance. If not ++specified, default git clone instructions are used. ++ + =item publicinboxmda.spamcheck + + This may be set to C<none> to disable the use of SpamAssassin +diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm +index 03534f03..f1a1fd81 100644 +--- a/lib/PublicInbox/WwwListing.pm ++++ b/lib/PublicInbox/WwwListing.pm +@@ -87,8 +87,8 @@ sub ibx_entry { + $tmp; + } + +-sub html ($$) { +- my ($env, $list) = @_; ++sub html ($$$) { ++ my ($pi_config, $env, $list) = @_; + my $title = 'public-inbox'; + my $out = ''; + my $code = 404; +@@ -107,7 +107,8 @@ sub html ($$) { + $out = '<pre>'.$l->linkify_2(ascii_html($tmp)).'</pre><hr>'; + } + $out = "<html><head><title>$title</title></head><body>" . $out; +- $out .= '<pre>'. PublicInbox::WwwStream::code_footer($env) . ++ $out .= '<pre>' . ++ PublicInbox::WwwStream::code_footer($pi_config, $env) . + '</pre></body></html>'; + + my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ]; +@@ -231,7 +232,7 @@ sub call { + js($env, $list); + } else { # / + my $list = $self->{www_cb}->($self, $env, 'www'); +- html($env, $list); ++ html($self->{pi_config}, $env, $list); + } + } + +diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm +index 0f4f55d0..09473c9f 100644 +--- a/lib/PublicInbox/WwwStream.pm ++++ b/lib/PublicInbox/WwwStream.pm +@@ -76,10 +76,30 @@ sub _html_top ($) { + "</head><body>". $top . $tip; + } + +-sub code_footer ($) { +- my ($env) = @_; ++sub get_user_source_info ($) { ++ my ($pi_config) = @_; ++ ++ local $/; ++ my $path = $pi_config->{'publicinbox.sourceinfo'}; ++ if (!defined($path)) { ++ return; ++ } ++ open my $fh, '<', $path or do { ++ warn "Failed to open publicinbox.sourceinfo=$path: $!\n"; ++ return; ++ }; ++ <$fh>; ++} ++ ++sub code_footer { ++ my ($pi_config, $env) = @_; ++ + my $u = PublicInbox::Hval::prurl($env, $CODE_URL); +- qq(AGPL code for this site: git clone <a\nhref="$u">$u</a>) ++ my $default_info = qq(git clone <a\n href="$u">$u</a>); ++ ++ my $info = get_user_source_info($pi_config) || $default_info; ++ ++ "AGPL code for this site: $info" + } + + sub _html_end { +@@ -153,7 +173,7 @@ EOF + '<hr><pre>'.join("\n\n", + $desc, + $urls, +- code_footer($ctx->{env}) ++ code_footer($ctx->{www}->{pi_config}, $ctx->{env}) + ).'</pre></body></html>'; + } + +-- +2.26.1 + diff --git a/overlays/patches/public-inbox/default.nix b/overlays/patches/public-inbox/default.nix new file mode 100644 index 000000000000..f9f573787c1c --- /dev/null +++ b/overlays/patches/public-inbox/default.nix @@ -0,0 +1,9 @@ +{ public-inbox }: + +public-inbox.overrideAttrs ({ patches ? [], ... }: { + patches = patches ++ [ + ./0003-view-don-t-show-page-if-no-links-follow-it.patch + ./0004-view-don-t-500-if-no-mail-received-yet.patch + ./0005-wwwstream-make-source-info-configurable.patch + ]; +}) |