+# 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;
options = {
- services.httpdTools = {
+ services."httpd${httpdName}" = {
enable = mkOption {
type = types.bool;
}
# Include the options shared between the main server and virtual hosts.
- // (import ./per-server-options.nix {
+ // (import <nixpkgs/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix> {
inherit lib;
forMainServer = true;
});
###### implementation
- config = mkIf config.services.httpdTools.enable {
+ config = mkIf config.services."httpd${httpdName}".enable {
assertions = [ { assertion = mainCfg.enableSSL == true
-> mainCfg.sslServerCert != null
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
date.timezone = "${config.time.timeZone}"
'';
- systemd.services.httpdTools =
+ systemd.services."httpd${httpdName}" =
{ description = "Apache HTTPD";
wantedBy = [ "multi-user.target" ];