mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-04 14:21:02 +03:00
5142b7afa8
The main idea behind that was to be able to do more sophisticated merging for stuff that goes into `postgresql.conf`: `shared_preload_libraries` is a comma-separated list in a `types.str` and thus not mergeable. With this change, the option accepts both a comma-separated string xor a list of strings. This can be implemented rather quick using `coercedTo` + freeform modules. The interface still behaves equally, but it allows to merge declarations for this option together. One side-effect was that I had to change the `attrsOf (oneOf ...)` part into a submodule to allow declaring options for certain things. While at it, I decided to move `log_line_prefix` and `port` into this structure as well.
42 lines
1.0 KiB
Nix
42 lines
1.0 KiB
Nix
import ./make-test-python.nix ({ pkgs, ... } :
|
|
let
|
|
role = "test";
|
|
password = "secret";
|
|
conn = "local";
|
|
in
|
|
{
|
|
name = "pgmanage";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ basvandijk ];
|
|
};
|
|
nodes = {
|
|
one = { config, pkgs, ... }: {
|
|
services = {
|
|
postgresql = {
|
|
enable = true;
|
|
initialScript = pkgs.writeText "pg-init-script" ''
|
|
CREATE ROLE ${role} SUPERUSER LOGIN PASSWORD '${password}';
|
|
'';
|
|
};
|
|
pgmanage = {
|
|
enable = true;
|
|
connections = {
|
|
${conn} = "hostaddr=127.0.0.1 port=${toString config.services.postgresql.settings.port} dbname=postgres";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
one.wait_for_unit("default.target")
|
|
one.require_unit_state("pgmanage.service", "active")
|
|
|
|
# Test if we can log in.
|
|
one.wait_until_succeeds(
|
|
"curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail"
|
|
)
|
|
'';
|
|
})
|