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

mpvScripts.twitch-chat: init at 0-unstable-2024-06-23 #368422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trueNAHO
Copy link
Member

@trueNAHO trueNAHO commented Dec 26, 2024

This module is strongly inspired by mpvScripts.modernz and mpvScripts.youtube-chat.

For reference, I am using this patch as follows:

commit a58ebab2f53b8a1e343b4016ca6a4db0721b2380
Author: NAHO <[email protected]>
Date:   2024-12-26 19:17:45 +0100

    mpv: scripts: twitch-chat: init

diff --git a/flake.lock b/flake.lock
index 41d49c60..41adbbae 100644
--- a/flake.lock
+++ b/flake.lock
@@ -392,6 +392,22 @@
         "type": "github"
       }
     },
+    "nixpkgs-mpv-script-mpv-twitch-chat-init-at-0-unstable-2024-06-23": {
+      "locked": {
+        "lastModified": 1735251247,
+        "narHash": "sha256-kwFSGhuoWd+BgHslTB5exfrvJzELbpUlmuK2bVxOnNo=",
+        "owner": "trueNAHO",
+        "repo": "nixpkgs",
+        "rev": "732505cc8174deca56ff8c3547ddc1e76244b2ef",
+        "type": "github"
+      },
+      "original": {
+        "owner": "trueNAHO",
+        "ref": "mpv-script-mpv-twitch-chat-init-at-0-unstable-2024-06-23",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
     "nixpkgs_2": {
       "locked": {
         "lastModified": 1731319897,
@@ -493,6 +509,7 @@
         "nix-alien": "nix-alien",
         "nix-index-database": "nix-index-database_2",
         "nixpkgs": "nixpkgs_3",
+        "nixpkgs-mpv-script-mpv-twitch-chat-init-at-0-unstable-2024-06-23": "nixpkgs-mpv-script-mpv-twitch-chat-init-at-0-unstable-2024-06-23",
         "nixvim": "nixvim",
         "os": "os",
         "stylix": "stylix",
diff --git a/flake.nix b/flake.nix
index 969d25d0..6c6a39d3 100644
--- a/flake.nix
+++ b/flake.nix
@@ -92,6 +92,11 @@
       url = "github:trueNAHO/nix-index-database/treewide-disable-programs-nix-index-enable-option-by-default";
     };

+    # TODO: Replace this fork with upstream once [1] is merged.
+    #
+    # [1]: https://github.com/NixOS/nixpkgs/pull/368422
+    nixpkgs-mpv-script-mpv-twitch-chat-init-at-0-unstable-2024-06-23.url = "github:trueNAHO/nixpkgs/mpv-script-mpv-twitch-chat-init-at-0-unstable-2024-06-23";
+
     nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

     nixvim = {
diff --git a/modules/inputs/home-manager/programs/mpv/default.nix b/modules/inputs/home-manager/programs/mpv/default.nix
index 6bea0dfe..ff7762fc 100644
--- a/modules/inputs/home-manager/programs/mpv/default.nix
+++ b/modules/inputs/home-manager/programs/mpv/default.nix
@@ -1,7 +1,9 @@
 {
   config,
+  inputs,
   lib,
   pkgs,
+  system,
   ...
 }: {
   options.dotfiles.inputs.home-manager.programs.mpv = {
@@ -35,6 +37,7 @@
     };

     scripts = {
+      mpv-twitch-chat = lib.dotfiles.mkEnableOption;
       playlistmanager = lib.dotfiles.mkEnableOption;
       thumbfast = lib.dotfiles.mkEnableOption;
       uosc = lib.dotfiles.mkEnableOption;
@@ -51,6 +54,7 @@
             bindings.anime4k = lib.mkDefault true;

             scripts = {
+              mpv-twitch-chat = lib.mkDefault true;
               playlistmanager = lib.mkDefault true;
               thumbfast = lib.mkDefault true;
               uosc = lib.mkDefault true;
@@ -263,6 +267,30 @@
           }
         )

+        (
+          lib.mkIf cfg.scripts.mpv-twitch-chat {
+            programs.mpv = {
+              profiles.twitch-chat = {
+                profile-cond = ''get("path", ""):find("^https://www.twitch.tv/") ~= nil'';
+                profile-restore = "copy-equal";
+                sub-align-x = "right";
+                sub-align-y = "top";
+                sub-font-size = 12;
+                sub-outline-size = 1;
+              };
+
+              scriptOpts.twitch_chat = {
+                duration_multiplier = 1000000;
+                fetch_aot = 11;
+                max_message_length = 0;
+                show_name = true;
+              };
+
+              scripts = [inputs.nixpkgs-mpv-script-mpv-twitch-chat-init-at-0-unstable-2024-06-23.legacyPackages.${system}.mpvScripts.twitch-chat];
+            };
+          }
+        )
+
         (
           lib.mkIf cfg.scripts.playlistmanager {
             programs.mpv = {

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@trueNAHO trueNAHO force-pushed the mpv-script-mpv-twitch-chat-init-at-0-unstable-2024-06-23 branch from 22d0c90 to 732505c Compare December 26, 2024 22:14
@trueNAHO trueNAHO changed the title mpvScripts.mpv-twitch-chat: init at 0-unstable-2024-06-23 mpvScripts.twitch-chat: init at 0-unstable-2024-06-23 Dec 26, 2024
@trueNAHO
Copy link
Member Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 368422


x86_64-linux

✅ 1 package built:
  • mpvScripts.twitch-chat

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1 10.rebuild-linux: 1 labels Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant