The experimental [piping operator](https://github.com/NixOS/rfcs/pull/148) is currently used in Dynix, so you must enable the experimental feature `pipe-operator` for Lix or `pipe-operators` for CppNix (you can add both to cover both Nix implementations); flakes are used for locked inputs.
To run a test with fewer experimental features, and without locked inputs, you can use the old CLI:
```bash
$ nix-build --experimental-features "pipe-operator pipe-operators" -A tests.gotosocial
This example, implemented in [`./modules/dynamicism/gotosocial.nix`](./modules/dynamicism/gotosocial.nix), is tested in [`./tests/gotosocial`](./tests/gotosocial).
The test sets up a VM using NixOS's `services.gotosocial` module with the following *static* [configuration](./tests/gotosocial/configuration.nix):
```nix
{
services.gotosocial = {
enable = true;
setupPostgresqlDB = true;
settings = {
application-name = "gotosocial-for-machine";
host = "gotosocial-machine.local";
};
};
}
```
The automated [test script](./tests/gotosocial/test-script.py):
1. Asserts that that the above *static* configuration is in effect (by extracting the configuration from the running Gotosocial process)
2. Runs `dynix append "services.gotosocial.settings.application-name" "yay!"`, which modifies the append-only configuration file `/etc/nixos/dynamic.nix` in the VM filesystem
3. Runs the dynamic activation script built by `(import <nixpkgs/nixos>).config.dynamicism.applyDynamicConfiguration { }`, which *applies* the dynamic configuration
4. Asserts that the dynamically configured `application-name` is in effect
5. Runs `nixos-rebuild switch` to re-apply the *static* configuration
6. Asserts that the dynamic configuration is *no longer* in effect, and we are back to the static configuration
This example, implemented in [`./modules/dynamicism/harmonia.nix`](./modules/dynamicism/harmonia.nix), is tested in [`./tests/harmonia`](./tests/harmonia).
The test sets up a VM using NixOS's `services.harmonia` module with the following *static* [configuration](./tests/harmonia/configuration.nix)
```nix
{
services.harmonia = {
enable = true;
settings = {
workers = 4;
max_connection_rate = 256;
};
};
}
```
The VM [test script](./tests/harmonia/test-script.py):
1. Asserts that the above *static* configuration is in effect (by extracting the configuration from the running Harmonia process)
2. Runs `dynix append "services.harmonia.settings.workers" 20`, to modify the append-only configuration file `/etc/nixos/dynamic.nix` in the VM filesystem
3. Runs the dynamic activation script built by `(import <nixpkgs/nixos>).config.dynamicism.applyDynamicConfiguration { }`, to *apply* the dynamic configuration
4. Asserts that the dynamically configured `workers` is in effect
This example, implemented in [`./modules/dynamicism/distccd.nix`](./modules/dynamicism/distccd.nix), is tested in [`./tests/distccd`](./tests/distccd).
The test sets up a VM using NixOS's `services.distccd` module with the following *static* [configuration](./tests/distccd/configuration.nix):
```nix
{
services.distccd = {
jobTimeout = 900;
maxJobs = 12;
logLevel = "warning";
};
}
```
The VM [test script](./tests/distccd/test-script.py):
1. Asserts that the above *static* configuration is in effect (by extracting the configuration from the running Distccd process)
2. Runs `dynix append "services.distccd.maxJobs" 4`, to modify the append-only configuration file `/etc/nixos/dynamic.nix` in the VM filesystem
3. Runs the dynamic activation script built by `(import <nixpkgs/nixos>).config.dynamicism.applyDynamicConfiguration { }`, to *apply* the dynamic configuration
4. Asserts that the dynamically configured `maxJobs` is in effect