diff --git a/host-registry.nix b/host-registry.nix index 66252ff7..a8c5dfcc 100644 --- a/host-registry.nix +++ b/host-registry.nix @@ -11,6 +11,7 @@ rec { hydra.publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDhurL/sxsXRglKdLfiWIcK+iqpyhGrGt/MoBODsgvig"; + mpd-index = { }; pulsebert.publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAnEWn/8CKIiCtehh6Ha3XUQqjODj0ygyo3aGAsFWgfG"; storage-ng.publicKey = diff --git a/hosts/containers/mpd-index/configuration.nix b/hosts/containers/mpd-index/configuration.nix deleted file mode 100644 index 9c47c9ee..00000000 --- a/hosts/containers/mpd-index/configuration.nix +++ /dev/null @@ -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? - -} diff --git a/hosts/pulsebert/configuration.nix b/hosts/pulsebert/configuration.nix index bb0ac903..6f5614c0 100644 --- a/hosts/pulsebert/configuration.nix +++ b/hosts/pulsebert/configuration.nix @@ -23,7 +23,10 @@ in { c3d2 = { isInHq = true; mapHqHosts = true; - hq.interface = "eno1"; + hq = { + interface = "eno1"; + enableMpdProxy = true; + }; enableHail = true; }; @@ -192,40 +195,46 @@ in { # should. system.stateVersion = "18.09"; # Did you read the comment? - # vater hoerte, dass menschen im space gern mpd fuer das abspielen von musik erwarten wuerden #### https://nixos.org/nixos/options.html#services.mpd.enable # See ../../mpd.nix - services.mpd.extraConfig = - '' - audio_output { - type "pulse" - name "/proc" - } - ''; + services.mpd.extraConfig = '' + audio_output { + type "pulse" + name "/proc" + } + ''; services.caddy = { enable = true; agree = true; # TODO: add auth? config = '' - ${mpdVhost} { - proxy / localhost:${toString ympdPort} - } + ${mpdVhost} { + proxy / localhost:${toString ympdPort} + } - :80 { - redir https://${mpdVhost}{uri} - } + :80 { + redir https://${mpdVhost}{uri} + } ''; }; - fileSystems."/mnt/storage" = { #device = "storage-ng.hq.c3d2.de:/mnt/zroot/storage/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"; - 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 diff --git a/hosts/server7/containers/adc/default.nix b/hosts/server7/containers/adc/default.nix index 84fde2f6..b0e3a04c 100644 --- a/hosts/server7/containers/adc/default.nix +++ b/hosts/server7/containers/adc/default.nix @@ -2,7 +2,7 @@ name: (import ../outer-defaults.nix name) // { config = { config, pkgs, lib, ... }: { - imports = [ (../inner-defaults.nix) (../../../../lib/yggdrasil-hq.nix) ]; + imports = [ ../inner-defaults.nix ../../../../lib/yggdrasil-hq.nix ]; services.uhub = { enable = true; diff --git a/hosts/server7/containers/mpd-index/default.nix b/hosts/server7/containers/mpd-index/default.nix new file mode 100644 index 00000000..c84d0b54 --- /dev/null +++ b/hosts/server7/containers/mpd-index/default.nix @@ -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" + ''; + }; + + }; + +} diff --git a/hosts/storage-ng/configuration.nix b/hosts/storage-ng/configuration.nix index 4dd77311..db903a7c 100644 --- a/hosts/storage-ng/configuration.nix +++ b/hosts/storage-ng/configuration.nix @@ -13,7 +13,6 @@ in { ../../lib/shared.nix ../../lib/users.nix ./ncdc.nix - ../../lib/mpd.nix ../../lib/default-gateway.nix ../../lib/emery.nix ]; diff --git a/lib/default.nix b/lib/default.nix index f465791d..9b360380 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -98,6 +98,11 @@ in { 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; 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"; @@ -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 ]; diff --git a/lib/mpd.nix b/lib/mpd.nix index 3ff2d1e9..6f825596 100644 --- a/lib/mpd.nix +++ b/lib/mpd.nix @@ -13,14 +13,9 @@ let dbFile = null; musicDirectory = "/mnt/storage/Music"; playlistDirectory = "/home/k-ot/Playlists"; - extraConfig = '' - database { - plugin "proxy" - host "storage-ng.hq.c3d2.de" - } - ''; }; in { + c3d2.hq.enableMpdProxy = true; services.mpd = (hostMpd // { enable = true; network.listenAddress = "any";