Created
July 26, 2025 17:55
-
-
Save entropie/702f10ce00394ac8bea65e5edfbc33a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, lib, pkgs, ... }: | |
let | |
mpdUser = "mpd"; | |
mpdGroup = "mpd"; | |
icecastUser = "icecast"; | |
icecastGroup = "icecast"; | |
mpdDir = "/srv/mpd"; | |
mpdMediaDir = "${mpdDir}/music"; | |
mpdPlaylistDir = "${mpdDir}/playlists"; | |
mpdDataDir = "${mpdDir}/data"; | |
icecastIp = "192.168.1.3"; | |
icecastPort = 13337; | |
icecastPassword = "hackme"; | |
in | |
{ | |
fileSystems."${mpdMediaDir}/audiobooks" = { | |
device = "/mnt/storage1/media/audiobooks"; | |
options = [ "bind" ]; | |
}; | |
fileSystems."${mpdMediaDir}/music" = { | |
device = "/mnt/storage1/media/music"; | |
options = [ "bind" ]; | |
}; | |
users.users.${mpdUser} = { | |
isSystemUser = true; | |
group = lib.mkForce mpdGroup; | |
extraGroups = [ "audio" "users" mpdGroup ]; | |
}; | |
services.mpd = { | |
enable = true; | |
musicDirectory = mpdMediaDir; | |
user = mpdUser; | |
group = mpdGroup; | |
dataDir = mpdDataDir; | |
extraConfig = '' | |
audio_output { | |
type "shout" | |
name "Icecast Ogg Stream" | |
host "${icecastIp}" | |
port "${toString icecastPort}" | |
mount "/mpd.ogg" | |
password "${icecastPassword}" | |
user "source" | |
format "44100:16:2" | |
encoder "vorbis" | |
bitrate "192" | |
} | |
''; | |
network.listenAddress = "any"; # if you want to allow non-localhost connections | |
}; | |
services.ympd = { | |
enable = true; | |
webPort = 1337; | |
}; | |
users.users.${icecastUser} = { | |
isSystemUser = true; | |
group = icecastGroup; | |
}; | |
users.groups.${icecastGroup} = {}; | |
services.icecast = { | |
enable = true; | |
hostname = icecastIp; | |
admin = { | |
user = "admin"; | |
password = icecastPassword; | |
}; | |
user = icecastUser; | |
group = icecastGroup; | |
logDir = "/var/log/icecast"; | |
listen = { | |
address = "0.0.0.0"; | |
port = icecastPort; | |
}; | |
extraConf = '' | |
<limits> | |
<clients>100</clients> | |
<sources>2</sources> | |
</limits> | |
<authentication> | |
<source-password>${icecastPassword}</source-password> | |
<admin-user>admin</admin-user> | |
<admin-password>${icecastPassword}</admin-password> | |
</authentication> | |
''; | |
}; | |
environment.systemPackages = with pkgs; [ | |
mpc | |
ncmpcpp | |
lame | |
mpd | |
icecast | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment