Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a pre- and post- hook for the process-compose wrapper #56

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions nix/process-compose/cli.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ in
default = true;
description = "Enable or disable process-compose's Swagger API.";
};
preHook = mkOption {
type = types.lines;
default = "";
description = "Shell commands to run before process-compose starts.";
};
port = mkOption {
type = types.int;
default = 0;
description = ''
Port to serve process-compose's Swagger API on.
'';
};
postHook = mkOption {
type = types.lines;
default = "";
description = "Shell commands to run after process-compose completes.";
};
tui = mkOption {
type = types.bool;
default = true;
Expand Down
13 changes: 9 additions & 4 deletions nix/process-compose/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ in

config.outputs =
let
mkProcessComposeWrapper = { name, tui, apiServer, port, configFile }:
mkProcessComposeWrapper = { name, tui, apiServer, port, configFile, preHook, postHook }:
pkgs.writeShellApplication {
inherit name;
runtimeInputs = [ config.package ];
Expand All @@ -50,7 +50,12 @@ in
if tui then "" else "export PC_DISABLE_TUI=true"
}
${if apiServer then "" else "export PC_NO_SERVER=true"}
exec process-compose -p ${toString port} "$@"

${preHook}

process-compose -p ${toString port} "$@"

${postHook}
'';
};
in
Expand All @@ -59,7 +64,7 @@ in
mkProcessComposeWrapper
{
inherit name;
inherit (config) tui apiServer port;
inherit (config) tui apiServer port preHook postHook;
configFile = config.outputs.settingsYaml;
};
testPackage =
Expand All @@ -69,7 +74,7 @@ in
mkProcessComposeWrapper
{
name = "${name}-test";
inherit (config) tui apiServer port;
inherit (config) tui apiServer port preHook postHook;
configFile = config.outputs.settingsTestYaml;
}
else null;
Expand Down