mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 23:43:30 +00:00
nixos/services/dolibarr: decouple nginx and let other web servers be used
This commit is contained in:
parent
3cf892d8ba
commit
b19612cb24
@ -1,11 +1,11 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
inherit (lib) any boolToString concatStringsSep isBool isString literalExpression mapAttrsToList mkDefault mkEnableOption mkIf mkOption optionalAttrs types;
|
||||
inherit (lib) any boolToString concatStringsSep isBool isString mapAttrsToList mkDefault mkEnableOption mkIf mkMerge mkOption optionalAttrs types;
|
||||
|
||||
package = pkgs.dolibarr.override { inherit (cfg) stateDir; };
|
||||
|
||||
cfg = config.services.dolibarr;
|
||||
vhostCfg = config.services.nginx.virtualHosts."${cfg.domain}";
|
||||
vhostCfg = lib.optionalAttr (cfg.nginx != null) config.services.nginx.virtualHosts."${cfg.domain}";
|
||||
|
||||
mkConfigFile = filename: settings:
|
||||
let
|
||||
@ -38,7 +38,7 @@ let
|
||||
force_install_database = cfg.database.name;
|
||||
force_install_databaselogin = cfg.database.user;
|
||||
|
||||
force_install_mainforcehttps = vhostCfg.forceSSL;
|
||||
force_install_mainforcehttps = vhostCfg.forceSSL or false;
|
||||
force_install_createuser = false;
|
||||
force_install_dolibarrlogin = null;
|
||||
} // optionalAttrs (cfg.database.passwordFile != null) {
|
||||
@ -183,7 +183,8 @@ in
|
||||
};
|
||||
|
||||
# implementation
|
||||
config = mkIf cfg.enable {
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
|
||||
assertions = [
|
||||
{ assertion = cfg.database.createLocally -> cfg.database.user == cfg.user;
|
||||
@ -214,7 +215,7 @@ in
|
||||
|
||||
# Security settings
|
||||
dolibarr_main_prod = true;
|
||||
dolibarr_main_force_https = vhostCfg.forceSSL;
|
||||
dolibarr_main_force_https = vhostCfg.forceSSL or false;
|
||||
dolibarr_main_restrict_os_commands = "${pkgs.mariadb}/bin/mysqldump, ${pkgs.mariadb}/bin/mysql";
|
||||
dolibarr_nocsrfcheck = false;
|
||||
dolibarr_main_instance_unique_id = ''
|
||||
@ -314,7 +315,9 @@ in
|
||||
users.groups = optionalAttrs (cfg.group == "dolibarr") {
|
||||
dolibarr = { };
|
||||
};
|
||||
|
||||
users.users."${config.services.nginx.group}".extraGroups = [ cfg.group ];
|
||||
};
|
||||
}
|
||||
(mkIf (cfg.nginx != null) {
|
||||
users.users."${config.services.nginx.group}".extraGroups = mkIf (cfg.nginx != null) [ cfg.group ];
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user