feat: add basic process compose module

This commit is contained in:
technofab 2025-12-19 15:04:26 +01:00
parent a4295c3cdb
commit 25fb9162ff
Signed by: technofab
SSH key fingerprint: SHA256:bV4h88OqS/AxjbPn66uUdvK9JsgIW4tv3vwJQ8tpMqQ
4 changed files with 84 additions and 0 deletions

View file

@ -3,5 +3,6 @@
./lefthook.nix
./taskfile.nix
./cocogitto.nix
./process_compose.nix
];
}

View 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];
};
}

View 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"
'';
}
];
};
}