mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-14 17:50:13 +00:00
build(nix): use nix develop in process scripts instead of repeating inputs in runtimeInputs
This commit is contained in:
parent
7496ae1c45
commit
b29c51f103
1 changed files with 16 additions and 29 deletions
45
flake.nix
45
flake.nix
|
|
@ -162,30 +162,20 @@
|
||||||
let
|
let
|
||||||
procCfg = composeCfg.settings.processes;
|
procCfg = composeCfg.settings.processes;
|
||||||
mkServiceProcess =
|
mkServiceProcess =
|
||||||
name:
|
name: attrs:
|
||||||
{
|
|
||||||
inputs ? [ ],
|
|
||||||
...
|
|
||||||
}@attrs:
|
|
||||||
let
|
let
|
||||||
shell = rustOutputs.${name}.devShell;
|
shell = rustOutputs.${name}.devShell;
|
||||||
filteredAttrs = lib.removeAttrs attrs ["inputs"];
|
|
||||||
in
|
in
|
||||||
filteredAttrs // {
|
attrs
|
||||||
|
// {
|
||||||
command = pkgs.writeShellApplication {
|
command = pkgs.writeShellApplication {
|
||||||
name = "pluralkit-${name}";
|
name = "pluralkit-${name}";
|
||||||
runtimeInputs =
|
runtimeInputs = [ pkgs.coreutils ];
|
||||||
(with pkgs; [
|
|
||||||
coreutils
|
|
||||||
shell.stdenv.cc
|
|
||||||
])
|
|
||||||
++ shell.nativeBuildInputs
|
|
||||||
++ inputs;
|
|
||||||
text = ''
|
text = ''
|
||||||
${sourceDotenv}
|
${sourceDotenv}
|
||||||
set -x
|
set -x
|
||||||
${pluralkitConfCheck}
|
${pluralkitConfCheck}
|
||||||
exec cargo run --package ${name}
|
nix develop .#services -c cargo run --package ${name}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -195,38 +185,35 @@
|
||||||
pluralkit-bot = {
|
pluralkit-bot = {
|
||||||
command = pkgs.writeShellApplication {
|
command = pkgs.writeShellApplication {
|
||||||
name = "pluralkit-bot";
|
name = "pluralkit-bot";
|
||||||
runtimeInputs = self'.devShells.bot.nativeBuildInputs ++ [
|
runtimeInputs = [ pkgs.coreutils ];
|
||||||
pkgs.coreutils
|
|
||||||
pkgs.git
|
|
||||||
self'.devShells.bot.stdenv.cc
|
|
||||||
];
|
|
||||||
text = ''
|
text = ''
|
||||||
${sourceDotenv}
|
${sourceDotenv}
|
||||||
set -x
|
set -x
|
||||||
${pluralkitConfCheck}
|
${pluralkitConfCheck}
|
||||||
${self'.apps.generate-command-parser-bindings.program}
|
${self'.apps.generate-command-parser-bindings.program}
|
||||||
dotnet build ./PluralKit.Bot/PluralKit.Bot.csproj -c Release -o obj/
|
nix develop .#bot -c bash -c "dotnet build ./PluralKit.Bot/PluralKit.Bot.csproj -c Release -o obj/ && dotnet obj/PluralKit.Bot.dll"
|
||||||
exec dotnet obj/PluralKit.Bot.dll
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
depends_on.postgres.condition = "process_healthy";
|
depends_on.postgres.condition = "process_healthy";
|
||||||
depends_on.redis.condition = "process_healthy";
|
depends_on.redis.condition = "process_healthy";
|
||||||
depends_on.pluralkit-gateway.condition = "process_healthy";
|
depends_on.pluralkit-gateway.condition = "process_log_ready";
|
||||||
# TODO: add liveness check
|
# TODO: add liveness check
|
||||||
ready_log_line = "Received Ready";
|
ready_log_line = "Received Ready";
|
||||||
|
availability.restart = "on_failure";
|
||||||
|
availability.max_restarts = 3;
|
||||||
};
|
};
|
||||||
### gateway ###
|
### gateway ###
|
||||||
pluralkit-gateway = mkServiceProcess "gateway" {
|
pluralkit-gateway = mkServiceProcess "gateway" {
|
||||||
inputs = with pkgs; [curl gnugrep];
|
|
||||||
depends_on.postgres.condition = "process_healthy";
|
depends_on.postgres.condition = "process_healthy";
|
||||||
depends_on.redis.condition = "process_healthy";
|
depends_on.redis.condition = "process_healthy";
|
||||||
# configure health checks
|
# configure health checks
|
||||||
# TODO: don't assume port?
|
# TODO: don't assume port?
|
||||||
liveness_probe.exec.command = ''curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/stats | grep "302"'';
|
liveness_probe.exec.command = ''${pkgs.curl}/bin/curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/stats | ${pkgs.busybox}/bin/grep "302"'';
|
||||||
liveness_probe.period_seconds = 5;
|
liveness_probe.period_seconds = 7;
|
||||||
readiness_probe.exec.command = procCfg.pluralkit-gateway.liveness_probe.exec.command;
|
# TODO: add actual listening or running line in gateway
|
||||||
readiness_probe.period_seconds = 5;
|
ready_log_line = "Running ";
|
||||||
readiness_probe.initial_delay_seconds = 3;
|
availability.restart = "on_failure";
|
||||||
|
availability.max_restarts = 3;
|
||||||
};
|
};
|
||||||
# TODO: add the rest of the services
|
# TODO: add the rest of the services
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue