1 { config, pkgs, lib, ... }:
6 cfg = config.services.odoo;
7 format = pkgs.formats.ini {};
12 enable = mkEnableOption (lib.mdDoc "odoo");
17 defaultText = literalExpression "pkgs.odoo";
18 description = lib.mdDoc "Odoo package to use.";
22 type = with types; listOf package;
24 example = literalExpression "[ pkgs.odoo_enterprise ]";
25 description = lib.mdDoc "Odoo addons.";
31 description = lib.mdDoc ''
32 Odoo configuration settings. For more details see <https://www.odoo.com/documentation/15.0/administration/install/deploy.html>
34 example = literalExpression ''
43 type = with types; nullOr str;
44 description = lib.mdDoc "Domain to host Odoo with nginx";
50 config = mkIf (cfg.enable) (let
51 cfgFile = format.generate "odoo.cfg" cfg.settings;
53 services.nginx = mkIf (cfg.domain != null) {
56 "127.0.0.1:8069" = {};
60 "127.0.0.1:8072" = {};
64 virtualHosts."${cfg.domain}" = {
66 proxy_read_timeout 720s;
67 proxy_connect_timeout 720s;
68 proxy_send_timeout 720s;
70 proxy_set_header X-Forwarded-Host $host;
71 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
72 proxy_set_header X-Forwarded-Proto $scheme;
73 proxy_set_header X-Real-IP $remote_addr;
78 proxyPass = "http://odoochat";
82 proxyPass = "http://odoo";
91 services.odoo.settings.options = {
92 proxy_mode = cfg.domain != null;
99 users.groups.odoo = {};
101 systemd.services.odoo = {
102 wantedBy = [ "multi-user.target" ];
103 after = [ "network.target" "postgresql.service" ];
106 path = [ config.services.postgresql.package ];
108 requires = [ "postgresql.service" ];
109 script = "HOME=$STATE_DIRECTORY ${cfg.package}/bin/odoo ${optionalString (cfg.addons != []) "--addons-path=${concatMapStringsSep "," escapeShellArg cfg.addons}"} -c ${cfgFile}";
114 StateDirectory = "odoo";
118 services.postgresql = {
121 ensureDatabases = [ "odoo" ];
124 ensureDBOwnership = true;