From b0e56fb99b48060a7c39bef8021efeca45adb22f Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Sun, 13 Jul 2025 20:03:23 -0400 Subject: [PATCH] tg-timer: init at 0.7.0 --- pkgs/by-name/tg/tg-timer/audio.patch | 18 +++++++ pkgs/by-name/tg/tg-timer/package.nix | 74 ++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 pkgs/by-name/tg/tg-timer/audio.patch create mode 100644 pkgs/by-name/tg/tg-timer/package.nix diff --git a/pkgs/by-name/tg/tg-timer/audio.patch b/pkgs/by-name/tg/tg-timer/audio.patch new file mode 100644 index 000000000000..8f78190b85b9 --- /dev/null +++ b/pkgs/by-name/tg/tg-timer/audio.patch @@ -0,0 +1,18 @@ +diff --git a/src/audio.c b/src/audio.c +index d1b9762..cb544dd 100644 + +This package assumes that there will always be an audio device while testing. +If there is not an audio device, it segfaults. So in the Nix sandbox, it +unconditionally segfaults without this patch. This patch allows the tests +to flow through the normal error handling logic. + +--- a/src/audio.c ++++ b/src/audio.c +@@ -637,7 +637,6 @@ int start_portaudio(int device, int *nominal_sample_rate, double *real_sample_ra + if(testing) { + *nominal_sample_rate = PA_SAMPLE_RATE; + *real_sample_rate = PA_SAMPLE_RATE; +- goto end; + } + #endif + diff --git a/pkgs/by-name/tg/tg-timer/package.nix b/pkgs/by-name/tg/tg-timer/package.nix new file mode 100644 index 000000000000..ab41af1a0bd5 --- /dev/null +++ b/pkgs/by-name/tg/tg-timer/package.nix @@ -0,0 +1,74 @@ +{ + lib, + stdenv, + fetchFromGitHub, + # Configure + autoreconfHook, + # Build binaries + pkg-config, + # Build libraries + gtk3, + portaudio, + fftwFloat, + libjack2, + python3, + # Check Binaries + xvfb-run, +}: +stdenv.mkDerivation (finalAttrs: { + pname = "tg-timer"; + version = "0.7.0"; + + src = fetchFromGitHub { + owner = "xyzzy42"; + repo = "tg"; + tag = "v${finalAttrs.version}-tpiepho"; + hash = "sha256-9QeTjr/J0Y10YfPKEfYnciu5z2+hmmWFKLdw6CCS3hU="; + }; + + patches = [ + ./audio.patch + ]; + + nativeBuildInputs = [ + autoreconfHook + pkg-config + ]; + + buildInputs = [ + gtk3 + portaudio + fftwFloat + libjack2 + (python3.withPackages (p: [ + p.numpy + p.matplotlib + p.libtfr + p.scipy + ])) + ]; + + enableParallelBuilding = true; + + doCheck = true; + nativeCheckInputs = [ + xvfb-run + ]; + checkPhase = '' + runHook preCheck + + xvfb-run -s '-screen 0 800x600x24' \ + make -j "$NIX_BUILD_CORES" test + + runHook postCheck + ''; + + meta = { + description = "for timing mechanical watches"; + homepage = "https://github.com/xyzzy42/tg"; + changelog = "https://github.com/xyzzy42/tg/releases/tag/v${finalAttrs.version}-tpiepho"; + license = lib.licenses.gpl2Plus; + mainProgram = "tg"; + maintainers = with lib.maintainers; [ RossSmyth ]; + }; +})