Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkgs/by-name/ta/tauon/install_mode_true.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/src/tauon/__main__.py b/src/tauon/__main__.py
index 04691586..e48afa02 100755
--- a/src/tauon/__main__.py
+++ b/src/tauon/__main__.py
@@ -115,8 +115,8 @@ def transfer_args_and_exit() -> None:
if "--no-start" in sys.argv:
transfer_args_and_exit()

-# If we're installed, use home data locations
-install_mode = bool(str(install_directory).startswith(("/opt/", "/usr/", "/app/", "/snap/")) or sys.platform in ("darwin", "win32"))
+# Nixpkgs install, use home data dirs.
+install_mode = True

# Assume that it's a classic Linux install, use standard paths
if str(install_directory).startswith("/usr/") and Path("/usr/share/TauonMusicBox").is_dir():
47 changes: 34 additions & 13 deletions pkgs/by-name/ta/tauon/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
stdenv,
fetchFromGitHub,
fetchPypi,
kissfft,
miniaudio,
pkg-config,
Expand All @@ -16,6 +17,7 @@
librsvg,
libsamplerate,
libvorbis,
xorg,
mpg123,
opusfile,
pango,
Expand All @@ -26,16 +28,32 @@
withDiscordRPC ? true,
}:

let
# fork of pypresence, to be reverted if/when there's an upstream release
lynxpresence = python3Packages.buildPythonPackage rec {
pname = "lynxpresence";
version = "4.4.1";
format = "setuptools";

src = fetchPypi {
inherit pname version;
hash = "sha256-y/KboyhEGs9RvyKayEIQu2+WaiQNOdsHDl1/pEoqEkQ=";
};

doCheck = false; # tests require internet connection
pythonImportsCheck = [ "lynxpresence" ];
};
in
python3Packages.buildPythonApplication rec {
pname = "tauon";
version = "7.9.0";
version = "8.0.1";
pyproject = true;

src = fetchFromGitHub {
owner = "Taiko2k";
repo = "Tauon";
tag = "v${version}";
hash = "sha256-6aEUniLoE5Qtfht3OAe+zvC9yZwjH+KpskmjGowDuuU=";
hash = "sha256-m94/zdlJu/u/dchIXhqB47bkl6Uej2hVr8R6RNg8Vaw=";
};

postUnpack = ''
Expand All @@ -46,16 +64,16 @@ python3Packages.buildPythonApplication rec {
ln -s ${miniaudio.src} source/src/phazor/miniaudio
'';

postPatch = ''
substituteInPlace src/tauon/__main__.py \
--replace-fail 'install_mode = False' 'install_mode = True'
patches = [
./install_mode_true.patch
];

postPatch = ''
substituteInPlace src/tauon/t_modules/t_phazor.py \
--replace-fail 'base_path = Path(pctl.install_directory).parent.parent / "build"' 'base_path = Path("${placeholder "out"}/${python3Packages.python.sitePackages}")'
'';

pythonRemoveDeps = [
"pysdl2-dll"
"opencc"
"tekore"
];
Expand Down Expand Up @@ -105,23 +123,26 @@ python3Packages.buildPythonApplication rec {
pychromecast
pylast
pygobject3
pysdl2
pysdl3
requests
send2trash
setproctitle
tidalapi
]
++ lib.optional withDiscordRPC pypresence
++ lib.optional withDiscordRPC lynxpresence
++ lib.optional stdenv.hostPlatform.isLinux pulsectl;

makeWrapperArgs = [
"--prefix PATH : ${lib.makeBinPath [ ffmpeg ]}"
"--prefix LD_LIBRARY_PATH : ${
lib.makeLibraryPath [
game-music-emu
libopenmpt
pulseaudio
]
lib.makeLibraryPath (
[
game-music-emu
libopenmpt
pulseaudio
]
++ lib.optional stdenv.hostPlatform.isLinux xorg.libXcursor
)
}"
"--prefix PYTHONPATH : $out/share/tauon"
"--set GI_TYPELIB_PATH $GI_TYPELIB_PATH"
Expand Down
102 changes: 102 additions & 0 deletions pkgs/development/python-modules/pysdl3/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
stdenv,
lib,
fetchurl,
fetchFromGitHub,
python,
buildPythonPackage,
setuptools-scm,
packaging,
aiohttp,
requests,

# native dependencies
sdl3,
sdl3-ttf,
sdl3-image,
}:

let
dochash =
if stdenv.hostPlatform.isLinux then
"sha256-+1zLd308zL+m68kLMeOWWxT0wYDgCd6g9cc2hEtaeUs="
else if stdenv.hostPlatform.isDarwin then
"sha256-2uB9+ABgv5O376LyHb0ShGjM4LHYzMRMxk/k+1LBmv0="
else if stdenv.hostPlatform.isWindows then
"sha256-46bQSPYctycizf2GXichd5V74LjxwIAPhBmklXAJ/Jg="
else
throw "PySDL3 does not support ${stdenv.hostPlatform.uname.system}";
lib_ext = stdenv.hostPlatform.extensions.sharedLibrary;
in
buildPythonPackage rec {
pname = "pysdl3";
version = "0.9.8b1";
pyproject = true;

pythonImportsCheck = [ "sdl3" ];

src = fetchFromGitHub {
owner = "Aermoss";
repo = "PySDL3";
tag = "v${version}";
hash = "sha256-FVUCcqKTq6qdNkYHTYFiUxt2HIaNC5LK0BEUfz8Mue8=";
};

docfile = fetchurl {
url = "https://github.com/Aermoss/PySDL3/releases/download/v${version}/${stdenv.hostPlatform.uname.system}-Docs.py";
hash = "${dochash}";
};
Comment on lines +45 to +48
Copy link
Copy Markdown
Member

@pbsds pbsds May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than fetching this generated asset, please generate it in the derivation if possible. The procedure seems to be in https://github.com/Aermoss/PySDL3/blob/main/.github/workflows/generate_docs.yml.

If we do have to fetch it, then we should set meta.sourceProvenance accordingly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generator attempts to first download the file from the github release so that would not really change anything. If downloading it from the github release fails, it starts scraping docs from libsdl.org which I'm also not a huge fan of (it mostly seems like a great way to get our CI machines IP blocked these days).

Ideally we'd generate the docs from our own SDL3 build. I was going to propose supporting that case to upstream but didn't manage to get nixpkgs SDL3 to generate its documentation...

Copy link
Copy Markdown
Member

@pbsds pbsds May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like a big can of worms, i'm not against fetching it in the meanwhile 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What shoud meta.sourceProvenance be set to in this case? binaryBytecode?


postUnpack = ''
cp ${docfile} source/sdl3/__doc__.py
'';

postInstall = ''
mkdir $out/${python.sitePackages}/sdl3/bin
ln -s ${sdl3}/lib/libSDL3${lib_ext} -t $out/${python.sitePackages}/sdl3/bin
ln -s ${sdl3-ttf}/lib/libSDL3_ttf${lib_ext} -t $out/${python.sitePackages}/sdl3/bin
ln -s ${sdl3-image}/lib/libSDL3_image${lib_ext} -t $out/${python.sitePackages}/sdl3/bin
'';

build-system = [
setuptools-scm
];

buildInputs = [
sdl3
sdl3-ttf
sdl3-image
];

dependencies = [
packaging
aiohttp
requests
];

# PySDL3 tries to update both itself and SDL binaries at runtime. This hook
# sets some env variables to tell it not to do that.
setupHook = ./setup-hook.sh;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment above that explains the reason for this setupHook? Something like

Suggested change
setupHook = ./setup-hook.sh;
# PySDL3 downloads SDL binaries itself by default so we set env variables to make it use the ones from nixpkgs
# See https://pysdl3.readthedocs.io/en/latest/install.html#the-environment-variable-method
setupHook = ./setup-hook.sh;


env = {
SDL_VIDEODRIVER = "dummy";
SDL_AUDIODRIVER = "dummy";
SDL_RENDER_DRIVER = "software";
PYTHONFAULTHANDLER = "1";
};

meta = {
description = "Pure Python wrapper for SDL3";
homepage = "https://github.com/Aermoss/PySDL3";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ jansol ];
Comment thread
jansol marked this conversation as resolved.
Outdated
platforms = [
"aarch64-linux"
"x86_64-linux"
"aarch64-windows"
"x86_64-windows"
"aarch64-darwin"
"x86_64-darwin"
];
};
}
10 changes: 10 additions & 0 deletions pkgs/development/python-modules/pysdl3/setup-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See also
# https://pysdl3.readthedocs.io/en/latest/install.html#the-environment-variable-method

# Don't check Pypi for new PySDL3 releases at runtime
export SDL_CHECK_VERSION=0
Comment thread
pbsds marked this conversation as resolved.
Outdated
# Don't try to download SDL binaries at runtime
export SDL_DOWNLOAD_BINARIES=0
# Nixpkgs does not provide a metadata.json. Instead we want PySDL3 to find the
# SDL libraries we symlink into its site-packages
export SDL_DISABLE_METADATA=1
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13333,6 +13333,8 @@ self: super: with self; {

pysdl2 = callPackage ../development/python-modules/pysdl2 { };

pysdl3 = callPackage ../development/python-modules/pysdl3 { };

pysearpc = toPythonModule (pkgs.libsearpc.override { python3 = self.python; });

pysecretsocks = callPackage ../development/python-modules/pysecretsocks { };
Expand Down