mirror of
https://github.com/Platonic-Systems/process-compose-flake.git
synced 2024-09-11 14:07:00 +03:00
Add testScript option
This commit is contained in:
parent
b5e97b110d
commit
3e6a7e4e0f
@ -2,7 +2,7 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- ...
|
||||
- Add `testScript` option for adding flake checks based on nixosTest library.
|
||||
|
||||
## 0.1.0 (Jun 12, 2023)
|
||||
|
||||
|
@ -29,9 +29,14 @@ in
|
||||
});
|
||||
};
|
||||
|
||||
config.packages = lib.mapAttrs
|
||||
(name: cfg: cfg.outputs.package)
|
||||
config.process-compose;
|
||||
config = {
|
||||
packages = lib.mapAttrs
|
||||
(name: cfg: cfg.outputs.package)
|
||||
config.process-compose;
|
||||
checks = lib.mapAttrs
|
||||
(name: cfg: cfg.outputs.check)
|
||||
config.process-compose;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ in
|
||||
imports = [
|
||||
./cli.nix
|
||||
./settings
|
||||
./test.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
|
47
nix/process-compose/test.nix
Normal file
47
nix/process-compose/test.nix
Normal file
@ -0,0 +1,47 @@
|
||||
{ name, config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) types mkOption;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
testScript = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = ''
|
||||
If set, add a flake check running nixosTest running this process-compose
|
||||
configuration, followed by the specified testScript.
|
||||
|
||||
Useful if you want to test your configuration in CI.
|
||||
'';
|
||||
default = null;
|
||||
};
|
||||
outputs.check = mkOption {
|
||||
type = types.nullOr types.package;
|
||||
default = if config.testScript == null then null else
|
||||
pkgs.nixosTest {
|
||||
inherit (config) testScript;
|
||||
name = "process-compose-${name}-test";
|
||||
nodes.machine = {
|
||||
environment.systemPackages = [ pkgs.bash ]; # process-compose requires it.
|
||||
systemd.services.process-compose = {
|
||||
enable = true;
|
||||
wantedBy = [ "default.target" ];
|
||||
serviceConfig = {
|
||||
WorkingDirectory = "/tmp";
|
||||
ExecStart = lib.getExe (pkgs.writeShellApplication {
|
||||
name = "process-compose-${name}";
|
||||
text = ''
|
||||
set -x
|
||||
echo "Launching procese-compose on ${name} ..."
|
||||
# make bash available to process-compose
|
||||
export PATH=/run/current-system/sw/bin:$PATH
|
||||
${lib.getExe config.outputs.package} -t=false
|
||||
'';
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user