diff --git a/nixos/modules/services/web-apps/davis.md b/nixos/modules/services/web-apps/davis.md index 9775d8221b5b..d654f2fd7f43 100644 --- a/nixos/modules/services/web-apps/davis.md +++ b/nixos/modules/services/web-apps/davis.md @@ -24,9 +24,10 @@ After that, `davis` can be deployed like this: adminLogin = "admin"; adminPasswordFile = "/run/secrets/davis-admin-password"; appSecretFile = "/run/secrets/davis-app-secret"; - nginx = {}; }; } ``` This deploys Davis using a sqlite database running out of `/var/lib/davis`. + +Logs can be found in `/var/lib/davis/var/log/`. diff --git a/nixos/modules/services/web-apps/davis.nix b/nixos/modules/services/web-apps/davis.nix index 444f8fc2cd20..23a28ed84fd3 100644 --- a/nixos/modules/services/web-apps/davis.nix +++ b/nixos/modules/services/web-apps/davis.nix @@ -220,10 +220,13 @@ in }; nginx = lib.mkOption { - type = lib.types.submodule ( - lib.recursiveUpdate (import ../web-servers/nginx/vhost-options.nix { inherit config lib; }) { } + type = lib.types.nullOr ( + lib.types.submodule ( + lib.recursiveUpdate (import ../web-servers/nginx/vhost-options.nix { inherit config lib; }) { + } + ) ); - default = null; + default = { }; example = '' { serverAliases = [ @@ -235,7 +238,7 @@ in } ''; description = '' - With this option, you can customize the nginx virtualHost settings. + Use this option to customize an nginx virtual host. To disable the nginx set this to null. ''; }; @@ -308,18 +311,16 @@ in message = "One of services.davis.database.urlFile or services.davis.database.createLocally must be set."; } { - assertion = (mail.dsn != null) != (mail.dsnFile != null); - message = "One of (and only one of) services.davis.mail.dsn or services.davis.mail.dsnFile must be set."; + assertion = !(mail.dsn != null && mail.dsnFile != null); + message = "services.davis.mail.dsn and services.davis.mail.dsnFile cannot both be set."; } ]; services.davis.config = { APP_ENV = "prod"; APP_CACHE_DIR = "${cfg.dataDir}/var/cache"; - # note: we do not need the log dir (we log to stdout/journald), by davis/symfony will try to create it, and the default value is one in the nix-store - # so we set it to a path under dataDir to avoid something like: Unable to create the "logs" directory (/nix/store/5cfskz0ybbx37s1161gjn5klwb5si1zg-davis-4.4.1/var/log). APP_LOG_DIR = "${cfg.dataDir}/var/log"; - LOG_FILE_PATH = "/dev/stdout"; + LOG_FILE_PATH = "%kernel.logs_dir%/%kernel.environment%.log"; DATABASE_DRIVER = db.driver; INVITE_FROM_ADDRESS = mail.inviteFromAddress; APP_SECRET._secret = cfg.appSecretFile; @@ -330,7 +331,14 @@ in CALDAV_ENABLED = true; CARDDAV_ENABLED = true; } - // (if mail.dsn != null then { MAILER_DSN = mail.dsn; } else { MAILER_DSN._secret = mail.dsnFile; }) + // ( + if mail.dsn != null then + { MAILER_DSN = mail.dsn; } + else if mail.dsnFile != null then + { MAILER_DSN._secret = mail.dsnFile; } + else + { } + ) // ( if db.createLocally then { diff --git a/nixos/tests/davis.nix b/nixos/tests/davis.nix index 480191704e2c..0dfa08342801 100644 --- a/nixos/tests/davis.nix +++ b/nixos/tests/davis.nix @@ -1,10 +1,14 @@ -{ pkgs, ... }: +{ + pkgs, + config, + ... +}: { name = "davis"; meta.maintainers = pkgs.davis.meta.maintainers; - nodes.machine = + nodes.machine1 = { config, ... }: { virtualisation = { @@ -24,33 +28,67 @@ adminLogin = "admin"; appSecretFile = "${pkgs.writeText "davisAppSecret" "52882ef142066e09ab99ce816ba72522e789505caba224"}"; adminPasswordFile = "${pkgs.writeText "davisAdminPass" "nixos"}"; - nginx = { }; + }; + }; + nodes.machine2 = + { nodes, config, ... }: + { + virtualisation = { + memorySize = 512; + }; + environment.systemPackages = [ pkgs.fcgi ]; + + # no nginx, and no mail dsn + services.davis = { + enable = true; + hostname = "davis.example.com"; + database = { + driver = "postgresql"; + }; + adminLogin = "admin"; + appSecretFile = "${pkgs.writeText "davisAppSecret" "52882ef142066e09ab99ce816ba72522e789505caba224"}"; + adminPasswordFile = "${pkgs.writeText "davisAdminPass" "nixos"}"; + nginx = null; }; }; testScript = '' start_all() - machine.wait_for_unit("postgresql.service") - machine.wait_for_unit("davis-env-setup.service") - machine.wait_for_unit("davis-db-migrate.service") - machine.wait_for_unit("nginx.service") - machine.wait_for_unit("phpfpm-davis.service") + + machine1.wait_for_unit("postgresql.service") + machine1.wait_for_unit("davis-env-setup.service") + machine1.wait_for_unit("davis-db-migrate.service") + machine1.wait_for_unit("phpfpm-davis.service") with subtest("welcome screen loads"): - machine.succeed( + machine1.succeed( "curl -sSfL --resolve davis.example.com:80:127.0.0.1 http://davis.example.com/ | grep '