diff --git a/flake.nix b/flake.nix index c2d64f2..2f5789d 100644 --- a/flake.nix +++ b/flake.nix @@ -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} + ''; + }; }); }