Overriding Jellyfin package to make addon usable

There’s an extension for Jellyfin called intro-skipper. This extension relies upon being able to inject a script tag into jellyfin-web’s index.html. Unfortunately this doesn’t work since the jellyfin-web files are in the readonly nix store.

According to this nixpkgs thread, it’s possible to override the package to change index.html before it’s copied to $out.

I also theorized that it’s possible to copy jellyfin-web out of the store and override the jellyfin package to use the new location. I’ve attempted to do this because I thought it would be more flexible with potential future extensions:

jellyfin-web-injectable = pkgs.jellyfin-web.overrideAttrs (oldAttrs: {
    installPhase = ''
      runHook preInstall

      mkdir -p $out/share
      cp -a dist $out/share/jellyfin-web

      mkdir -p /var/lib/jellyfin-web # dies here due to permission issues
      cp $out/share/jellyfin-web /var/lib/jellyfin-web
      chown -R jellyfin:jellyfin /var/lib/jellyfin-web

      runHook postInstall
    '';
  });

  jellfin-injectable = pkgs.jellfin.overrideAttrs (oldAttrs: {
    preInstall = ''
      makeWrapperArgs+=(
        --add-flags "--ffmpeg ${ffmpeg}/bin/ffmpeg" # dies here since ${ffmpeg} can't be found
        --add-flags "--webdir /var/lib/jellyfin-web"
      )
    '';
  });

However it fails in the two places I added comments. At this point I’m fine using either method; I just want it to work. Could someone help me either fix my attempt or assist with how to override an individual file in a package?