Commit 5ae2b275 authored by happysalada's avatar happysalada Committed by Yt
Browse files

nixos/surrealdb: incorporate beta 10 changes

parent 3d8c6b5b
Loading
Loading
Loading
Loading
+7 −22
Original line number Diff line number Diff line
@@ -47,17 +47,13 @@ in {
        example = 8000;
      };

      userNamePath = mkOption {
        type = types.path;
      extraFlags = mkOption {
        type = types.listOf types.str;
        default = [];
        example = [ "--allow-all" "--auth" "--user root" "--pass root" ];
        description = lib.mdDoc ''
          Path to read the username from.
        '';
      };

      passwordPath = mkOption {
        type = types.path;
        description = lib.mdDoc ''
          Path to read the password from.
          Specify a list of additional command line flags,
          which get escaped and are then passed to surrealdb.
        '';
      };
    };
@@ -73,19 +69,8 @@ in {
      wantedBy = [ "multi-user.target" ];
      after = [ "network.target" ];

      script = ''
        ${cfg.package}/bin/surreal start \
          --user $(${pkgs.systemd}/bin/systemd-creds cat SURREALDB_USERNAME) \
          --pass $(${pkgs.systemd}/bin/systemd-creds cat SURREALDB_PASSWORD) \
          --bind ${cfg.host}:${toString cfg.port} \
          -- ${cfg.dbPath}
      '';
      serviceConfig = {
        LoadCredential = [
          "SURREALDB_USERNAME:${cfg.userNamePath}"
          "SURREALDB_PASSWORD:${cfg.passwordPath}"
        ];

        ExecStart = "${cfg.package}/bin/surreal start --bind ${cfg.host}:${toString cfg.port} ${escapeShellArgs cfg.extraFlags} -- ${cfg.dbPath}";
        DynamicUser = true;
        Restart = "on-failure";
        StateDirectory = "surrealdb";