Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs-ndi does not build #219578

Closed
Zahrun opened this issue Mar 4, 2023 · 14 comments
Closed

obs-ndi does not build #219578

Zahrun opened this issue Mar 4, 2023 · 14 comments

Comments

@Zahrun
Copy link
Contributor

Zahrun commented Mar 4, 2023

Describe the bug

obs-ndi does not build

Steps To Reproduce

Steps to reproduce the behavior:

  1. Add to configuration.nix:
(wrapOBS {
      plugins = with obs-studio-plugins; [
        obs-ndi
      ];
    })
  1. Comply with NewTek's license and download the appropriate Linux tarball from: https://ndi.tv/sdk/
  2. nix-prefetch-url file://$PWD/Install_NDI_SDK_v5_Linux.tar.gz
  3. nixos-rebuild switch

Expected behavior

obs-ndi builds

Current behavior

Console log
[:~/Downloads] 27s % du Install_NDI_SDK_v5_Linux.tar.gz 53240 Install_NDI_SDK_v5_Linux.tar.gz [:~/Downloads] % sha256sum Install_NDI_SDK_v5_Linux.tar.gz 00d0bedc2c72736d82883fc0fd6bc1a544e7958c7e46db79f326633d44e15153 Install_NDI_SDK_v5_Linux.tar.gz [:~/Downloads] % nix-prefetch-url file://$PWD/Install_NDI_SDK_v5_Linux.tar.gz path is '/nix/store/20kyvmkc9shd673fxy1rgddjg04fqv4n-Install_NDI_SDK_v5_Linux.tar.gz' 0lsiw523sqr6ydwxnikyijayfi55q5mzvh1zi216swvj5kfbxl00 [:~/Downloads] % nixos-rebuild switch building Nix... building the system configuration... these 17 derivations will be built: /nix/store/y7vda101cq3l5xgys39px2ak33s6n84c-Install_NDI_SDK_v5_Linux.tar.gz.drv /nix/store/69zmj9sikwgapvn16bqz9ajpnr9j3grd-ndi-5.5.2.drv /nix/store/hb337jfbqilabs9iqm9pajxsxawcya25-source.drv /nix/store/z7ks25k55j9aqdmwml1p065aw6ldcajb-obs-ndi-4.10.0.drv /nix/store/s8phb72yk7gkihqzdpgd2vk5dp311x2h-obs-studio-plugins.drv /nix/store/mrlcmihb41v1bab7svcd6j4ada8hl5lr-wrapped-obs-studio-28.1.2.drv /nix/store/sp0hgyg9nmspv2zgkgpkff7jdjlvarzx-system-path.drv /nix/store/7w5ai9rvl2fildhczn308m3jq0gbsq5y-dbus-1.drv /nix/store/akrvdv6bbgp52sicvnvlcxwbavzv6rpn-unit-dbus.service.drv /nix/store/das8y7njmgi896pn1zgv7zzsr3hhgdcp-unit-systemd-fsck-.service.drv /nix/store/hmakp0h9nf9wydmqq09zy92lagx3z312-unit-accounts-daemon.service.drv /nix/store/vvk6y5xm7ml0cr4wj53wxrr624d31s42-unit-polkit.service.drv /nix/store/s6d5yylbb8cjgzwk6vyzk9kfv7vx5as5-system-units.drv /nix/store/qnwqip8x7iv5jg6kfv8mja2x6nz9zlvg-unit-dbus.service.drv /nix/store/z0f36rann9f34nfa1f3g5s5lji8y7y1q-user-units.drv /nix/store/qp70nx54x8kj7vbxzsxcmkq9n8nnk3iw-etc.drv /nix/store/j7aqkpv7nqx1jlhykk2q0k34yrdaa1r1-nixos-system-nixos-22.11.2939.96e18717904.drv this path will be fetched (0.04 MiB download, 0.24 MiB unpacked): /nix/store/972c7mk1s1q5ci4wx7mk361m345ki01q-curl-7.86.0-dev copying path '/nix/store/972c7mk1s1q5ci4wx7mk361m345ki01q-curl-7.86.0-dev' from 'https://cache.nixos.org'... building '/nix/store/y7vda101cq3l5xgys39px2ak33s6n84c-Install_NDI_SDK_v5_Linux.tar.gz.drv'...

