X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fprivate%2Fhttpd-service-builder.nix;fp=nixops%2Fmodules%2Fwebsites%2Fapache%2Fhttpd_tools.nix;h=0f0fe2244564ecdb97e4ed83271b36096360565a;hb=581c499c06bcc834e084c49f284e18611fbc139b;hp=c48d0d2f45348772be29162ea35a60b97fa9cb21;hpb=8f904d0d982684e8e66dfc5d9123712eb96bf16e;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/nixops/modules/websites/apache/httpd_tools.nix b/modules/private/httpd-service-builder.nix similarity index 97% rename from nixops/modules/websites/apache/httpd_tools.nix rename to modules/private/httpd-service-builder.nix index c48d0d2..0f0fe22 100644 --- a/nixops/modules/websites/apache/httpd_tools.nix +++ b/modules/private/httpd-service-builder.nix @@ -1,10 +1,13 @@ +# to help backporting this builder should stay as close as possible to +# nixos/modules/services/web-servers/apache-httpd/default.nix +{ httpdName, withUsers ? true }: { config, lib, pkgs, ... }: with lib; let - mainCfg = config.services.httpdTools; + mainCfg = config.services."httpd${httpdName}"; httpd = mainCfg.package.out; @@ -435,7 +438,7 @@ in options = { - services.httpdTools = { + services."httpd${httpdName}" = { enable = mkOption { type = types.bool; @@ -642,7 +645,7 @@ in } # Include the options shared between the main server and virtual hosts. - // (import ./per-server-options.nix { + // (import { inherit lib; forMainServer = true; }); @@ -652,7 +655,7 @@ in ###### implementation - config = mkIf config.services.httpdTools.enable { + config = mkIf config.services."httpd${httpdName}".enable { assertions = [ { assertion = mainCfg.enableSSL == true -> mainCfg.sslServerCert != null @@ -662,21 +665,21 @@ in warnings = map (cfg: ''apache-httpd's port option is deprecated. Use listen = [{/*ip = "*"; */ port = ${toString cfg.port};}]; instead'' ) (lib.filter (cfg: cfg.port != 0) allHosts); - users.users = optionalAttrs (mainCfg.user == "wwwrun") (singleton + users.users = optionalAttrs (withUsers && mainCfg.user == "wwwrun") (singleton { name = "wwwrun"; group = mainCfg.group; description = "Apache httpd user"; uid = config.ids.uids.wwwrun; }); - users.groups = optionalAttrs (mainCfg.group == "wwwrun") (singleton + users.groups = optionalAttrs (withUsers && mainCfg.group == "wwwrun") (singleton { name = "wwwrun"; gid = config.ids.gids.wwwrun; }); environment.systemPackages = [httpd] ++ concatMap (svc: svc.extraPath) allSubservices; - services.httpdTools.phpOptions = + services."httpd${httpdName}".phpOptions = '' ; Needed for PHP's mail() function. sendmail_path = sendmail -t -i @@ -689,7 +692,7 @@ in date.timezone = "${config.time.timeZone}" ''; - systemd.services.httpdTools = + systemd.services."httpd${httpdName}" = { description = "Apache HTTPD"; wantedBy = [ "multi-user.target" ];