Hey!
I am trying to factor a bit a configuration for NixOps. Here is my current take:
{ config, pkgs, lib, nodes, ... }:
vhost = name: attrs: {
# Virtualhost definition
services.nginx = {
virtualHosts."${name}" = {
root = "/data/webserver/${name}";
enableACME = true;
forceSSL = true;
} // attrs;
};
# Let's encrypt extra configuration
security.acme = {
certs."${name}" = {
email = "letsencrypt@me";
};
};
};
in
{
services.nginx = {
enable = true;
[...]
};
} // vhost "web.example.com" {
extraConfig = 'expires 1h;';
}
With this, I get an error like that:
error: The option `security.acme.certs.web.example.com.webroot' is used but not defined.
I can fix the error by adding services.nginx.enable = true
in the vhost
function. But in this case, the whole config in the first block is ignored. From my understanding, I don’t correctly extend the first attribute set with the second one. The whole services.nginx
definition is replaced by the one in the vhost
function. What is the proper way to factor configuration? I’ve also tried to use mkMerge
, but it seems to be not different.