Skip to content

Commit 248d02a

Browse files
committed
Refactor: separate out cli options
1 parent 15ad16e commit 248d02a

File tree

4 files changed

+47
-36
lines changed

4 files changed

+47
-36
lines changed

nix/flake-module.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
{ self, lib, flake-parts-lib, ... }:
1+
{ lib, flake-parts-lib, ... }:
22
let
33
inherit (flake-parts-lib)
44
mkPerSystemOption;
55
inherit (lib)
66
mdDoc
77
mkOption
8-
types
9-
literalExpression;
8+
types;
109
in
1110
{
1211
options.perSystem = mkPerSystemOption ({ config, pkgs, lib, ... }:

nix/process-compose/cli.nix

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{ config, lib, ... }:
2+
3+
let
4+
inherit (lib) types mkOption;
5+
in
6+
{
7+
options = {
8+
port = mkOption {
9+
type = types.nullOr types.int;
10+
default = null;
11+
description = ''
12+
Port to serve process-compose's Swagger API on.
13+
'';
14+
};
15+
tui = mkOption {
16+
type = types.nullOr types.bool;
17+
default = null;
18+
description = "Enable or disable the TUI for the application.";
19+
};
20+
extraCliArgs =
21+
let
22+
cliArgsAttr = {
23+
port = "-p ${toString config.port}";
24+
tui = "-t=${lib.boolToString config.tui}";
25+
};
26+
getCliArgs =
27+
lib.mapAttrsToList
28+
(opt: arg: lib.optionalString (config.${opt} != null) arg)
29+
cliArgsAttr;
30+
in
31+
mkOption {
32+
type = types.str;
33+
default = lib.concatStringsSep " " getCliArgs;
34+
internal = true;
35+
readOnly = true;
36+
description = ''
37+
Extra command-line arguments to pass to process-compose.
38+
'';
39+
};
40+
};
41+
}
42+

nix/process-compose/default.nix

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{ name, config, pkgs, lib, ... }:
22

33
let
4-
inherit (lib) types mkOption literalExpression;
4+
inherit (lib) types mkOption;
55
in
66
{
77
imports = [
8+
./cli.nix
89
./settings.nix
910
];
1011

@@ -17,38 +18,6 @@ in
1718
The process-compose package to bundle up in the command package and flake app.
1819
'';
1920
};
20-
port = mkOption {
21-
type = types.nullOr types.int;
22-
default = null;
23-
description = ''
24-
Port to serve process-compose's Swagger API on.
25-
'';
26-
};
27-
tui = mkOption {
28-
type = types.nullOr types.bool;
29-
default = null;
30-
description = "Enable or disable the TUI for the application.";
31-
};
32-
extraCliArgs =
33-
let
34-
cliArgsAttr = {
35-
port = "-p ${toString config.port}";
36-
tui = "-t=${lib.boolToString config.tui}";
37-
};
38-
getCliArgs =
39-
lib.mapAttrsToList
40-
(opt: arg: lib.optionalString (config.${opt} != null) arg)
41-
cliArgsAttr;
42-
in
43-
mkOption {
44-
type = types.str;
45-
default = lib.concatStringsSep " " getCliArgs;
46-
internal = true;
47-
readOnly = true;
48-
description = ''
49-
Extra command-line arguments to pass to process-compose.
50-
'';
51-
};
5221
outputs.package = mkOption {
5322
type = types.package;
5423
description = ''

nix/process-compose/settings.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ in
3131
internal = true;
3232
};
3333
};
34+
3435
config.settingsYaml =
3536
let
3637
toYAMLFile =

0 commit comments

Comments
 (0)