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