Skip to content

Commit

Permalink
Merge pull request #7 from jwillikers/fix-mop2
Browse files Browse the repository at this point in the history
Fix Mopidy not playing after suspend on idle
  • Loading branch information
jwillikers authored Nov 24, 2024
2 parents b6fa2ee + 0beda9a commit 511b7da
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 91 deletions.
13 changes: 10 additions & 3 deletions home-manager/_mixins/services/mopidy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ lib.mkIf (lib.elem username installFor && role == "piceiver") {
services.mopidy = {
enable = true;
extensionPackages = with pkgs; [
# Trick the NixOS module into using my overlay for Mopidy.
# Ha.
mopidy
mopidy-iris
mopidy-jellyfin
];
Expand All @@ -20,10 +23,14 @@ lib.mkIf (lib.elem username installFor && role == "piceiver") {
audio = {
# If you set this too low, Mopidy will get hopelessly lost when switching between tracks and become unresponsive.
# The lowest I could get this without causing Mopidy to crash was 35ms.
buffer_time = 35; # Must be greater than 0, default from GStreamer is 1000ms
# Now lowest is 50ms for some reason...
buffer_time = 50; # Must be greater than 0, default from GStreamer is 1000ms
mixer = "software";
mixer_volume = 50;
output = "pipewiresink client-name=Mopidy target-object=snapserver stream-properties=\"props,application.id=mopidy,application.name=Mopidy,application.process.binary=mopidy,application.version=${lib.getVersion pkgs.mopidy},media.category=Playback,media.role=Music,media.type=Audio\"";
output = "pipewiresink client-name=Mopidy target-object=snapserver stream-properties=\"props,application.id=mopidy,application.name=Mopidy,application.process.binary=mopidy,application.version=${lib.getVersion pkgs.mopidy},media.category=Playback,media.role=Music,media.type=Audio,session.suspend-timeout-seconds=0\"";
};
file = {
enabled = false;
};
http = {
enabled = true;
Expand All @@ -40,7 +47,7 @@ lib.mkIf (lib.elem username installFor && role == "piceiver") {
hostname = "jellyfin.lan.jwillikers.io";
username = "jordan";
# todo Use sops for password.
password = "your password here";
password = "I0DpLg45FF^t5N";
libraries = [
"Books"
"Music"
Expand Down
200 changes: 112 additions & 88 deletions overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,40 +61,61 @@
# todo Make it possible to disable graphviz support in libcamera.
graphviz = prev.graphviz.override { withXorg = false; };
gst_all_1 = prev.gst_all_1 // {
gstreamer = prev.gst_all_1.gstreamer.overrideAttrs (prevAttrs: rec {
version = "1.24.9";
src = prev.fetchurl {
url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
hash = "sha256-6/R7a+71CKAMhVfUwfFxPlx++bpw2sRd7tgOGCvPJg8=";
};
});
gst-plugins-base =
(prev.gst_all_1.gst-plugins-base.override {
enableX11 = false;
enableWayland = false;
}).overrideAttrs
(prevAttrs: rec {
version = "1.24.9";
src = prev.fetchurl {
url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
hash = "sha256-W7O5RpB9POBN2EK2EMgRHCsGETUbJaH6Iq9e+ol4V8s=";
};
});
gst-plugins-good =
(prev.gst_all_1.gst-plugins-good.override {
enableX11 = false;
enableWayland = false;
}).overrideAttrs
(prevAttrs: rec {
version = "1.24.9";
src = prev.fetchurl {
url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
hash = "sha256-iX3lC/8zfjyi+G8eqijggo2DAkFWFipQxOoK+G4peZ8=";
};
});
# gstreamer = prev.gst_all_1.gstreamer.overrideAttrs (prevAttrs: rec {
# version = "1.24.9";
# src = prev.fetchurl {
# url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
# hash = "sha256-6/R7a+71CKAMhVfUwfFxPlx++bpw2sRd7tgOGCvPJg8=";
# };
# });
# gst-plugins-bad = prev.gst_all_1.gst-plugins-bad.overrideAttrs (prevAttrs: rec {
# version = "1.24.9";
# src = prev.fetchurl {
# url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
# hash = "sha256-Nvz3qa8KdTtDuwO5g1JG901y9xJDaeZqHi3HsE9aXKs=";
# };
# });
gst-plugins-base = prev.gst_all_1.gst-plugins-base.override {
enableX11 = false;
enableWayland = false;
};
# }).overrideAttrs
# (prevAttrs: rec {
# # version = "1.24.9";
# # src = prev.fetchurl {
# # url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
# # hash = "sha256-W7O5RpB9POBN2EK2EMgRHCsGETUbJaH6Iq9e+ol4V8s=";
# # };
# });
gst-plugins-good = prev.gst_all_1.gst-plugins-good.override {
enableX11 = false;
enableWayland = false;
};
# }).overrideAttrs
# (prevAttrs: rec {
# version = "1.24.9";
# src = prev.fetchurl {
# url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
# hash = "sha256-iX3lC/8zfjyi+G8eqijggo2DAkFWFipQxOoK+G4peZ8=";
# };
# });
# gst-libva = prev.gst_all_1.gst-libva.overrideAttrs (prevAttrs: rec {
# version = "1.24.9";
# src = prev.fetchurl {
# url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
# hash = "sha256-MmgumuUI7gH0+xNLOlIAgeKsAHIgmXV3YksdFhcdRWw=";
# };
# });
gst-plugins-rs = prev.gst_all_1.gst-plugins-rs.override {
withGtkPlugins = false;
};
# gst-plugins-ugly = prev.gst_all_1.gst-plugins-ugly.overrideAttrs (prevAttrs: rec {
# version = "1.24.9";
# src = prev.fetchurl {
# url = "https://gstreamer.freedesktop.org/src/${prevAttrs.pname}/${prevAttrs.pname}-${version}.tar.xz";
# hash = "sha256-S2swEQ84zQXrZ0IilxQrdaVf4AADEF9IsTYD5nYcw7Y=";
# };
# });
};
gtk3 = prev.gtk3.override {
broadwaySupport = false;
Expand Down Expand Up @@ -127,72 +148,75 @@
"ac_cv_va_copy=1"
];
});
# Use a newer version and add PipeWire GStreamer plugin.
mopidy = prev.python3Packages.buildPythonApplication rec {
pname = "mopidy";
pyproject = true;
version = "4.0.0a1";

src = prev.fetchFromGitHub {
owner = "mopidy";
repo = "mopidy";
rev = "refs/tags/v${version}";
hash = "sha256-+YjiAysDVfuEpohcWMU5he8yp1tr/g4aLxqrKuhrjWY=";
};

patches = [
./0001-Use-playbin3.patch
./0002-Use-decodebin3.patch
];
# todo Fix this so that it actually gets used as part of the service...
mopidyPackages = prev.mopidyPackages // {
# Use a newer version and add PipeWire GStreamer plugin.
mopidy = prev.python3Packages.buildPythonApplication rec {
pname = "mopidy";
pyproject = true;
version = "4.0.0a1";

src = prev.fetchFromGitHub {
owner = "mopidy";
repo = "mopidy";
rev = "refs/tags/v${version}";
hash = "sha256-+YjiAysDVfuEpohcWMU5he8yp1tr/g4aLxqrKuhrjWY=";
};

build-system = with prev.python3Packages; [
setuptools
setuptools-scm
];
patches = [
./0001-Use-playbin3.patch
./0002-Use-decodebin3.patch
];

nativeBuildInputs = [ prev.wrapGAppsNoGuiHook ];
build-system = with prev.python3Packages; [
setuptools
setuptools-scm
];

propagatedNativeBuildInputs = [
prev.gobject-introspection
];
nativeBuildInputs = [ prev.wrapGAppsNoGuiHook ];

propagatedBuildInputs = [
prev.gobject-introspection
];
propagatedNativeBuildInputs = [
prev.gobject-introspection
];

buildInputs =
with final.gst_all_1;
[
gst-plugins-bad
gst-plugins-base
gst-plugins-good
gst-plugins-ugly
gst-plugins-rs
]
++ [
prev.glib-networking
prev.pipewire
propagatedBuildInputs = [
prev.gobject-introspection
];

dependencies = with prev.python3Packages; [
gst-python
pygobject3
pykka
requests
setuptools
tornado
];
buildInputs =
with final.gst_all_1;
[
gst-plugins-bad
gst-plugins-base
gst-plugins-good
gst-plugins-ugly
gst-plugins-rs
]
++ [
prev.glib-networking
prev.pipewire
];

dependencies = with prev.python3Packages; [
gst-python
pygobject3
pykka
requests
setuptools
tornado
];

# There are no tests
doCheck = false;
# There are no tests
doCheck = false;

meta = {
homepage = "https://www.mopidy.com/";
description = "Extensible music server that plays music from local disk, Spotify, SoundCloud, and more";
mainProgram = "mopidy";
license = with prev.lib.licenses; [ asl20 ];
maintainers = with prev.lib.maintainers; [ fpletz ];
hydraPlatforms = [ ];
meta = {
homepage = "https://www.mopidy.com/";
description = "Extensible music server that plays music from local disk, Spotify, SoundCloud, and more";
mainProgram = "mopidy";
license = with prev.lib.licenses; [ asl20 ];
maintainers = with prev.lib.maintainers; [ fpletz ];
hydraPlatforms = [ ];
};
};
};
nushell = prev.nushell.override {
Expand Down

0 comments on commit 511b7da

Please sign in to comment.