In order to use NDI SDK version 5.5.2, you need to comply with
NewTek's license and download the appropriate Linux tarball from:

https://ndi.tv/sdk/

Once you have downloaded the file, please use the following command and
re-run the installation:

$ nix-prefetch-url file://$PWD/Install_NDI_SDK_v5_Linux.tar.gz


error: builder for '/nix/store/y7vda101cq3l5xgys39px2ak33s6n84c-Install_NDI_SDK_v5_Linux.tar.gz.drv' failed with exit code 1;
last 10 log lines:
>
> https://ndi.tv/sdk/
>
> Once you have downloaded the file, please use the following command and
> re-run the installation:
>
> $ nix-prefetch-url file://$PWD/Install_NDI_SDK_v5_Linux.tar.gz
>
> ***
>
For full logs, run 'nix log /nix/store/y7vda101cq3l5xgys39px2ak33s6n84c-Install_NDI_SDK_v5_Linux.tar.gz.drv'.
error: 1 dependencies of derivation '/nix/store/69zmj9sikwgapvn16bqz9ajpnr9j3grd-ndi-5.5.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/z7ks25k55j9aqdmwml1p065aw6ldcajb-obs-ndi-4.10.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mrlcmihb41v1bab7svcd6j4ada8hl5lr-wrapped-obs-studio-28.1.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/sp0hgyg9nmspv2zgkgpkff7jdjlvarzx-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/j7aqkpv7nqx1jlhykk2q0k34yrdaa1r1-nixos-system-nixos-22.11.2939.96e18717904.drv' failed to build

Notify maintainers

@jshcmpbll

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.96, NixOS, 22.11 (Raccoon), 22.11.2939.96e18717904`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - channels(aroun): `""`
 - channels(root): `"nixos-22.11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@jshcmpbll
Copy link
Member

In the log nix spit out there is another one that says run 'nix log /nix/store/y7vda101cq3l5xgys39px2ak33s6n84c-Install_NDI_SDK_v5_Linux.tar.gz.drv'.

Its probably complaining somewhere that the version you installed from NDI doesnt match the version in nixpkgs. There has been a bug for a while that I eventually stopped tracking but looks like I can come back take a look about updating the version needed for OBS-NDI

If you want you could give this a go:

    (wrapOBS {
      plugins = with obs-studio-plugins; [ wlrobs obs-gstreamer obs-move-transition ] ++ (lib.optionals config.nixpkgs.config.allowUnfree [ (obs-ndi.override {
        ndi = ndi.overrideAttrs (attrs: rec {
          src = fetchurl {
            name = "${attrs.pname}-${attrs.version}.tar.gz";
            url = "https://downloads.ndi.tv/SDK/NDI_SDK_Linux/Install_NDI_SDK_v5_Linux.tar.gz";
            hash = "sha256-ANC+3Cxyc22CiD/A/WvBpUTnlYx+Rtt58yZjPUThUVM=";
          };

          unpackPhase = ''unpackFile ${src}; echo y | ./${attrs.installerName}.sh; sourceRoot="NDI SDK for Linux";'';
        });
      }) ]);
    })

@jshcmpbll
Copy link
Member

Also, if thats not what its complaining about can you please post the full log 😄

@Zahrun
Copy link
Contributor Author

Zahrun commented Mar 4, 2023

Hum, the full log is not very helpful

⌂14.11 [:~/Downloads] % nix log /nix/store/y7vda101cq3l5xgys39px2ak33s6n84c-Install_NDI_SDK_v5_Linux.tar.gz.drv

***
In order to use NDI SDK version 5.5.2, you need to comply with
NewTek's license and download the appropriate Linux tarball from:

  https://ndi.tv/sdk/

Once you have downloaded the file, please use the following command and
re-run the installation:

  $ nix-prefetch-url file://$PWD/Install_NDI_SDK_v5_Linux.tar.gz

***

⌂13.92 [:~/Downloads] %

However, the workaround that you gave works fine, thank you for that.

@jshcmpbll
Copy link
Member

jshcmpbll commented Mar 4, 2023

However, the workaround that you gave works fine, thank you for that.

Good to hear!

Just to double check, did you download the file manually and add it to the nix store like that error is saying? (just double checking, sorry for the silly question)

