working wrapper
This commit is contained in:
44
lib.nix
44
lib.nix
@@ -1,4 +1,46 @@
|
|||||||
{ pkgs }:
|
{ pkgs }:
|
||||||
|
let
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
mkWrapper = { }: { };
|
mkWrapper =
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
name,
|
||||||
|
enableTui ? false,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
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 (
|
||||||
|
config
|
||||||
|
// {
|
||||||
|
is_tui_disabled = !enableTui;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
in
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
inherit name;
|
||||||
|
text = ''
|
||||||
|
PC_CONFIG_FILES=${configFile} ${pkgs.process-compose}/bin/process-compose "$@"
|
||||||
|
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user