SNM (mail server) not building

I’m trying to install SNM, but i get a error when trying to nixos-rebuild.

building Nix...
building the system configuration...
error:
       … while calling the 'head' builtin

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:922:11:

          921|         || pred here (elemAt values 1) (head values) then
          922|           head values
             |           ^
          923|         else

       … while evaluating the attribute 'value'

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:807:9:

          806|     in warnDeprecation opt //
          807|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          808|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: cannot coerce null to a string

–show-trace doesn’t show me anything I understand and I’ve gone over my configuration.nix several times without finding anything wrong (to my eyes).

If anyone can point me in the right direction on this i would be very happy!
Running nixos 23.11 on a VPS.

Could you please provide more detail about the Nixpkgs revision you use to input your system configuration, the nix-info -m output, and the configuration you use to invoke SNM?

1 Like

:sweat_smile:

While collecting the information you asked for I noticed I’d only set “security.acme.certs” e-mail for my domain and not for the fqdn… Seems to work now!

Thank you for helping!

1 Like

That’s still an awful error. Do you have a minimal reproducible example?

Not sure if i can provide that, i’m new to nixos and don’t want to try and remove to much from my config. I can however provide my config (without parts that can’t be involved and my domains and stuff) . If there is anything i can provide, test or run that would give you any useful information just tell me how and I’d be glad to do it!


{ config, lib, pkgs, ... }:
{
  imports =
    [ 
      (builtins.fetchTarball {
        # Pick a release version you are interested in and set its hash, e.g.
        url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/nixos-23.11/nixos-mailserver-nixos-23.11.tar.gz";
        # To get the sha256 of the nixos-mailserver tarball, we can use the nix-prefetch-url command:
        # release="nixos-23.11"; nix-prefetch-url "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/${release}/nixos-mailserver-${release}.tar.gz" --unpack
        sha256 = "122vm4n3gkvlkqmlskiq749bhwfd0r71v6vcmg1bbyg4998brvx8";
      })
     ];


  mailserver = {
    enable = true;
    fqdn = "mail.domain.com";
    domains = [ "domain.com" ];
    openFirewall = true;
    loginAccounts = {
      "user1@domain.com" = {
	hashedPassword = "PASSWORDHASH";
        aliases = ["postmaster@domain.com"];
      };
      "user2@domain.com" = {
	hashedPassword = "PASSWORDHASH";
      };
    };

    certificateScheme = "acme-nginx";

    enableImap = true;
    enablePop3 = true;
    enableImapSsl = true;
    enablePop3Ssl = true;
    
  };


  networking.firewall = {
    enable = true;
    allowedTCPPorts = [ 80 443 ];
    allowedUDPPortRanges = [
    ];
  };

  services.openssh.openFirewall = true;

  services.nginx = {
    enable = true;
    virtualHosts."domain.com" = {
      enableACME = true;
      forceSSL = true;
      root = "/var/www/domain.com";
    };
  };
  
  #########################################################
  # This (below) is where I think my error was, it works as intended if i use 'defaults.email' or add 'certs."mail.domain.com".email'
  # leaving this with only a mail for the 'top/main' domain gets me the "error: cannot coerce null to a string"
  #########################################################
  security.acme.acceptTerms = true;
  #security.acme.defaults.email = "email@mail.com";
  security.acme.certs."domain.com".email = "email@mail.com";


  system.copySystemConfiguration = true;


  system.stateVersion = "23.11"; 

}