I think the NDI library derivation could use some improvements around pulling it for the user rather than having them do it themselves. Thats what the snippet I included above does.

@Zahrun
Copy link
Contributor Author

Zahrun commented Mar 4, 2023

I manually downloaded the file from the website, filling the form and all, then from my Downloads folder, ran nix-prefetch-url file://$PWD/Install_NDI_SDK_v5_Linux.tar.gz does that add it to the store?
You can see in the log it gave this output

:~/Downloads] % nix-prefetch-url file://$PWD/Install_NDI_SDK_v5_Linux.tar.gz path is '/nix/store/20kyvmkc9shd673fxy1rgddjg04fqv4n-Install_NDI_SDK_v5_Linux.tar.gz' 0lsiw523sqr6ydwxnikyijayfi55q5mzvh1zi216swvj5kfbxl00

Would be better to have the derivation pull the file for the user to keep things declarative.

@jshcmpbll
Copy link
Member

Totally agree! Ill see if the maintainer is cool with changing that up.

Yeah, that should add it. From what I've seen in the past though, NDI releases the SDK with just v5 but dont actually provide the full version. So when they update it the url never changes 😞 so even if you are downloading the right file it might be a newer version than the hash that is being checked

@jshcmpbll
Copy link
Member

#82617 (comment)

@Zahrun
Copy link
Contributor Author

Zahrun commented Mar 4, 2023

Adding a nixpkg option to confirm we accept the license sounds good.

I am not finding the NDI output in the list of filters in OBS.
I can confirm that the plugin is loaded, since I can add a NDI source
Did I forget something?

@jshcmpbll
Copy link
Member

Tools -> obs-ndi Settings I had the same confusion when I first installed it.

@Zahrun
Copy link
Contributor Author

Zahrun commented Mar 5, 2023

I'm still not seeing the Output NDI filter as in https://streamgeeks.us/wp-content/uploads/2022/02/NDI-Filter-in-OBS-1024x551.png
Seems it's a known issue though DistroAV/DistroAV#774, DistroAV/DistroAV#772
So I tried to build the obs-ndi 4.11.0-RC instead as in Zahrun@c83e307, now the output NDI Filter appears. I can add it to a Source as a Filter, then I can add a NDI Source, I enter the same name, and... it does not show anything

@Krutonium
Copy link
Contributor

Heads up the version of NDI from their website is now newer and no longer works with the existing obs-ndi version in the repo.

@Lownin
Copy link

Lownin commented Jun 10, 2023

Is there a clean way to add the file to the Nix store when NewTek updates the file and the hash/version no longer match?

@benaryorg
Copy link
Contributor

Note that there seems to be a bug in the current ndi derivation that requires a workaround to actually be able to supply a custom version at the moment, as tested locally by me.

The current unpackPhase uses the src of the derivation, rather than using the $src environment variable present in the stdenv.
The result is a derivation that always depends on the version of the file that is used in the upstream nixpkgs definition.

I'm copy&pasting the following from my nix repl to make sure everything is 100% accurate, sorry for the dense one-liners.

So when updating to the new version like this in a local shell (or in any nix expression), one should be able to override like this¹:

pkgs.ndi.overrideAttrs (self: super: { version = "5.5.4"; src = pkgs.requireFile rec { name = "${self.installerName}.tar.gz"; sha256 = "sha256:c16db57b467d06cce1455393df744f152623b48ae53d76aa6ac4b3b5f0e3bde8"; message = "update the file again please"; }; })

This however fails building (prefix with :b in nix repl):

error: builder for '/nix/store/06024yxsdxpdd4gy18b022yfgjzqi9ki-Install_NDI_SDK_v5_Linux.tar.gz.drv' failed with exit code 1;
       last 10 log lines:
       >
       >   https://ndi.tv/sdk/
       >
       > Once you have downloaded the file, please use the following command and
       > re-run the installation:
       >
       >   $ nix-prefetch-url file://$PWD/Install_NDI_SDK_v5_Linux.tar.gz
       >
       > ***
       >
       For full logs, run 'nix log /nix/store/06024yxsdxpdd4gy18b022yfgjzqi9ki-Install_NDI_SDK_v5_Linux.tar.gz.drv'.
error: 1 dependencies of derivation '/nix/store/cl1qmjyfndmcngmkir0cj7xmxaxn2jwp-ndi-5.5.4.drv' failed to build

