diff --git a/flake.nix b/flake.nix index 25b34be..8171bd1 100644 --- a/flake.nix +++ b/flake.nix @@ -69,6 +69,18 @@ description = "The phoenix package containing the application"; }; + secret_key_file = mkOption { + type = types.string; + example = "/var/lib/skey"; + description = "The Secrert key for Phoenix"; + }; + + dbUrl = mkOption { + type = types.string; + default = "postgresql://${config.services.postgres.user}:${config.services.postgres.password}@${config.services.postgres.host}:${toString config.services.postgres.port}/zoeyscomputer_prod"; + description = "Postgres Databaase URL"; + }; + enableServer = mkOption rec { type = types.bool; default = true; @@ -105,6 +117,7 @@ PORT = "${toString cfg.phx.port}"; PHX_HOST = cfg.domain; PHX_SERVER = toString cfg.phx.enableServer; + DATABASE_URL = cfg.phx.dbUrl; }; serviceConfig = { Type = "exec"; @@ -113,6 +126,7 @@ # Implied by DynamicUser, but just to emphasize due to RELEASE_TMP PrivateTmp = true; ExecStart = pkgs.writeShellScript "start-zoeycomputer" '' + export SECRET_KEY_BASE=$(cat ${cfg.phx.secret_key_file}) ${cfg.phx.package}/bin/${release_name} eval "ZoeysComputer.Release.migrate" ${cfg.phx.package}/bin/${release_name} start ''; @@ -128,7 +142,7 @@ StartLimitInterval = 10; }; # disksup requires bash - path = [pkgs.bash]; + path = [pkgs.bash pkgs.coreutils]; }; }; };