diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-06-16 06:56:35 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-06-16 06:56:35 +0000 |
commit | 99fcaeccb89621dd492203ce1f2d551c06f228ed (patch) | |
tree | 41cb730ae07383004789779b0f6e11cb3f4642a3 /nixpkgs/pkgs/development/libraries/ndi | |
parent | 59c5f5ac8682acc13bb22bc29c7cf02f7d75f01f (diff) | |
parent | 75a5ebf473cd60148ba9aec0d219f72e5cf52519 (diff) | |
download | nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.gz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.bz2 nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.lz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.xz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.zst nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.zip |
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts: nixpkgs/nixos/modules/config/console.nix nixpkgs/nixos/modules/services/mail/mailman.nix nixpkgs/nixos/modules/services/mail/public-inbox.nix nixpkgs/nixos/modules/services/mail/rss2email.nix nixpkgs/nixos/modules/services/networking/ssh/sshd.nix nixpkgs/pkgs/applications/networking/instant-messengers/dino/default.nix nixpkgs/pkgs/applications/networking/irc/weechat/default.nix nixpkgs/pkgs/applications/window-managers/sway/default.nix nixpkgs/pkgs/build-support/go/module.nix nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix nixpkgs/pkgs/development/interpreters/python/default.nix nixpkgs/pkgs/development/node-packages/overrides.nix nixpkgs/pkgs/development/tools/b4/default.nix nixpkgs/pkgs/servers/dict/dictd-db.nix nixpkgs/pkgs/servers/mail/public-inbox/default.nix nixpkgs/pkgs/tools/security/pinentry/default.nix nixpkgs/pkgs/tools/text/unoconv/default.nix nixpkgs/pkgs/top-level/all-packages.nix
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/ndi')
-rw-r--r-- | nixpkgs/pkgs/development/libraries/ndi/default.nix | 23 | ||||
-rwxr-xr-x | nixpkgs/pkgs/development/libraries/ndi/update.py | 77 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/libraries/ndi/version.json | 1 |
3 files changed, 94 insertions, 7 deletions
diff --git a/nixpkgs/pkgs/development/libraries/ndi/default.nix b/nixpkgs/pkgs/development/libraries/ndi/default.nix index 7ea64aa3f134..1c15455b6add 100644 --- a/nixpkgs/pkgs/development/libraries/ndi/default.nix +++ b/nixpkgs/pkgs/development/libraries/ndi/default.nix @@ -1,15 +1,19 @@ -{ lib, stdenv, requireFile, avahi }: +{ lib, stdenv, requireFile, avahi, obs-studio-plugins }: +let + versionJSON = lib.importJSON ./version.json; +in stdenv.mkDerivation rec { pname = "ndi"; - fullVersion = "4.6.2"; - version = builtins.head (builtins.splitVersion fullVersion); + version = versionJSON.version; + majorVersion = builtins.head (builtins.splitVersion version); + installerName = "Install_NDI_SDK_v${majorVersion}_Linux"; src = requireFile rec { - name = "InstallNDISDK_v${version}_Linux.tar.gz"; - sha256 = "181ypfj1bl0kljzrfr6037i14ykg2y4plkzdhym6m3z7kcrnm1fl"; + name = "${installerName}.tar.gz"; + sha256 = versionJSON.hash; message = '' - In order to use NDI SDK version ${fullVersion}, you need to comply with + In order to use NDI SDK version ${version}, you need to comply with NewTek's license and download the appropriate Linux tarball from: ${meta.homepage} @@ -25,7 +29,7 @@ stdenv.mkDerivation rec { unpackPhase = '' unpackFile ${src} - echo y | ./InstallNDISDK_v4_Linux.sh + echo y | ./${installerName}.sh sourceRoot="NDI SDK for Linux"; ''; @@ -51,6 +55,11 @@ stdenv.mkDerivation rec { # Stripping breaks ndi-record. dontStrip = true; + passthru.tests = { + inherit (obs-studio-plugins) obs-ndi; + }; + passthru.updateScript = ./update.py; + meta = with lib; { homepage = "https://ndi.tv/sdk/"; description = "NDI Software Developer Kit"; diff --git a/nixpkgs/pkgs/development/libraries/ndi/update.py b/nixpkgs/pkgs/development/libraries/ndi/update.py new file mode 100755 index 000000000000..e80260210368 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/ndi/update.py @@ -0,0 +1,77 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i python -p "python3.withPackages (ps: with ps; [ ps.absl-py ps.requests ])" + +import hashlib +import io +import json +import os.path +import tarfile + +import requests +from absl import app, flags + +BASE_NAME = "Install_NDI_SDK_v5_Linux" +NDI_SDK_URL = f"https://downloads.ndi.tv/SDK/NDI_SDK_Linux/{BASE_NAME}.tar.gz" +NDI_EXEC = f"{BASE_NAME}.sh" + +NDI_ARCHIVE_MAGIC = b"__NDI_ARCHIVE_BEGIN__\n" + +FLAG_out = flags.DEFINE_string("out", None, "Path to read/write version.json from/to.") + + +def find_version_json() -> str: + if FLAG_out.value: + return FLAG_out.value + try_paths = ["pkgs/development/libraries/ndi/version.json", "version.json"] + for path in try_paths: + if os.path.exists(path): + return path + raise Exception( + "Couldn't figure out where to write version.json; try specifying --out" + ) + + +def fetch_tarball() -> bytes: + r = requests.get(NDI_SDK_URL) + r.raise_for_status() + return r.content + + +def read_version(tarball: bytes) -> str: + # Find the inner script. + outer_tarfile = tarfile.open(fileobj=io.BytesIO(tarball), mode="r:gz") + eula_script = outer_tarfile.extractfile(NDI_EXEC).read() + + # Now find the archive embedded within the script. + archive_start = eula_script.find(NDI_ARCHIVE_MAGIC) + len(NDI_ARCHIVE_MAGIC) + inner_tarfile = tarfile.open( + fileobj=io.BytesIO(eula_script[archive_start:]), mode="r:gz" + ) + + # Now find Version.txt... + version_txt = ( + inner_tarfile.extractfile("NDI SDK for Linux/Version.txt") + .read() + .decode("utf-8") + ) + _, _, version = version_txt.strip().partition(" v") + return version + + +def main(argv): + tarball = fetch_tarball() + + sha256 = hashlib.sha256(tarball).hexdigest() + version = { + "hash": f"sha256:{sha256}", + "version": read_version(tarball), + } + + out_path = find_version_json() + with open(out_path, "w") as f: + json.dump(version, f) + f.write("\n") + + +if __name__ == "__main__": + app.run(main) diff --git a/nixpkgs/pkgs/development/libraries/ndi/version.json b/nixpkgs/pkgs/development/libraries/ndi/version.json new file mode 100644 index 000000000000..d751aa79e431 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/ndi/version.json @@ -0,0 +1 @@ +{"hash": "sha256:70e04c2e7a629a9854de2727e0f978175b7a4ec6cf4cd9799a22390862f6fa27", "version": "5.5.2"} |