Skip to content

Commit

Permalink
bencodetools,uade: Fix build, update, modernise (NixOS#352867)
Browse files Browse the repository at this point in the history
  • Loading branch information
OPNA2608 authored Nov 16, 2024
2 parents fbd28d1 + 35a5b60 commit 2f3db1d
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 67 deletions.
41 changes: 25 additions & 16 deletions pkgs/by-name/be/bencodetools/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,51 @@
stdenv,
lib,
fetchFromGitLab,
python3,
gitUpdater,
python3Packages,
}:

stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "bencodetools";
version = "unstable-2022-05-11";
version = "1.0.1";

src = fetchFromGitLab {
owner = "heikkiorsila";
repo = "bencodetools";
rev = "384d78d297a561dddbbd0f4632f0c74c0db41577";
sha256 = "1d699q9r33hkmmqkbh92ax54mcdf9smscmc0dza2gp4srkhr83qm";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-5Y1r6+aVtK22lYr2N+YUPPdUts9PIF9I/Pq/mI+WqQs=";
};

postPatch = ''
patchShebangs configure
substituteInPlace configure \
--replace 'python_install_option=""' 'python_install_option="--prefix=$out"'
'';

enableParallelBuilding = true;

nativeBuildInputs = [
(python3.withPackages (ps: with ps; [ distutils ]))
];
configureFlags = [ (lib.strings.withFeature false "python") ];

# installCheck instead of check due to -install_name'd library on Darwin
doInstallCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
installCheckTarget = "check";

meta = with lib; {
installCheckPhase = ''
runHook preInstallCheck
./bencodetest
runHook postInstallCheck
'';

passthru = {
tests.python-module = python3Packages.bencodetools;
updateScript = gitUpdater { rev-prefix = "v"; };
};

meta = {
description = "Collection of tools for manipulating bencoded data";
homepage = "https://gitlab.com/heikkiorsila/bencodetools";
license = licenses.bsd2;
maintainers = with maintainers; [ OPNA2608 ];
license = lib.licenses.bsd2;
maintainers = with lib.maintainers; [ OPNA2608 ];
mainProgram = "bencat";
platforms = platforms.unix;
platforms = lib.platforms.unix;
};
}
})
58 changes: 58 additions & 0 deletions pkgs/by-name/li/libzakalwe/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
stdenv,
lib,
fetchFromGitLab,
unstableGitUpdater,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "libzakalwe";
version = "1.0.0-unstable-2024-02-26";

src = fetchFromGitLab {
owner = "hors";
repo = "libzakalwe";
rev = "c7eba014ba14dc6fa145f6e71e75cca2b65bbc8a";
hash = "sha256-2a30ztFnemCgGW/I5S6Dz4eC1Y6K2aV9dPvysvQtBxo=";
};

outputs = [
"out"
"dev"
];

postPatch =
''
substituteInPlace Makefile.in \
--replace-fail 'libzakalwe.so' "libzakalwe${stdenv.hostPlatform.extensions.sharedLibrary}"
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace Makefile.in \
--replace-fail '-soname' '-install_name'
'';

strictDeps = true;

enableParallelBuilding = true;

env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-D_DARWIN_C_SOURCE";

# Darwin: Assertion failed at thread_util_test_0:52: tr != NULL
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform && (!stdenv.hostPlatform.isDarwin);

installFlags = [ "PREFIX=$(out)" ];

preInstall = ''
mkdir -p $out/lib
'';

passthru.updateScript = unstableGitUpdater { tagPrefix = "v"; };

