{ pkgs }: let inherit (pkgs) lib; runtime = ".compose"; in { mkWrapper = { config, name, enableTui ? false, modules ? [ ], }: let merged_config = lib.foldl' (acc: elem: lib.recursiveUpdate acc elem) config modules; removeNullAndEmptyAttrs = attrs: let f = lib.filterAttrsRecursive (key: value: value != null && value != { }); in # filterAttrsRecursive doesn't delete the *resulting* empty attrs, so we must # evaluate it again and to get rid of it. lib.pipe attrs [ f f ]; toPCJson = name: attrs: pkgs.writeTextFile { name = "process-compose-${name}.json"; text = builtins.toJSON attrs; }; configFile = toPCJson name ( removeNullAndEmptyAttrs ( merged_config // { is_tui_disabled = !enableTui; } ) ); in pkgs.writeShellApplication { inherit name; text = '' PC_NO_SERVER=true PC_CONFIG_FILES=${configFile} RUNTIME_PATH=$(pwd)/${runtime} ${pkgs.process-compose}/bin/process-compose "$@" ''; }; mkPostgres = import ./services/postgres.nix { inherit pkgs; }; mkRedis = import ./services/redis.nix { inherit pkgs; }; mkValkey = import ./services/valkey.nix { inherit pkgs; }; }