forked from mirrors/nixpkgs
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
123 lines
3 KiB
Nix
123 lines
3 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.odoo;
|
|
format = pkgs.formats.ini {};
|
|
in
|
|
{
|
|
options = {
|
|
services.odoo = {
|
|
enable = mkEnableOption "odoo";
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.odoo;
|
|
defaultText = literalExpression "pkgs.odoo";
|
|
description = lib.mdDoc "Odoo package to use.";
|
|
};
|
|
|
|
addons = mkOption {
|
|
type = with types; listOf package;
|
|
default = [];
|
|
example = literalExpression "[ pkgs.odoo_enterprise ]";
|
|
description = lib.mdDoc "Odoo addons.";
|
|
};
|
|
|
|
settings = mkOption {
|
|
type = format.type;
|
|
default = {};
|
|
description = lib.mdDoc ''
|
|
Odoo configuration settings. For more details see <https://www.odoo.com/documentation/15.0/administration/install/deploy.html>
|
|
'';
|
|
};
|
|
|
|
domain = mkOption {
|
|
type = with types; nullOr str;
|
|
description = lib.mdDoc "Domain to host Odoo with nginx";
|
|
default = null;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf (cfg.enable) (let
|
|
cfgFile = format.generate "odoo.cfg" cfg.settings;
|
|
in {
|
|
services.nginx = mkIf (cfg.domain != null) {
|
|
upstreams = {
|
|
odoo.servers = {
|
|
"127.0.0.1:8069" = {};
|
|
};
|
|
|
|
odoochat.servers = {
|
|
"127.0.0.1:8072" = {};
|
|
};
|
|
};
|
|
|
|
virtualHosts."${cfg.domain}" = {
|
|
extraConfig = ''
|
|
proxy_read_timeout 720s;
|
|
proxy_connect_timeout 720s;
|
|
proxy_send_timeout 720s;
|
|
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
'';
|
|
|
|
locations = {
|
|
"/longpolling" = {
|
|
proxyPass = "http://odoochat";
|
|
};
|
|
|
|
"/" = {
|
|
proxyPass = "http://odoo";
|
|
extraConfig = ''
|
|
proxy_redirect off;
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
services.odoo.settings.options = {
|
|
proxy_mode = cfg.domain != null;
|
|
};
|
|
|
|
users.users.odoo = {
|
|
isSystemUser = true;
|
|
group = "odoo";
|
|
};
|
|
users.groups.odoo = {};
|
|
|
|
systemd.services.odoo = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" "postgresql.service" ];
|
|
|
|
# pg_dump
|
|
path = [ config.services.postgresql.package ];
|
|
|
|
requires = [ "postgresql.service" ];
|
|
script = "HOME=$STATE_DIRECTORY ${cfg.package}/bin/odoo ${optionalString (cfg.addons != []) "--addons-path=${concatMapStringsSep "," escapeShellArg cfg.addons}"} -c ${cfgFile}";
|
|
|
|
serviceConfig = {
|
|
DynamicUser = true;
|
|
User = "odoo";
|
|
StateDirectory = "odoo";
|
|
};
|
|
};
|
|
|
|
services.postgresql = {
|
|
enable = true;
|
|
|
|
ensureUsers = [{
|
|
name = "odoo";
|
|
ensurePermissions = { "DATABASE odoo" = "ALL PRIVILEGES"; };
|
|
}];
|
|
ensureDatabases = [ "odoo" ];
|
|
};
|
|
});
|
|
}
|