From ddf2fa899aed56089c62e38c7898df0ccb05f221 Mon Sep 17 00:00:00 2001 From: Isidor Zeuner Date: Wed, 13 Dec 2023 12:36:15 +0100 Subject: [PATCH] haskellPackages.PortMidi: fix ALSA plugins load path --- .../haskell-modules/configuration-common.nix | 10 ++++++ .../patches/portmidi-alsa-plugins.patch | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 pkgs/development/haskell-modules/patches/portmidi-alsa-plugins.patch diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 833d85d2ddd3..2bb4df2708ac 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -1318,6 +1318,16 @@ self: super: { testToolDepends = (drv.testToolDepends or []) ++ [pkgs.postgresql]; }) super.beam-postgres; + # PortMidi needs an environment variable to have ALSA find its plugins: + # https://github.com/NixOS/nixpkgs/issues/6860 + PortMidi = overrideCabal (drv: { + patches = (drv.patches or []) ++ [ ./patches/portmidi-alsa-plugins.patch ]; + postPatch = (drv.postPatch or "") + '' + substituteInPlace portmidi/pm_linux/pmlinuxalsa.c \ + --replace @alsa_plugin_dir@ "${pkgs.alsa-plugins}/lib/alsa-lib" + ''; + }) super.PortMidi; + # Fix for base >= 4.11 scat = overrideCabal (drv: { patches = [(fetchpatch { diff --git a/pkgs/development/haskell-modules/patches/portmidi-alsa-plugins.patch b/pkgs/development/haskell-modules/patches/portmidi-alsa-plugins.patch new file mode 100644 index 000000000000..13860b7cfb7f --- /dev/null +++ b/pkgs/development/haskell-modules/patches/portmidi-alsa-plugins.patch @@ -0,0 +1,31 @@ +diff -Naurd PortMidi-0.2.0.0/portmidi/pm_linux/pmlinuxalsa.c PortMidi-0.2.0.0-alsafix/portmidi/pm_linux/pmlinuxalsa.c +--- PortMidi-0.2.0.0/portmidi/pm_linux/pmlinuxalsa.c 2023-12-13 11:35:12.517413022 +0000 ++++ PortMidi-0.2.0.0-alsafix/portmidi/pm_linux/pmlinuxalsa.c 2023-12-13 11:35:12.565413037 +0000 +@@ -719,6 +719,18 @@ + } + + ++static void set_alsa_plugin_path( void ) ++{ ++ char *existing; ++ ++ existing = getenv("ALSA_PLUGIN_DIR"); ++ if (NULL != existing) { ++ return; ++ } ++ setenv("ALSA_PLUGIN_DIR", "@alsa_plugin_dir@", 0); ++} ++ ++ + PmError pm_linuxalsa_init( void ) + { + int err; +@@ -726,6 +738,8 @@ + snd_seq_port_info_t *pinfo; + unsigned int caps; + ++ set_alsa_plugin_path(); ++ + /* Previously, the last parameter was SND_SEQ_NONBLOCK, but this + * would cause messages to be dropped if the ALSA buffer fills up. + * The correct behavior is for writes to block until there is