From e27024dc8abcefe2e79faa522d0fb33096199242 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sat, 23 Oct 2021 00:42:03 -0700 Subject: [PATCH] Try relax on derivation attribute to check for SSL --- module.nix | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/module.nix b/module.nix index d8b90db..40b9cf2 100644 --- a/module.nix +++ b/module.nix @@ -2,22 +2,22 @@ with lib; let cfg = config.services.danilafe-blog; - sslForDomain = domain: (cfg.ssl == true) || (cfg.ssl."${domain}" or false); - anySsl = any sslForDomain (attrNames cfg.domains); + sslForDomain = domain: package: package.ssl; + anySsl = any id (mapAttrsToList sslForDomain cfg.domains); virtualHost = domain: package: { virtualHosts."${domain}" = mkMerge [ { root = package; } - (mkIf (sslForDomain domain) { + (mkIf (sslForDomain domain package) { addSSL = true; enableACME = true; acmeRoot = cfg.challengePath; }) ]; }; - service = domain: + service = domain: package: { # Workaround for new configuration setting all of /var to be readonly. # See https://github.com/NixOS/nixpkgs/issues/139310 @@ -26,16 +26,11 @@ let }; }; virtualHosts = mapAttrsToList virtualHost cfg.domains; - services = map service (filter sslForDomain (attrNames cfg.domains)); + services = mapAttrsToList service (filterAttrs sslForDomain cfg.domains); in { options.services.danilafe-blog = { enable = mkEnableOption "Daniel's blog service"; - ssl = mkOption { - type = types.either types.bool (types.attrsOf types.bool); - default = false; - description = "Enable SSL and ACME for all or some domains."; - }; domains = mkOption { type = types.attrsOf types.package; default = {};