blob: d54b08d60b3a9397e0a7a30e8614e7a6eb4ce0d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
{ pkgs, lib, ... }:
let
customSettings = {
pageInfo = {
title = "My Custom Dashy Title";
};
sections = [
{
name = "My Section";
items = [
{
name = "NixOS";
url = "https://nixos.org";
}
];
}
];
};
customSettingsYaml = (pkgs.formats.yaml_1_2 { }).generate "custom-conf.yaml" customSettings;
in
{
name = "dashy";
meta.maintainers = [ lib.maintainers.therealgramdalf ];
defaults =
{ config, ... }:
{
services.dashy = {
enable = true;
virtualHost = {
enableNginx = true;
domain = "dashy.local";
};
};
networking.extraHosts = "127.0.0.1 dashy.local";
services.nginx.virtualHosts."${config.services.dashy.virtualHost.domain}".listen = [
{
addr = "127.0.0.1";
port = 80;
}
];
};
containers = {
container = { };
custom = {
services.dashy.settings = customSettings;
};
};
testScript = ''
start_all()
container.wait_for_unit("nginx.service")
container.wait_for_open_port(80)
actual = container.succeed("curl -v --stderr - http://dashy.local/", timeout=10)
expected = "<title>Dashy</title>"
assert expected in actual, \
f"unexpected reply from Dashy, expected: '{expected}' got: '{actual}'"
custom.wait_for_unit("nginx.service")
custom.wait_for_open_port(80)
actual_custom = custom.succeed("curl -s --stderr - http://dashy.local/conf.yml", timeout=10).strip()
expected_custom = custom.succeed("cat ${customSettingsYaml}").strip()
assert expected_custom == actual_custom, \
f"unexpected reply from Dashy, expected: '{expected_custom}' got: '{actual_custom}'"
'';
}
|