Skip to content

Commit

Permalink
make process-compose-flake usable without flake-parts
Browse files Browse the repository at this point in the history
  • Loading branch information
VanCoding committed Sep 29, 2024
1 parent dcf3082 commit dbc39c1
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 25 deletions.
42 changes: 18 additions & 24 deletions example/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions example/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@
};
};
};

# nix run .#ponysay up to start the process
packages.ponysay = inputs.process-compose-flake.lib.makeProcessCompose {
inherit pkgs;
name = "ponysay";
modules = [{
arguments.detached = true;
settings = {
processes = {
ponysay.command = ''
while true; do
${lib.getExe pkgs.ponysay} "Hi!"
sleep 2
done
'';
};
};
}];
};
};
};
}
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
flakeModule = ./nix/flake-module.nix;

lib = ./nix/lib.nix;
evalModules = import ./nix/eval-modules.nix;

templates.default = {
description = "Example flake using process-compose-flake";
Expand Down
21 changes: 20 additions & 1 deletion nix/lib.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, ... }:
{ pkgs, lib ? pkgs.lib, ... }:

rec {
# Lookup an environment in process-compose environment list
Expand Down Expand Up @@ -31,4 +31,23 @@ rec {
types = {
command = import ./process-compose/setting/command.nix { inherit lib; };
};

# Run the process-compose-module stand-alone, without flake-parts
# - modules: list of modules that set process-compose-flake options
# - name: name of the module, you typically don't need to set this
# Returns the full result of the module evaluation
evalModules = { name ? "process-compose", modules }: (lib.evalModules {
specialArgs = {
inherit name pkgs;
};
modules = [
./process-compose
] ++ modules;
});

# Same as evalModules, but returns the process-compose process directly
makeProcessCompose = { name, modules }: (evalModules {
inherit pkgs name;
modules = modules;
}).config.outputs.package;
}

0 comments on commit dbc39c1

Please sign in to comment.