Move mpd-index to Server7, c3d2.hq.enableMpdProxy

This commit is contained in:
Emery Hemingway 2020-01-26 13:49:39 +01:00
parent d17a7e01e9
commit 6033155062
8 changed files with 79 additions and 87 deletions

View File

@ -11,6 +11,7 @@ rec {
hydra.publicKey = hydra.publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDhurL/sxsXRglKdLfiWIcK+iqpyhGrGt/MoBODsgvig"; "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDhurL/sxsXRglKdLfiWIcK+iqpyhGrGt/MoBODsgvig";
mpd-index = { };
pulsebert.publicKey = pulsebert.publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAnEWn/8CKIiCtehh6Ha3XUQqjODj0ygyo3aGAsFWgfG"; "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAnEWn/8CKIiCtehh6Ha3XUQqjODj0ygyo3aGAsFWgfG";
storage-ng.publicKey = storage-ng.publicKey =

View File

@ -1,61 +0,0 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, lib, ... }:
{
imports = [
../../../lib/lxc-container.nix
../../../lib/shared.nix
../../../lib/admins.nix
../../../lib
];
c3d2 = {
isInHq = true;
enableHail = true;
};
environment.systemPackages = with pkgs; [ ncmpcpp ];
fileSystems."/mnt/music" = {
fsType = "nfs";
device = "172.22.99.10:/mnt/zroot/storage/rpool/Music";
};
networking.hostName = "mpd-index";
services.openssh = {
enable = true;
permitRootLogin = "yes";
};
services.mpd = {
enable = true;
user = "mpd";
group = "audio";
network = {
listenAddress = "any";
port = 6600;
};
musicDirectory = "/mnt/music";
extraConfig = ''
default_permissions "read,add,control,admin"
input {
plugin "curl"
}
audio_output {
type "null"
name "My Null Output"
}
filesystem_charset "UTF-8"
'';
};
system.stateVersion = "18.09"; # Did you read the comment?
}

View File

