diff --git a/hosts/common/programs/mpv/default.nix b/hosts/common/programs/mpv/default.nix index 885ab09b9..22877b413 100644 --- a/hosts/common/programs/mpv/default.nix +++ b/hosts/common/programs/mpv/default.nix @@ -41,7 +41,6 @@ let cfg = config.sane.programs.mpv; - myHrtf = "${pkgs.sofacoustics.listen.irc_1052}/share/sofa/listen-irc_1052.sofa"; uosc = pkgs.mpvScripts.uosc.overrideAttrs (upstream: { version = "5.2.0-unstable-2024-03-13"; src = lib.warnIf (lib.versionOlder "5.2.0" upstream.version) "uosc outdated; remove patch?" pkgs.fetchFromGitHub { @@ -138,6 +137,11 @@ let }); in { + sane.programs.sofa-default = { + packageUnwrapped = pkgs.sofacoustics.listen.irc_1052.asDefault; + sandbox.enable = false; #< data only + }; + sane.programs.mpv = { packageUnwrapped = pkgs.mpv-unwrapped.wrapper { mpv = pkgs.mpv-unwrapped.override rec { @@ -195,6 +199,7 @@ in "sane-cast" "sane-die-with-parent" "xdg-terminal-exec" + "sofa-default" ]; sandbox.method = "bwrap"; @@ -227,7 +232,6 @@ in fs.".config/mpv/scripts/sane_cast/main.lua".symlink.target = ./sane_cast/main.lua; fs.".config/mpv/scripts/sane_sysvol/main.lua".symlink.target = ./sane_sysvol/main.lua; fs.".config/mpv/scripts/sane_sysvol/non_blocking_popen.lua".symlink.target = ./sane_sysvol/non_blocking_popen.lua; - fs.".config/mpv/hrtf.sofa".symlink.target = myHrtf; fs.".config/mpv/input.conf".symlink.target = ./input.conf; fs.".config/mpv/mpv.conf".symlink.target = ./mpv.conf; fs.".config/mpv/script-opts/osc.conf".symlink.target = ./osc.conf; @@ -257,5 +261,9 @@ in #v Loupe image viewer can't open URIs, so use mpv instead mime.urlAssociations."^https?://i\.imgur.com/.+" = "mpv.desktop"; }; + + environment.pathsToLink = lib.mkIf cfg.enabled [ + "/share/libmysofa" + ]; } diff --git a/hosts/common/programs/mpv/mpv.conf b/hosts/common/programs/mpv/mpv.conf index eebb09888..2ff73873e 100644 --- a/hosts/common/programs/mpv/mpv.conf +++ b/hosts/common/programs/mpv/mpv.conf @@ -32,4 +32,4 @@ border=no # see: # TODO: this maybe belongs in pipewire instead of mpv. # at least, provide a way to disable the downmixing, so i can still output 5.1 over HDMI? -af=sofalizer=sofa=/home/colin/.config/mpv/hrtf.sofa +af=sofalizer=sofa=/etc/profiles/per-user/colin/share/libmysofa/default.sofa:gain=11 diff --git a/pkgs/additional/sofacoustics/default.nix b/pkgs/additional/sofacoustics/default.nix index db246f8d6..d5a7d3b68 100644 --- a/pkgs/additional/sofacoustics/default.nix +++ b/pkgs/additional/sofacoustics/default.nix @@ -3,11 +3,12 @@ lib, newScope, nix-update-script, + runCommandLocal, stdenvNoCC, symlinkJoin, }: lib.makeScope newScope (self: with self; { - downloadSofacoustics = prefix: database: name: hash: stdenvNoCC.mkDerivation { + downloadSofacoustics = prefix: database: name: hash: stdenvNoCC.mkDerivation (finalAttrs: { name = "${database}-${name}"; src = fetchurl { url = "${prefix}${name}.sofa"; @@ -17,8 +18,8 @@ lib.makeScope newScope (self: with self; { dontUnpack = true; installPhase = '' - mkdir -p $out/share/sofa - cp $src $out/share/sofa/${database}-${name}.sofa + mkdir -p $out/share/libmysofa + cp $src $out/share/libmysofa/${database}-${name}.sofa ''; doBuild = false; @@ -27,7 +28,11 @@ lib.makeScope newScope (self: with self; { passthru.updateScript = nix-update-script { extraArgs = [ "--version" "skip" ]; }; - }; + passthru.asDefault = runCommandLocal "${database}-${name}-as-default" {} '' + mkdir -p $out/share/libmysofa + ln -s "${finalAttrs.finalPackage}/share/libmysofa/${database}-${name}.sofa" $out/share/libmysofa/default.sofa + ''; + }); ari = lib.recurseIntoAttrs (lib.mapAttrs (downloadSofacoustics "https://sofacoustics.org/data/database/ari/hrtf%20" "ari") { # in-the-ear measurements from real human subjects, complete with detailed anthropometric data.