Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
72 changes: 70 additions & 2 deletions nix/process-compose/cli.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,81 @@ in
};
environment = mkOption {
default = { };
description = "Environment variables to pass to process-compose binary.";
description = ''
Environment variables to pass to process-compose binary.
Note that flags directly configured via cli.options will override these values.
'';
type = types.submodule {
options = {
PC_DISABLE_TUI = mkOption {
type = types.nullOr types.bool;
default = null;
description = "Disable the TUI (Text User Interface) of process-compose";
description = "disable the TUI (Text User Interface) of process-compose";
};
PC_PORT_NUM = mkOption {
type = types.nullOr types.int;
default = null;
description = "port number on which to bind process-compose listener";
};
PC_CONFIG_FILES = mkOption {
type = types.nullOr types.str;
default = null;
description = "comma-separated list of path to config files to load";
};
PC_SHORTCUTS_FILES = mkOption {
type = types.nullOr types.str;
default = null;
description = "comma-separated list of paths to shortcut config files to load";
};
PC_NO_SERVER = mkOption {
type = types.nullOr types.bool;
default = null;
description = "disable HTTP server";
};
PC_SOCKET_PATH = mkOption {
type = types.nullOr types.str;
default = null;
description = "path to unix socket";
};
PC_READ_ONLY = mkOption {
type = types.nullOr types.bool;
default = null;
description = "enable read-only mode";
};
PC_DISABLE_DOTENV = mkOption {
type = types.nullOr types.bool;
default = null;
description = "disable .env file loading";
};
PC_TUI_FULL_SCREEN = mkOption {
type = types.nullOr types.bool;
default = null;
description = "enable TUI full screen";
};
PC_HIDE_DISABLED_PROC = mkOption {
type = types.nullOr types.bool;
default = null;
description = "hide disabled processes";
};
PC_ORDERED_SHUTDOWN = mkOption {
type = types.nullOr types.bool;
default = null;
description = "shut down processes in reverse dependency order";
};
PC_RECURSIVE_METRICS = mkOption {
type = types.nullOr types.bool;
default = null;
description = "collect metrics recursively";
};
PC_DISABLED_PROCESSES = mkOption {
type = types.nullOr types.str;
default = null;
description = "comma-separated list of process to initially disable";
};
PC_LOG_FILE = mkOption {
type = types.nullOr types.str;
default = null;
description = "specify the log file path";
};
};
};
Expand Down
64 changes: 63 additions & 1 deletion nix/process-compose/settings/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ in
File to write the logs to.
'';
};

log_configuration = mkOption {
type = types.nullOr (types.submoduleWith {
specialArgs = { inherit lib; };
modules = [ ./log-config.nix ];
});
default = null;
description = ''
The default settings for global logging.
'';
};
shell = {
shell_argument = mkOption {
type = types.str;
Expand Down Expand Up @@ -87,6 +96,59 @@ in
Version of the process-compose configuration.
'';
};

vars = import ./vars.nix { inherit lib; };

disable_env_expansion = mkOption {
type = types.nullOr types.bool;
default = true;
example = false;
description = ''
Globally disables automatic \$ variable expansion.
Enabled by default, unlike upstream process-compose.
'';
};

ordered_shutdown = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
description = ''
Causes processes to shut down in reverse dependency order.
'';
};

env_cmds = mkOption {
type = types.nullOr (types.attrsOf types.str);
default = null;
example = {
UPTIME = "uptime -p";
OS_NAME = "awk -F = '/PRETTY/ {print $2}' /etc/os-release";
};
description = ''
Dynamically populate environment variables by executing commands before starting processes.
'';
};

is_strict = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
description = ''
Enables additional checks on YAML configuration correctness.
'';
};

extends = mkOption {
type = types.nullOr types.path;
default = null;
example = "process-compose.base.yaml";
description = ''
Make the current configuration inherit all values in the given file.

See https://f1bonacc1.github.io/process-compose/merge#configuration-inheritance-with-extends
'';
};
};
}];
};
Expand Down
122 changes: 122 additions & 0 deletions nix/process-compose/settings/log-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{ name, lib, ... }:

let
inherit (lib) types mkOption;
inherit (types) nullOr listOf str enum bool;
in
{
options = {
rotation = mkOption {
type = types.submodule {
options = {
max_size_mb = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 1;
description = ''
Maximum size in MB of the logfile before it's rolled.
'';
};
max_backups = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 3;
description = ''
Maximum number of rolled logfiles to keep.
'';
};
max_age_days = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 7;
description = ''
Maximum age in days to keep a rolled logfile.
'';
};
compress = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
description = ''
If enabled, compress rolled logfiles with gzip.
'';
};
};
};
default = { };
description = ''
Settings related to process log rotation.
'';
};

fields_order = mkOption {
type = nullOr (listOf (enum [
"time"
"level"
"message"
# technically arbitrary, but these are defined in config.
])
);
default = null;
example = [
"time"
"level"
"message"
];
description = ''
Order of logging fields. The default is time, level, message
'';
};
disable_json = mkOption {
type = nullOr bool;
default = null;
example = false;
description = ''
If enabled, output as plain text rather than json.
'';
};
timestamp_format = mkOption {
type = nullOr str;
default = null;
example = "2006-01-02T15:04:05.000Z";
description = ''
Timestamp format, per Go's time.Parse function.
Requires `add_timestamp` be enabled to be effective.

See https://pkg.go.dev/time#pkg-constants for examples.
'';
};
no_color = mkOption {
type = nullOr bool;
default = null;
example = false;
description = ''
Enabling `no_color` prevents the use of ANSI colors in the logger.
'';
};
no_metadata = mkOption {
type = nullOr bool;
default = null;
example = true;
description = ''
If enabled, do not add process name and replica number to logs.
'';
};
add_timestamp = mkOption {
type = nullOr bool;
default = null;
example = true;
description = ''
If enabled, prepends a timestamp to log entries.
'';
};
flush_each_line = mkOption {
type = nullOr bool;
default = null;
example = true;
description = ''
If enabled, disables output buffering and flushes each line to the logfile immediately.
'';
};
};
}
23 changes: 23 additions & 0 deletions nix/process-compose/settings/probe.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ in
Which port to probe the process on.
'';
};
headers = mkOption {
type = types.nullOr (types.attrsOf types.str);
default = null;
example = { "x-foo" = "bar"; };
description = ''
Additional headers to set on an HTTP probe
'';
};
status_code = mkOption {
type = types.nullOr types.int;
default = null;
example = 200;
description = ''
Expected status code.
'';
};
};
});
default = null;
Expand All @@ -62,6 +78,13 @@ in
The command to execute in order to check the health of the process.
'';
};
options.working_dir = mkOption {
type = types.str;
example = "./directory";
description = ''
Directory in which to execute the exec probe command.
'';
};
});
default = null;
description = ''
Expand Down
Loading