meta = {
description = "Library for functions shared across zakalwe projects";
homepage = "https://gitlab.com/hors/libzakalwe";
license = lib.licenses.bsd2;
maintainers = with lib.maintainers; [ OPNA2608 ];
platforms = lib.platforms.unix;
};
})
100 changes: 49 additions & 51 deletions pkgs/by-name/ua/uade/package.nix
Original file line number Diff line number Diff line change
@@ -1,73 +1,64 @@
{ lib
, stdenv
, fetchFromGitLab
, python3
, pkg-config
, which
, makeWrapper
, libao
, bencodetools
, sox
, lame
, flac
, vorbis-tools
# https://gitlab.com/uade-music-player/uade/-/issues/38
, withWriteAudio ? !stdenv.hostPlatform.isDarwin
{
lib,
stdenv,
fetchFromGitLab,
gitUpdater,
bencodetools,
flac,
lame,
libao,
libzakalwe,
makeWrapper,
python3,
pkg-config,
sox,
vorbis-tools,
which,
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "uade";
version = "3.02";
version = "3.05";

src = fetchFromGitLab {
owner = "uade-music-player";
repo = "uade";
rev = "uade-${version}";
hash = "sha256-skPEXBQwyr326zCmZ2jwGxcBoTt3Y/h2hagDeeqbMpw=";
rev = "uade-${finalAttrs.version}";
hash = "sha256-k6t8EQ/G8PbfRrBMXubn1XfBPvw1qDoMGh5xJKrcX+E=";
};

postPatch = ''
patchShebangs configure
substituteInPlace configure \
--replace 'PYTHON_SETUP_ARGS=""' 'PYTHON_SETUP_ARGS="--prefix=$out"'
substituteInPlace src/frontends/mod2ogg/mod2ogg2.sh.in \
--replace '-e stat' '-n stat' \
--replace '/usr/local' "$out"
--replace-fail '-e stat' '-n stat' \
--replace-fail '/usr/local' "$out"
substituteInPlace python/uade/generate_oscilloscope_view.py \
--replace "default='uade123'" "default='$out/bin/uade123'"
# https://gitlab.com/uade-music-player/uade/-/issues/37
substituteInPlace write_audio/Makefile.in \
--replace 'g++' '${stdenv.cc.targetPrefix}c++'
--replace-fail "default='uade123'" "default='$out/bin/uade123'"
'';

nativeBuildInputs = [
makeWrapper
pkg-config
which
makeWrapper
] ++ lib.optionals withWriteAudio [
python3
];

buildInputs = [
libao
bencodetools
sox
lame
flac
lame
libao
libzakalwe
sox
vorbis-tools
] ++ lib.optionals withWriteAudio [
(python3.withPackages (p: with p; [
pillow
tqdm
more-itertools
]))
];

configureFlags = [
"--bencode-tools-prefix=${bencodetools}"
"--with-text-scope"
] ++ lib.optionals (!withWriteAudio) [
"--without-write-audio"
"--libzakalwe-prefix=${libzakalwe}"
(lib.strings.withFeature true "text-scope")
(lib.strings.withFeature false "write-audio")
];

enableParallelBuilding = true;
Expand All @@ -76,24 +67,31 @@ stdenv.mkDerivation rec {

postInstall = ''
wrapProgram $out/bin/mod2ogg2.sh \
--prefix PATH : $out/bin:${lib.makeBinPath [ sox lame flac vorbis-tools ]}
--prefix PATH : $out/bin:${
lib.makeBinPath [
flac
lame
sox
vorbis-tools
]
}
# This is an old script, don't break expectations by renaming it
ln -s $out/bin/mod2ogg2{.sh,}
'' + lib.optionalString withWriteAudio ''
wrapProgram $out/bin/generate_amiga_oscilloscope_view \
--prefix PYTHONPATH : "$PYTHONPATH:$out/${python3.sitePackages}"
'';

meta = with lib; {
passthru.updateScript = gitUpdater { rev-prefix = "uade-"; };

meta = {
description = "Plays old Amiga tunes through UAE emulation and cloned m68k-assembler Eagleplayer API";
homepage = "https://zakalwe.fi/uade/";
# It's a mix of licenses. "GPL", Public Domain, "LGPL", GPL2+, BSD, LGPL21+ and source code with unknown licenses. E.g.
# - hippel-coso player is "[not] under any Open Source certified license"
# - infogrames player is disassembled from Andi Silvas player, unknown license
# Let's make it easy and flag the whole package as unfree.
license = licenses.unfree;
maintainers = with maintainers; [ OPNA2608 ];
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [ OPNA2608 ];
mainProgram = "uade123";
platforms = platforms.unix;
platforms = lib.platforms.unix;
};
}
})
30 changes: 30 additions & 0 deletions pkgs/development/python-modules/bencodetools/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
buildPythonPackage,
bencodetools,
pytestCheckHook,
setuptools,
}:
buildPythonPackage {
inherit (bencodetools) pname version src;
format = "pyproject";

nativeBuildInputs = [ setuptools ];

nativeCheckInputs = [ pytestCheckHook ];

dontConfigure = true;

pythonImportsCheck = [
"bencode"
"typevalidator"
];

meta = {
inherit (bencodetools.meta)
description
homepage
license
maintainers
;
};
}
4 changes: 4 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,10 @@ self: super: with self; {

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

bencodetools = callPackage ../development/python-modules/bencodetools {
bencodetools = pkgs.bencodetools;
};

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

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

0 comments on commit 2f3db1d

Please sign in to comment.