Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make process-compose-flake usable without flake-parts #80

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- ~~#18: Add `testScript` option for adding flake checks based on nixosTest library.~~
- #39: Allow `test` process to act as a test, which then gets run as part of flake checks.
- #55: Add `lib` flake output - library of useful functions
- #80: Add `evalModules`, to use process-compose-flake without flake-parts
- New options
- #52: Add `is_foreground` option
- ~~#54: Add `apiServer` option to control REST API server~~
Expand Down
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.

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

# nix run .#ponysay up to start the process
packages.ponysay = (import inputs.process-compose-flake.lib { inherit pkgs; }).makeProcessCompose {
modules = [{
settings = {
processes = {
ponysay.command = ''
while true; do
${lib.getExe pkgs.ponysay} "Hi!"
sleep 2
done
'';
};
};
}];
};
};
};
}
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 ? "process-compose", modules }: (evalModules {
inherit name;
modules = modules;
}).config.outputs.package;
}
Loading