nixcloud/nixcloud-webservices

nixcloud.email: evaluation error when using nginx simultaniously

Closed this issue · 3 comments

When using the example config, I'm getting

error: cannot coerce null to a string, at /home/justin/git/nixcloud-webservices/modules/services/reverse-proxy/default.nix:224:7
(use ‘--show-trace’ to show detailed location information)

This is a test case, reproducing the issue:

import <nixpkgs/nixos/tests/make-test.nix> ({ pkgs, ...}:

{
  name = "nixcloud-email";

  nodes = {

    server =
      { config, pkgs, lib, ... }:

      let
        ipAddress = "8.19.10.3";
        ipv6Address = "201:48:11:403::1:1";
      in {
        imports = [
          <nixcloud-webservices/modules>
        ];
        nixcloud.email= {
          enable = true;
          domains = [ "lastlog.de" "dune2.de" ];
          ipAddress = ipAddress;
          ip6Address = ipv6Address;
          hostname = "mail.lastlog.de";
          users = [
            # see https://wiki.dovecot.org/Authentication/PasswordSchemes
            { name = "js"; domain = "lastlog.de"; password = "{SHA256-CRYPT}$<<<removed by qknight>>>"; }
            { name = "foo1"; domain = "dune2.de"; password = "{PLAIN}asdfasdfasdfasdf"; }
          ];
        };
        services.nginx = {
          enable = true;
          virtualHosts = {
            "example.com" = {
              locations."/" = {
                root = "/webroot/";
              };
              forceSSL = true;
              enableACME = true;
            };
          };
        };

      };
  };

  testScript = ''
    startAll;

  '';
})

Put it in test-email.nix and call it with

nix-build test-email.nix -I nixcloud-webservices=/path/to/your/nixcloud-webservices/ -I nixpkgs=https://d3g5gsiof5omrk.cloudfront.net/nixos/17.09/nixos-17.09.3154.b47b4f3dd3c/nixexprs.tar.xz

where nixpkgs is current nixos-17.09 and nixcloud-webservices current master.

thanks for that bug report, needs to be fixed!

note on services.nginx usage

if you want to use services.nginx then you need to disable ACME in nixcloud.email, see:

https://nixdoc.io/nixcloud-webservices/index.html#enableacme+nixcloud

use nixcloud.webservices instead of services.nginx, see:

https://github.com/nixcloud/nixcloud-webservices/blob/master/documentation/nixcloud.webservices.md#static-file-serving-no-cgi

documentation

i'll update the documentation about how to use services.nginx with nixcloud.reverse-proxy in parallel soon.

@erictapen fixed in 7a510de and the cause for the problem is fixed in nixpkgs by NixOS/nixpkgs@edeacd0#diff-3ac514cd8063d3114597ce7aa42b27cf