tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
Added icecast module.
koral
11 years ago
54857abf
1d9d0312
+132
-1
2 changed files
expand all
collapse all
unified
split
nixos
modules
module-list.nix
services
audio
icecast.nix
+2
-1
nixos/modules/module-list.nix
···
91
91
./services/amqp/activemq/default.nix
92
92
./services/amqp/rabbitmq.nix
93
93
./services/audio/alsa.nix
94
94
-
# Disabled as fuppes it does no longer builds.
94
94
+
# Disabled as fuppes no longer builds.
95
95
# ./services/audio/fuppes.nix
96
96
+
./services/audio/icecast.nix
96
97
./services/audio/liquidsoap.nix
97
98
./services/audio/mpd.nix
98
99
./services/audio/mopidy.nix
+130
nixos/modules/services/audio/icecast.nix
···
1
1
+
{ config, lib, pkgs, ... }:
2
2
+
3
3
+
with lib;
4
4
+
5
5
+
let
6
6
+
cfg = config.services.icecast;
7
7
+
configFile = pkgs.writeText "icecast.xml" ''
8
8
+
<icecast>
9
9
+
<hostname>${cfg.hostname}</hostname>
10
10
+
11
11
+
<authentication>
12
12
+
<admin-user>${cfg.admin.user}</admin-user>
13
13
+
<admin-password>${cfg.admin.password}</admin-password>
14
14
+
</authentication>
15
15
+
16
16
+
<paths>
17
17
+
<logdir>${cfg.logDir}</logdir>
18
18
+
<adminroot>${pkgs.icecast}/share/icecast/admin</adminroot>
19
19
+
<webroot>${pkgs.icecast}/share/icecast/web</webroot>
20
20
+
<alias source="/" dest="/status.xsl"/>
21
21
+
</paths>
22
22
+
23
23
+
<listen-socket>
24
24
+
<port>${toString cfg.listen.port}</port>
25
25
+
<bind-address>${cfg.listen.address}</bind-address>
26
26
+
</listen-socket>
27
27
+
28
28
+
<security>
29
29
+
<chroot>0</chroot>
30
30
+
<changeowner>
31
31
+
<user>${cfg.user}</user>
32
32
+
<group>${cfg.group}</group>
33
33
+
</changeowner>
34
34
+
</security>
35
35
+
36
36
+
${cfg.extraConf}
37
37
+
</icecast>
38
38
+
'';
39
39
+
in {
40
40
+
41
41
+
###### interface
42
42
+
43
43
+
options = {
44
44
+
45
45
+
services.icecast = {
46
46
+
47
47
+
enable = mkEnableOption "Icecast server";
48
48
+
49
49
+
hostname = mkOption {
50
50
+
type = types.str;
51
51
+
description = "DNS name or IP address that will be used for the stream directory lookups or possibily the playlist generation if a Host header is not provided.";
52
52
+
default = config.networking.domain;
53
53
+
};
54
54
+
55
55
+
admin = {
56
56
+
user = mkOption {
57
57
+
type = types.str;
58
58
+
description = "Username used for all administration functions.";
59
59
+
default = "admin";
60
60
+
};
61
61
+
62
62
+
password = mkOption {
63
63
+
type = types.str;
64
64
+
description = "Password used for all administration functions.";
65
65
+
};
66
66
+
};
67
67
+
68
68
+
logDir = mkOption {
69
69
+
type = types.path;
70
70
+
description = "Base directory used for logging.";
71
71
+
default = "/var/log/icecast";
72
72
+
};
73
73
+
74
74
+
listen = {
75
75
+
port = mkOption {
76
76
+
type = types.int;
77
77
+
description = "TCP port that will be used to accept client connections.";
78
78
+
default = 8000;
79
79
+
};
80
80
+
81
81
+
address = mkOption {
82
82
+
type = types.str;
83
83
+
description = "Address Icecast will listen on.";
84
84
+
default = "::";
85
85
+
};
86
86
+
};
87
87
+
88
88
+
user = mkOption {
89
89
+
type = types.str;
90
90
+
description = "User privileges for the server.";
91
91
+
default = "nobody";
92
92
+
};
93
93
+
94
94
+
group = mkOption {
95
95
+
type = types.str;
96
96
+
description = "Group privileges for the server.";
97
97
+
default = "nogroup";
98
98
+
};
99
99
+
100
100
+
extraConf = mkOption {
101
101
+
type = types.lines;
102
102
+
description = "icecast.xml content.";
103
103
+
default = "";
104
104
+
};
105
105
+
106
106
+
};
107
107
+
108
108
+
};
109
109
+
110
110
+
111
111
+
###### implementation
112
112
+
113
113
+
config = mkIf cfg.enable {
114
114
+
115
115
+
systemd.services.icecast = {
116
116
+
after = [ "network.target" ];
117
117
+
description = "Icecast Network Audio Streaming Server";
118
118
+
wantedBy = [ "multi-user.target" ];
119
119
+
120
120
+
preStart = "mkdir -p ${cfg.logDir} && chown ${cfg.user}:${cfg.group} ${cfg.logDir}";
121
121
+
serviceConfig = {
122
122
+
Type = "simple";
123
123
+
ExecStart = "${pkgs.icecast}/bin/icecast -c ${configFile}";
124
124
+
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
125
125
+
};
126
126
+
};
127
127
+
128
128
+
};
129
129
+
130
130
+
}