|
17 | 17 | process-compose-flake: creates [process-compose](https://github.com/F1bonacc1/process-compose) |
18 | 18 | executables from process-compose configurations written as Nix attribute sets. |
19 | 19 | ''; |
20 | | - type = types.submodule { |
| 20 | + type = types.attrsOf (types.submodule ({ config, ... }: { |
21 | 21 | options = { |
22 | 22 | package = mkOption { |
23 | 23 | type = types.package; |
|
27 | 27 | The process-compose package to bundle up in the command package and flake app. |
28 | 28 | ''; |
29 | 29 | }; |
30 | | - configs = mkOption { |
31 | | - type = types.attrsOf (pkgs.formats.yaml { }).type; |
32 | | - default = { }; |
| 30 | + settings = mkOption { |
| 31 | + type = (pkgs.formats.yaml { }).type; |
33 | 32 | example = |
34 | | - # apps.${system}.watch-server and packages.${system}.watch-server become available |
| 33 | + # packages.${system}.watch-server becomes available |
35 | 34 | # execute `nix run .#watch-server` or incude packages.${system}.watch-server |
36 | 35 | # as a nativeBuildInput to your devShell |
37 | 36 | literalExpression '' |
|
64 | 63 | extraCliArgs = |
65 | 64 | let |
66 | 65 | cliArgsAttr = { |
67 | | - port = "-p ${toString config.process-compose.port}"; |
68 | | - tui = "-t=${lib.boolToString config.process-compose.tui}"; |
| 66 | + port = "-p ${toString config.port}"; |
| 67 | + tui = "-t=${lib.boolToString config.tui}"; |
69 | 68 | }; |
70 | 69 | getCliArgs = |
71 | 70 | lib.mapAttrsToList |
72 | | - (opt: arg: lib.optionalString (config.process-compose.${opt} != null) arg) |
| 71 | + (opt: arg: lib.optionalString (config.${opt} != null) arg) |
73 | 72 | cliArgsAttr; |
74 | 73 | in |
75 | 74 | mkOption { |
|
82 | 81 | ''; |
83 | 82 | }; |
84 | 83 | }; |
85 | | - }; |
| 84 | + })); |
86 | 85 | }; |
87 | 86 | }); |
88 | 87 | }; |
|
95 | 94 | yq -P '.' ${pkgs.writeTextFile { name = "tmp.json"; text = (builtins.toJSON attrs); }} > $out |
96 | 95 | ''; |
97 | 96 | packages = pkgs.lib.mapAttrs |
98 | | - (name: processComposeConfig: |
| 97 | + (name: cfg: |
99 | 98 | pkgs.writeShellApplication { |
100 | 99 | inherit name; |
101 | | - runtimeInputs = [ config.process-compose.package ]; |
| 100 | + runtimeInputs = [ cfg.package ]; |
102 | 101 | text = '' |
103 | | - process-compose up -f ${toYAMLFile processComposeConfig} ${config.process-compose.extraCliArgs} "$@" |
| 102 | + process-compose up \ |
| 103 | + -f ${toYAMLFile cfg.settings} \ |
| 104 | + ${cfg.extraCliArgs} \ |
| 105 | + "$@" |
104 | 106 | ''; |
105 | 107 | } |
106 | 108 | ) |
107 | | - config.process-compose.configs; |
| 109 | + config.process-compose; |
108 | 110 | in |
109 | 111 | { |
110 | 112 | inherit packages; |
|
0 commit comments