blob: 9e8230f262caec57b8c1668c97139c52231ff907 (
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
|
{ lib, pkgs, ... }:
{
name = "gonic";
meta.maintainers = pkgs.gonic.meta.maintainers;
nodes.default_cache_dir =
{ config, ... }:
{
systemd.tmpfiles.settings = {
"10-gonic" = {
"/tmp/music"."d" = { };
"/tmp/podcast"."d" = { };
"/tmp/playlists"."d" = { };
"/tmp/secrets"."d" = { };
};
};
services.gonic = {
enable = true;
# Wrap gonic to check that the required paths are writable.
# This isn't necessarily checked by successful service startup.
package = pkgs.writeShellApplication {
name = "gonic-test-wrapper";
runtimeInputs = [ pkgs.gonic ];
text = ''
touch ${config.services.gonic.settings.cache-path}/foo && echo "cache dir writeable" >&2
touch /tmp/podcast/foo && echo "podcast dir writeable" >&2
touch /tmp/playlists/foo && echo "playlists dir writeable" >&2
touch /tmp/secrets/foo && echo "shouldn't be able to write /tmp/secrets" >&2 && exit 1
exec ${lib.getExe pkgs.gonic} "$@"
'';
};
settings = {
music-path = [ "/tmp/music" ];
podcast-path = "/tmp/podcast";
playlists-path = "/tmp/playlists";
};
};
};
nodes.custom_cache_dir =
{ ... }:
{
systemd.tmpfiles.settings = {
"10-gonic" = {
"/tmp/music"."d" = { };
"/tmp/podcast"."d" = { };
"/tmp/playlists"."d" = { };
"/tmp/cache"."d" = { };
};
};
services.gonic = {
enable = true;
settings = {
music-path = [ "/tmp/music" ];
podcast-path = "/tmp/podcast";
playlists-path = "/tmp/playlists";
cache-path = "/tmp/cache";
};
};
};
testScript = ''
default_cache_dir.wait_for_unit("gonic")
default_cache_dir.wait_for_open_port(4747)
custom_cache_dir.wait_for_unit("gonic")
custom_cache_dir.wait_for_open_port(4747)
'';
}
|