Skip to content

Commit 3b0318d

Browse files
authored
Add all known outstanding yaml config options as of process-compose v1.7.3 (#98)
* Add all known outstanding yaml config options as of process-compose v1.7.3 - per-process `description` that displays in the UI - global and per-process `log_configuration`, including `rotation` - global and per-process `vars` for supporting Go template expansion on configs - `env_cmds` allows running host commands to populate env variables - `ordered_shutdown` controls the order of process shutdown - `is_strict` does additional checking on configuration files at startup - `disable_env_expansion` to not propagate .env variables to processes - `http_get.{headers,status_code}` and `working_dir` for probe commands - `replicas` to run multiple copies of processes - `entrypoint` alternate to `command` - `is_elevated` for sudo/runas priviledged processes - `extends,is_disabled,is_dotenv_disabled` for multi-file fragments and overrides. - `launch_timeout_seconds` for daemon processes * new: add additional PC_ env variables - Make disable-dotenv default to true, per @adrian-gierakowski request. - Remove unnecessary args in vars.nix * fix: import of vars.nix needs no extra args now
1 parent 2ed89a2 commit 3b0318d

File tree

6 files changed

+397
-3
lines changed

6 files changed

+397
-3
lines changed

nix/process-compose/cli.nix

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,81 @@ in
1717
};
1818
environment = mkOption {
1919
default = { };
20-
description = "Environment variables to pass to process-compose binary.";
20+
description = ''
21+
Environment variables to pass to process-compose binary.
22+
Note that flags directly configured via cli.options will override these values.
23+
'';
2124
type = types.submodule {
2225
options = {
2326
PC_DISABLE_TUI = mkOption {
2427
type = types.nullOr types.bool;
2528
default = null;
26-
description = "Disable the TUI (Text User Interface) of process-compose";
29+
description = "disable the TUI (Text User Interface) of process-compose";
30+
};
31+
PC_PORT_NUM = mkOption {
32+
type = types.nullOr types.int;
33+
default = null;
34+
description = "port number on which to bind process-compose listener";
35+
};
36+
PC_CONFIG_FILES = mkOption {
37+
type = types.nullOr types.str;
38+
default = null;
39+
description = "comma-separated list of path to config files to load";
40+
};
41+
PC_SHORTCUTS_FILES = mkOption {
42+
type = types.nullOr types.str;
43+
default = null;
44+
description = "comma-separated list of paths to shortcut config files to load";
45+
};
46+
PC_NO_SERVER = mkOption {
47+
type = types.nullOr types.bool;
48+
default = null;
49+
description = "disable HTTP server";
50+
};
51+
PC_SOCKET_PATH = mkOption {
52+
type = types.nullOr types.str;
53+
default = null;
54+
description = "path to unix socket";
55+
};
56+
PC_READ_ONLY = mkOption {
57+
type = types.nullOr types.bool;
58+
default = null;
59+
description = "enable read-only mode";
60+
};
61+
PC_DISABLE_DOTENV = mkOption {
62+
type = types.nullOr types.bool;
63+
default = null;
64+
description = "disable .env file loading";
65+
};
66+
PC_TUI_FULL_SCREEN = mkOption {
67+
type = types.nullOr types.bool;
68+
default = null;
69+
description = "enable TUI full screen";
70+
};
71+
PC_HIDE_DISABLED_PROC = mkOption {
72+
type = types.nullOr types.bool;
73+
default = null;
74+
description = "hide disabled processes";
75+
};
76+
PC_ORDERED_SHUTDOWN = mkOption {
77+
type = types.nullOr types.bool;
78+
default = null;
79+
description = "shut down processes in reverse dependency order";
80+
};
81+
PC_RECURSIVE_METRICS = mkOption {
82+
type = types.nullOr types.bool;
83+
default = null;
84+
description = "collect metrics recursively";
85+
};
86+
PC_DISABLED_PROCESSES = mkOption {
87+
type = types.nullOr types.str;
88+
default = null;
89+
description = "comma-separated list of process to initially disable";
90+
};
91+
PC_LOG_FILE = mkOption {
92+
type = types.nullOr types.str;
93+
default = null;
94+
description = "specify the log file path";
2795
};
2896
};
2997
};

nix/process-compose/settings/default.nix

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,16 @@ in
5656
File to write the logs to.
5757
'';
5858
};
59-
59+
log_configuration = mkOption {
60+
type = types.nullOr (types.submoduleWith {
61+
specialArgs = { inherit lib; };
62+
modules = [ ./log-config.nix ];
63+
});
64+
default = null;
65+
description = ''
66+
The default settings for global logging.
67+
'';
68+
};
6069
shell = {
6170
shell_argument = mkOption {
6271
type = types.str;
@@ -87,6 +96,59 @@ in
8796
Version of the process-compose configuration.
8897
'';
8998
};
99+
100+
vars = import ./vars.nix { inherit lib; };
101+
102+
disable_env_expansion = mkOption {
103+
type = types.nullOr types.bool;
104+
default = true;
105+
example = false;
106+
description = ''
107+
Globally disables automatic \$ variable expansion.
108+
Enabled by default, unlike upstream process-compose.
109+
'';
110+
};
111+
112+
ordered_shutdown = mkOption {
113+
type = types.nullOr types.bool;
114+
default = null;
115+
example = true;
116+
description = ''
117+
Causes processes to shut down in reverse dependency order.
118+
'';
119+
};
120+
121+
env_cmds = mkOption {
122+
type = types.nullOr (types.attrsOf types.str);
123+
default = null;
124+
example = {
125+
UPTIME = "uptime -p";
126+
OS_NAME = "awk -F = '/PRETTY/ {print $2}' /etc/os-release";
127+
};
128+
description = ''
129+
Dynamically populate environment variables by executing commands before starting processes.
130+
'';
131+
};
132+
133+
is_strict = mkOption {
134+
type = types.nullOr types.bool;
135+
default = null;
136+
example = true;
137+
description = ''
138+
Enables additional checks on YAML configuration correctness.
139+
'';
140+
};
141+
142+
extends = mkOption {
143+
type = types.nullOr types.path;
144+
default = null;
145+
example = "process-compose.base.yaml";
146+
description = ''
147+
Make the current configuration inherit all values in the given file.
148+
149+
See https://f1bonacc1.github.io/process-compose/merge#configuration-inheritance-with-extends
150+
'';
151+
};
90152
};
91153
}];
92154
};
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{ name, lib, ... }:
2+
3+
let
4+
inherit (lib) types mkOption;
5+
inherit (types) nullOr listOf str enum bool;
6+
in
7+
{
8+
options = {
9+
rotation = mkOption {
10+
type = types.submodule {
11+
options = {
12+
max_size_mb = mkOption {
13+
type = types.nullOr types.ints.unsigned;
14+
default = null;
15+
example = 1;
16+
description = ''
17+
Maximum size in MB of the logfile before it's rolled.
18+
'';
19+
};
20+
max_backups = mkOption {
21+
type = types.nullOr types.ints.unsigned;
22+
default = null;
23+
example = 3;
24+
description = ''
25+
Maximum number of rolled logfiles to keep.
26+
'';
27+
};
28+
max_age_days = mkOption {
29+
type = types.nullOr types.ints.unsigned;
30+
default = null;
31+
example = 7;
32+
description = ''
33+
Maximum age in days to keep a rolled logfile.
34+
'';
35+
};
36+
compress = mkOption {
37+
type = types.nullOr types.bool;
38+
default = null;
39+
example = true;
40+
description = ''
41+
If enabled, compress rolled logfiles with gzip.
42+
'';
43+
};
44+
};
45+
};
46+
default = { };
47+
description = ''
48+
Settings related to process log rotation.
49+
'';
50+
};
51+
52+
fields_order = mkOption {
53+
type = nullOr (listOf (enum [
54+
"time"
55+
"level"
56+
"message"
57+
# technically arbitrary, but these are defined in config.
58+
])
59+
);
60+
default = null;
61+
example = [
62+
"time"
63+
"level"
64+
"message"
65+
];
66+
description = ''
67+
Order of logging fields. The default is time, level, message
68+
'';
69+
};
70+
disable_json = mkOption {
71+
type = nullOr bool;
72+
default = null;
73+
example = false;
74+
description = ''
75+
If enabled, output as plain text rather than json.
76+
'';
77+
};
78+
timestamp_format = mkOption {
79+
type = nullOr str;
80+
default = null;
81+
example = "2006-01-02T15:04:05.000Z";
82+
description = ''
83+
Timestamp format, per Go's time.Parse function.
84+
Requires `add_timestamp` be enabled to be effective.
85+
86+
See https://pkg.go.dev/time#pkg-constants for examples.
87+
'';
88+
};
89+
no_color = mkOption {
90+
type = nullOr bool;
91+
default = null;
92+
example = false;
93+
description = ''
94+
Enabling `no_color` prevents the use of ANSI colors in the logger.
95+
'';
96+
};
97+
no_metadata = mkOption {
98+
type = nullOr bool;
99+
default = null;
100+
example = true;
101+
description = ''
102+
If enabled, do not add process name and replica number to logs.
103+
'';
104+
};
105+
add_timestamp = mkOption {
106+
type = nullOr bool;
107+
default = null;
108+
example = true;
109+
description = ''
110+
If enabled, prepends a timestamp to log entries.
111+
'';
112+
};
113+
flush_each_line = mkOption {
114+
type = nullOr bool;
115+
default = null;
116+
example = true;
117+
description = ''
118+
If enabled, disables output buffering and flushes each line to the logfile immediately.
119+
'';
120+
};
121+
};
122+
}

nix/process-compose/settings/probe.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ in
4949
Which port to probe the process on.
5050
'';
5151
};
52+
headers = mkOption {
53+
type = types.nullOr (types.attrsOf types.str);
54+
default = null;
55+
example = { "x-foo" = "bar"; };
56+
description = ''
57+
Additional headers to set on an HTTP probe
58+
'';
59+
};
60+
status_code = mkOption {
61+
type = types.nullOr types.int;
62+
default = null;
63+
example = 200;
64+
description = ''
65+
Expected status code.
66+
'';
67+
};
5268
};
5369
});
5470
default = null;
@@ -62,6 +78,13 @@ in
6278
The command to execute in order to check the health of the process.
6379
'';
6480
};
81+
options.working_dir = mkOption {
82+
type = types.str;
83+
example = "./directory";
84+
description = ''
85+
Directory in which to execute the exec probe command.
86+
'';
87+
};
6588
});
6689
default = null;
6790
description = ''

0 commit comments

Comments
 (0)