@ -23,7 +23,10 @@ in {
c3d2 = { c3d2 = {
isInHq = true; isInHq = true;
mapHqHosts = true; mapHqHosts = true;
hq.interface = "eno1"; hq = {
interface = "eno1";
enableMpdProxy = true;
};
enableHail = true; enableHail = true;
}; };
@ -192,40 +195,46 @@ in {
# should. # should.
system.stateVersion = "18.09"; # Did you read the comment? system.stateVersion = "18.09"; # Did you read the comment?
# vater hoerte, dass menschen im space gern mpd fuer das abspielen von musik erwarten wuerden # vater hoerte, dass menschen im space gern mpd fuer das abspielen von musik erwarten wuerden
#### https://nixos.org/nixos/options.html#services.mpd.enable #### https://nixos.org/nixos/options.html#services.mpd.enable
# See ../../mpd.nix # See ../../mpd.nix
services.mpd.extraConfig = services.mpd.extraConfig = ''
'' audio_output {
audio_output { type "pulse"
type "pulse" name "/proc"
name "/proc" }
} '';
'';
services.caddy = { services.caddy = {
enable = true; enable = true;
agree = true; agree = true;
# TODO: add auth? # TODO: add auth?
config = '' config = ''
${mpdVhost} { ${mpdVhost} {
proxy / localhost:${toString ympdPort} proxy / localhost:${toString ympdPort}
} }
:80 { :80 {
redir https://${mpdVhost}{uri} redir https://${mpdVhost}{uri}
} }
''; '';
}; };
fileSystems."/mnt/storage" = { fileSystems."/mnt/storage" = {
#device = "storage-ng.hq.c3d2.de:/mnt/zroot/storage/rpool"; #device = "storage-ng.hq.c3d2.de:/mnt/zroot/storage/rpool";
#device = "storage-ng.hq.c3d2.de:/c3d2/rpool"; #device = "storage-ng.hq.c3d2.de:/c3d2/rpool";
device = "172.22.99.13:6789,172.22.99.15:6789,172.22.99.16:6789:/c3d2/rpool"; device =
"172.22.99.13:6789,172.22.99.15:6789,172.22.99.16:6789:/c3d2/rpool";
fsType = "ceph"; fsType = "ceph";
options = [ "rw" "relatime" "name=public" "secret=AQDgER1chJcMORAAK1ysRTN59B5x/MyniwVXFQ==" "acl" "wsize=16777216" "_netdev" ]; options = [
"rw"
"relatime"
"name=public"
"secret=AQDgER1chJcMORAAK1ysRTN59B5x/MyniwVXFQ=="
"acl"
"wsize=16777216"
"_netdev"
];
}; };
# MPD music playing daemon with webinterface # MPD music playing daemon with webinterface

View File

@ -2,7 +2,7 @@ name:
(import ../outer-defaults.nix name) // { (import ../outer-defaults.nix name) // {
config = { config, pkgs, lib, ... }: { config = { config, pkgs, lib, ... }: {
imports = [ (../inner-defaults.nix) (../../../../lib/yggdrasil-hq.nix) ]; imports = [ ../inner-defaults.nix ../../../../lib/yggdrasil-hq.nix ];
services.uhub = { services.uhub = {
enable = true; enable = true;

View File

@ -0,0 +1,33 @@
name:
(import ../outer-defaults.nix name) // {
bindMounts."/mnt/music" = {
hostPath = "/srv/ceph/c3d2/rpool/Music";
isReadOnly = true;
};
config = { config, pkgs, lib, ... }:
{
imports = [ ../inner-defaults.nix ];
services.mpd = {
enable = true;
network.listenAddress = "any";
musicDirectory = "/mnt/music";
extraConfig = ''
default_permissions "read,add,control,admin"
audio_output {
type "null"
name "My Null Output"
}
filesystem_charset "UTF-8"
'';
};
};
}

View File

@ -13,7 +13,6 @@ in {
../../lib/shared.nix ../../lib/shared.nix
../../lib/users.nix ../../lib/users.nix
./ncdc.nix ./ncdc.nix
../../lib/mpd.nix
../../lib/default-gateway.nix ../../lib/default-gateway.nix
../../lib/emery.nix ../../lib/emery.nix
]; ];

View File

@ -98,6 +98,11 @@ in {
description = "Whether to enable the local Nix binary cache"; description = "Whether to enable the local Nix binary cache";
}; };
enableMpdProxy = mkOption {
type = bool;
default = false;
description = "Whether to proxy the local MPD database";
};
}; };
@ -123,6 +128,10 @@ in {
assertion = cfg.hq.enableBinaryCache -> cfg.mapHqHosts; assertion = cfg.hq.enableBinaryCache -> cfg.mapHqHosts;
message = "mapHqHosts must be enabled for enableBinaryCache"; message = "mapHqHosts must be enabled for enableBinaryCache";
} }
{
assertion = cfg.hq.enableMpdProxy -> cfg.mapHqHosts;
message = "mapHqHosts must be enabled for enableMpdProxy";
}
]; ];
networking.defaultGateway = mkIfIsInHq "172.22.99.4"; networking.defaultGateway = mkIfIsInHq "172.22.99.4";
@ -247,6 +256,13 @@ in {
]; ];
}; };
services.mpd.extraConfig = lib.mkIf cfg.hq.enableMpdProxy ''
database {
plugin "proxy"
host "mpd-index.hq"
}
'';
}; };
meta.maintainers = with lib.maintainers; [ ehmry ]; meta.maintainers = with lib.maintainers; [ ehmry ];

View File

@ -13,14 +13,9 @@ let
dbFile = null; dbFile = null;
musicDirectory = "/mnt/storage/Music"; musicDirectory = "/mnt/storage/Music";
playlistDirectory = "/home/k-ot/Playlists"; playlistDirectory = "/home/k-ot/Playlists";
extraConfig = ''
database {
plugin "proxy"
host "storage-ng.hq.c3d2.de"
}
'';
}; };
in { in {
c3d2.hq.enableMpdProxy = true;
services.mpd = (hostMpd // { services.mpd = (hostMpd // {
enable = true; enable = true;
network.listenAddress = "any"; network.listenAddress = "any";