24 cfg = config.services.crabfit;
28 options.services.crabfit = {
29 enable = mkEnableOption "Crab Fit, a meeting scheduler based on peoples' availability";
32 package = mkPackageOption pkgs "crabfit-frontend" { };
37 default = cfg.frontend.package.override {
38 api_url = "https://${cfg.api.host}";
39 frontend_url = cfg.frontend.host;
42 defaultText = literalExpression ''
43 cfg.package.override {
44 api_url = "https://''${cfg.api.host}";
45 frontend_url = cfg.frontend.host;
50 The patched frontend, using the correct urls for the API and frontend.
54 environment = mkOption {
58 Environment variables for the crabfit frontend.
65 The hostname of the frontend.
73 The internal listening port of the frontend.
79 package = mkPackageOption pkgs "crabfit-api" { };
81 environment = mkOption {
85 Environment variables for the crabfit API.
92 The hostname of the API.
100 The internal listening port of the API.
106 config = mkIf cfg.enable {
109 description = "The API for Crab Fit.";
111 wantedBy = [ "multi-user.target" ];
112 after = [ "postgresql.service" ];
116 ExecStart = lib.getExe cfg.api.package;
121 API_LISTEN = "127.0.0.1:${builtins.toString cfg.api.port}";
122 DATABASE_URL = "postgres:///crabfit?host=/run/postgresql";
123 FRONTEND_URL = "https://${cfg.frontend.host}";
124 } // cfg.api.environment;
128 description = "The frontend for Crab Fit.";
130 wantedBy = [ "multi-user.target" ];
134 CacheDirectory = "crabfit";
136 ExecStart = "${lib.getExe pkgs.nodejs} standalone/server.js";
137 WorkingDirectory = cfg.frontend.finalDrv;
141 NEXT_PUBLIC_API_URL = "https://${cfg.api.host}";
142 PORT = builtins.toString cfg.frontend.port;
143 } // cfg.frontend.environment;
148 groups.crabfit = { };
160 ensureDatabases = [ "crabfit" ];
165 ensureDBOwnership = true;