Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/mailman: postorius & hyperkitty support #67951

Merged
merged 6 commits into from Sep 11, 2019
Merged

Conversation

peti
Copy link
Member

@peti peti commented Sep 2, 2019

A simple Apache configuration for running Postorious and Hyperkitty looks as follows:

httpd = let webRoot = config.services.mailman.webRoot; in {
  enable = true;
  adminAddr = "postmaster@example.org";
  hostName = "lists.example.org";
  logPerVirtualHost = true;
  extraModules = [ { name = "wsgi"; path = "${pkgs.apacheHttpdPackages.mod_wsgi3}/modules/mod_wsgi.so"; } ];
  extraConfig = ''                                                                                                                                                                                                  
    WSGISocketPrefix /run/httpd/wsgi                                                                                                                                                                                
    WSGIDaemonProcess mailman threads=25 home=/var/lib/mailman-web python-path=${webRoot}:${
      lib.makeSearchPath pkgs.python3.sitePackages
        pkgs.python3Packages.mailman-web.requiredPythonModules
    }                                                                       
  '';
  virtualHosts = [
    { hostName = "lists.example.org";
      documentRoot = config.security.acme.certs."lists.example.org".webroot;
      extraConfig = ''                                                                                                                                                                                              
        <Directory "${config.security.acme.certs."lists.example.org".webroot}">                                                                                                                                     
          Options -Indexes                                                                                                                                                                                          
        </Directory>                                                                                                                                                                                                
        RedirectMatch permanent ^(?!/\.well-known/acme-challenge/).* https://lists.example.org$0                                                                                                                    
                                                                                                                                                                                                                    
      '';
    }
    { hostName = "lists.example.org";
      enableSSL = true;
      sslServerCert = "/var/lib/acme/lists.example.org/fullchain.pem";
      sslServerKey = "/var/lib/acme/lists.example.org/key.pem";
      servedDirs = [ { dir = "/var/lib/mailman-web/static"; urlPath = "/static"; } ];
      extraConfig = ''                                                                                                                                                                                              
        <Directory "${webRoot}">                                                                                                                                                                                    
          <Files wsgi.py>                                                                                                                                                                                           
            Require all granted                                                                                                                                                                                     
          </Files>                                                                                                                                                                                                  
          WSGIProcessGroup mailman                                                                                                                                                                                  
        </Directory>                                                                                                                                                                                                
        WSGIScriptAlias / ${webRoot}/wsgi.py                                                                                                                                                                        
      '';
    }
    { hostName = "localhost";
      servedDirs = [ { dir = "/var/lib/postorius/static"; urlPath = "/static"; } ];
      extraConfig = ''                                                                                                                                                                                              
        <Directory "${webRoot}">                                                                                                                                                                                    
          <Files wsgi.py>                                                                                                                                                                                           
            Require ip 127.0.0.1                                                                                                                                                                                    
            Require all granted                                                                                                                                                                                     
          </Files>                                                                                                                                                                                                  
          WSGIProcessGroup mailman                                                                                                                                                                                  
        </Directory>                                                                                                                                                                                                
        WSGIScriptAlias / ${webRoot}/wsgi.py                                                                                                                                                                        
      '';
    }
  ];
};

[1] https://gitlab.com/mailman/hyperkitty/tree/master/example_project

@peti peti added this to the 19.09 milestone Sep 2, 2019
@peti peti requested a review from globin September 2, 2019 14:28
@peti peti self-assigned this Sep 2, 2019
@peti peti requested a review from FRidh as a code owner September 10, 2019 15:16
@peti peti changed the title [WIP] nixos/mailman: hyperkitty support nixos/mailman: hyperkitty support Sep 10, 2019
@peti peti changed the title nixos/mailman: hyperkitty support nixos/mailman: postorius & hyperkitty support Sep 10, 2019
@peti
Copy link
Member Author

peti commented Sep 10, 2019

I've been running this code on my server for a while now and consider it good enough(tm) to be useful to others.

@FRidh
Copy link
Member

FRidh commented Sep 11, 2019 via email

@peti
Copy link
Member Author

peti commented Sep 11, 2019

It is not a Python module that is usable otherwise.

Users of Nixpkgs can use that module to set up the Mailman Web UI outside of NixOS.

@FRidh
Copy link
Member

FRidh commented Sep 11, 2019 via email

@peti
Copy link
Member Author

peti commented Sep 11, 2019

Great, then it needs to become a proper package.

I am sorry, @FRidh. I am aware of the fact that you dedicate a lot of time and effort into maintaining the Python infrastructure. I also realize that you perform a lot of updates, make sure everything works, and are actively maintaining that part of Nixpkgs here on Github. I totally respect that and I'd like to use the occasion to say thank you for all those efforts for all those years, which have benefited me greatly.

Having said that, the issue we are discussing here is a trivial minutiae that seems totally inconsequential. I don't understand where do you want to go with this. You seem to be pulling all kinds of rules and conventions out of thin air just for the sake of having something to criticize.

@FRidh
Copy link
Member

FRidh commented Sep 11, 2019

@peti initially it did not make sense to me to have mailman-web in there because it appeared to be configuration only for a module. You then made the point that it actually can be reusable, and I agree now with that. We actually do this in other places as well (I recall jupyter notebook or lab), where the logic is not included in the module so it can be used elsewhere.

Right now, the issue is that the modules are not in a site-package folder. That means that, by default, they are not importable. To make them importable they should be in a site-packages folder, or an environment variable like PYTHONPATH needs to be used to make them importable. In the module, you made it work because PYTHONPATH is set using the --pythonpath attribute.

The Python packages is meant only for packages that provide importable packages and modules. That means the modules need to be in a site-packages folder and the derivation marked in a certain way, using toPyhonModule (which buildPythonPackage) already does. Functions like python.buildEnv and python.withPackages rely on this. This is the part that matters to me and why I have this discussion.

Now, Django configuration is typically not put in a default site-packages folder because on systems the dependencies are often put separate from the web application configuration, however, there is no harm in doing so.

@peti
Copy link
Member Author

peti commented Sep 11, 2019

OK. That makes sense. I'll make the necessary changes to mailman-web.

When mailman-web restarts, it removes the generated "static" directory. This
breaks a currently running httpd process, which needs a re-start, too, to
obtain a new handle for the newly generated path.
@peti peti merged commit 5ba6173 into NixOS:master Sep 11, 2019
peti added a commit to peti/nixpkgs that referenced this pull request Sep 11, 2019
…-shift Python library

Suggested in NixOS#67951 (comment).

(cherry picked from commit 86f8895)
matthuszagh pushed a commit to matthuszagh/nixpkgs that referenced this pull request Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants