Unverified Commit 31dcccb0 authored by soyouzpanda's avatar soyouzpanda
Browse files

nixos/lasuite-meet: fix preStart script for backend

- Use Systemd bind mount instead of symlinking the static directory
- Perfom migrations after generating secret key

Thanks @networkException and @Ma27
parent 1e13373d
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ in
            type = types.str;
            default = if cfg.enableNginx then "localhost,127.0.0.1,${cfg.domain}" else "";
            defaultText = lib.literalExpression ''
              if cfg.enableNginx then "localhost,127.0.0.1,$${cfg.domain}" else ""
              if cfg.enableNginx then "localhost,127.0.0.1,''${cfg.domain}" else ""
            '';
            description = "Comma-separated list of hosts that are able to connect to the server";
          };
@@ -327,16 +327,10 @@ in
      wantedBy = [ "multi-user.target" ];

      preStart = ''
        ln -sfT ${cfg.backendPackage}/share/static /var/lib/lasuite-meet/static

        if [ ! -f .version ]; then
          touch .version
        fi

        if [ "${cfg.backendPackage.version}" != "$(cat .version)" ]; then
          ${getExe cfg.backendPackage} migrate
          echo -n "${cfg.backendPackage.version}" > .version
        fi
        ${optionalString (cfg.secretKeyPath == null) ''
          if [[ ! -f /var/lib/lasuite-meet/django_secret_key ]]; then
            (
@@ -345,11 +339,17 @@ in
            )
          fi
        ''}
        if [ "${cfg.backendPackage.version}" != "$(cat .version)" ]; then
          ${getExe cfg.backendPackage} migrate
          echo -n "${cfg.backendPackage.version}" > .version
        fi
      '';

      environment = pythonEnvironment;

      serviceConfig = {
        BindReadOnlyPaths = "${cfg.backendPackage}/share/static:/var/lib/lasuite-meet/static";

        ExecStart = utils.escapeSystemdExecArgs (
          [
            (lib.getExe' cfg.backendPackage "gunicorn")