added make-mprocs function

This commit is contained in:
didier amyot committed 2023-07-03 13:08:20 -04:00
1 parent 6240fd4b14
commit 5682ef4dd9
1 file changed
+16 -2
+16 -2
View File
@@ -14,14 +14,14 @@
{
writePythonApplication = {name, contentFile, extraRuntimeInputs ? [], python ? null}:
let
python-to-use = python == null then pkgs.python311 else python;
python-to-use = if python == null then pkgs.python311 else python;
wrappedScript = pkgs.writeText "wrappedScript" (builtins.readFile contentFile);
in
pkgs.writeShellApplication {
name = name;
runtimeInputs = [
wrappedScript
if python-to-use] ++ extraRuntimeInputs;
python-to-use] ++ extraRuntimeInputs;
text = ''
exec ${python-to-use}/bin/python ${wrappedScript} "$@"
'';
@@ -39,5 +39,19 @@
exec ${pkgs.babashka}/bin/bb ${wrappedScript} "$@"
'';
};
make-mprocs = {name, derivations ? []}: let
mk-mprocs-procs = ret: derivation: ret ++ [{name = derivation.name;
value = {cmd = ["${derivation}/bin/${derivation.name}"];};
}];
mprocs-procs = builtins.listToAttrs (builtins.foldl' mk-mprocs-procs [] derivations);
mprocs-config = builtins.toJSON {procs = mprocs-procs;};
mprocs-config-file = pkgs.writeText "config.yaml" mprocs-config;
in pkgs.writeShellApplication {
name = name;
runtimeInputs = [pkgs.mprocs] ++ derivations;
text = ''
${pkgs.mprocs}/bin/mprocs --config ${mprocs-config-file}
'';
};
});
}