The reason this contains the upstream error message and not the one provided in the repl is precisely because the ${src} in the above piece of code is evaluated in nix, not the stdenv shell so it cannot be overridden.
This is also visible in the derivation for ndi-5.5.4 which lists both the old and new version of the file as its inputs, as the old one is being interpolated:

% nix show-derivation /nix/store/cl1qmjyfndmcngmkir0cj7xmxaxn2jwp-ndi-5.5.4.drv
[snip]
      "unpackPhase": "unpackFile /nix/store/6rx5a4pxzfdbm6q9si2gpqzpnbfp8c94-Install_NDI_SDK_v5_Linux.tar.gz\necho y | ./Install_NDI_SDK_v5_Linux.sh\nsourceRoot=\"NDI SDK for Linux\";\n",
[snip]
    "inputDrvs": {
      "/nix/store/06024yxsdxpdd4gy18b022yfgjzqi9ki-Install_NDI_SDK_v5_Linux.tar.gz.drv": [
        "out"
      ],
      "/nix/store/4ipmv8hn6hak618qy9fr49m5yazphvcg-Install_NDI_SDK_v5_Linux.tar.gz.drv": [
        "out"
      ],
[snip]

(notice the unpackPhase still referencing the old file starting with 6rx[…] rather than the new sr2[…] one listed later¹)

So the temporary workaround is to provide the fixed unpackPhase in the overrideAttrs:

pkgs.ndi.overrideAttrs (self: super: { version = "5.5.4"; src = pkgs.requireFile rec { name = "${self.installerName}.tar.gz"; sha256 = "sha256:c16db57b467d06cce1455393df744f152623b48ae53d76aa6ac4b3b5f0e3bde8"; message = self.installerName; }; unpackPhase = "unpackFile \${src}\necho y | ./${self.installerName}.sh\nsourceRoot=\"NDI SDK for Linux\";\n"; })

¹: provided the current version was retrieved from upstream by:

  1. fetching the file (Install_NDI_SDK_v5_Linux.tar.gz)
  2. adding it to the store (nix-store --add-fixed sha256 Install_NDI_SDK_v5_Linux.tar.gz) yielding /nix/store/sr2nl8nqbcdl45l28dkjjr8zqky0smfq-Install_NDI_SDK_v5_Linux.tar.gz
  3. hashing that file using sha256sum (at time of writing c16db57b467d06cce1455393df744f152623b48ae53d76aa6ac4b3b5f0e3bde8)

I will provide a Pull Request for this shortly.

benaryorg added a commit to benaryorg/nixpkgs that referenced this issue Jun 11, 2023
The `unpackPhase` as of the previous commit did interpolate the result of the `src` on a nix level.
However for any overrides (`overrideAttrs`) to work on the source, for instance to update to a newer version locally, the `src` environment variable of `stdenv` must be used.
Otherwise the old, upstream, version will still be pulled in as a dependency and ultimately used for building, which will fail if the old version is not present, or will just deploy the old version if the old version was already downloaded (`requireFile` causes special semi-non-idempotent issues here).

Further information was provided in a GitHub comment: NixOS#219578 (comment)

Signed-off-by: benaryorg <binary@benary.org>
benaryorg added a commit to benaryorg/nixpkgs that referenced this issue Jun 11, 2023
The `unpackPhase` as of the previous commit did interpolate the result of the `src` on a nix level.
However for any overrides (`overrideAttrs`) to work on the source, for instance to update to a newer version locally, the `src` environment variable of `stdenv` must be used.
Otherwise the old, upstream, version will still be pulled in as a dependency and ultimately used for building, which will fail if the old version is not present, or will just deploy the old version if the old version was already downloaded (`requireFile` causes special semi-non-idempotent issues here).

Further information was provided in a GitHub comment: NixOS#219578 (comment)

Signed-off-by: benaryorg <binary@benary.org>
misumisumi added a commit to misumisumi/nixos-desktop-config that referenced this issue Sep 26, 2023
@jshcmpbll
Copy link
Member

Resolved with #298259

The NDI library now fetches the src from NDI directly resolving the user interaction necessary for installing obs-ndi. I've also got a new PR up to update obs-ndi if anyone is interested in helping review it 😄

#308938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants