mirror of
https://gitlab.com/rensa-nix/devtools.git
synced 2026-02-02 07:15:08 +01:00
feat: add basic process compose module
This commit is contained in:
parent
a4295c3cdb
commit
25fb9162ff
4 changed files with 84 additions and 0 deletions
|
|
@ -3,5 +3,6 @@
|
||||||
./lefthook.nix
|
./lefthook.nix
|
||||||
./taskfile.nix
|
./taskfile.nix
|
||||||
./cocogitto.nix
|
./cocogitto.nix
|
||||||
|
./process_compose.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
47
lib/modules/process_compose.nix
Normal file
47
lib/modules/process_compose.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkEnableOption mkOption mkIf types;
|
||||||
|
cfg = config.process-compose;
|
||||||
|
|
||||||
|
configFile = (pkgs.formats.yaml {}).generate "process-compose.yaml" cfg.config;
|
||||||
|
pcAlias = pkgs.writeTextFile {
|
||||||
|
name = "pc-alias";
|
||||||
|
destination = "/bin/${cfg.alias}";
|
||||||
|
executable = true;
|
||||||
|
text =
|
||||||
|
# sh
|
||||||
|
''
|
||||||
|
${pkgs.process-compose}/bin/process-compose --config "${configFile}" ''${@:1}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.process-compose = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption "Process-Compose"
|
||||||
|
// {
|
||||||
|
default = cfg.config != {};
|
||||||
|
};
|
||||||
|
alias = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "pc";
|
||||||
|
description = ''
|
||||||
|
Alias for `process-compose`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
config = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Configure process-compose here.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
packages = [pcAlias];
|
||||||
|
};
|
||||||
|
}
|
||||||
28
lib/modules/process_compose_test.nix
Normal file
28
lib/modules/process_compose_test.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
ntlib,
|
||||||
|
devshell,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
module = ./process_compose.nix;
|
||||||
|
in {
|
||||||
|
suites."Process-Compose" = {
|
||||||
|
pos = __curPos;
|
||||||
|
tests = [
|
||||||
|
{
|
||||||
|
name = "basic";
|
||||||
|
type = "script";
|
||||||
|
script = let
|
||||||
|
shell = devshell.mkShell {
|
||||||
|
imports = [module];
|
||||||
|
process-compose.enable = true;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
# sh
|
||||||
|
''
|
||||||
|
${ntlib.helpers.scriptHelpers}
|
||||||
|
assert "-f ${shell}/bin/pc" "/bin/pc should exist"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -54,6 +54,14 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
process-compose.config.processes = {
|
||||||
|
hello.command = "echo 'Hello World'";
|
||||||
|
pc = {
|
||||||
|
command = "echo 'From Process Compose'";
|
||||||
|
depends_on.hello.condition = "process_completed";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
cocogitto.config.changelog = {
|
cocogitto.config.changelog = {
|
||||||
path = "CHANGELOG.md";
|
path = "CHANGELOG.md";
|
||||||
template = "remote";
|
template = "remote";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue