How to combine overlays of unstable branch, overrideAttrs and override altoguther for a package?

Hi, I am using stable branch of NixOS with flake.
I want to combine unstable branch, overrideAttrs, and override on yt-dlp.

Before, I use overlays to install yt-dlp in unstable branch.

{ lib, system, inputs, ... }:
let
	overlay-unstable = final: prev: {
		# import input from flake.nix
		unstable = import inputs.nixpkgs-unstable {
			inherit system;
		};
	};
in { 
    nixpkgs.overlays = [ overlay-unstable ];
    environment.systemPackages = with pkgs; [ unstable.yt-dlp ];
}

However I found that the yt-dlp of unstable branch is not new enough to fix some bug (downloading comment ), so I use overlay of yt-dlp with overrideAttrs instead.
I do not know how to combine the above unstable ovelay with it, so I just overlay it with stable branch.

{ pkgs, ...}:
let
	overlay-yt-dlp = final: prev: {
		yt-dlp = prev.yt-dlp.overrideAttrs {
			src = pkgs.fetchFromGitHub {
				owner = "yt-dlp";
				repo = "yt-dlp";
				rev = "8e15177b4113c355989881e4e030f695a9b59c3a";
				hash = "sha256-iBk672ocjUZi+VTAegcC5GWaeg+ZleVcuYzMkp1i5aI=";
			};
		};
	};
in {
    nixpkgs.overlays = [ overlay-yt-dlp ];
    environment.systemPackages = with pkgs; [ yt-dlp ];
}

The bad news is that some bug (video and audio merging) require the latest ffmpeg to fix it, I thought

{ environment.systemPackages = with pkgs; [ 
    yt-dlp.override { ffmpeg = pkgs.ffmpeg_7; } 
]; }

can do it, but ffmpeg_7 is not available in stable branch.

What should I do to combine all of it?
Thanks for your help!

Solved.

{ pkgs, lib, system, inputs, ... }:
let
	overlay-yt-dlp = final: prev: {
		yt-dlp = prev.yt-dlp.overrideAttrs {
			src = pkgs.fetchFromGitHub {
				owner = "yt-dlp";
				repo = "yt-dlp";
				rev = "8e15177b4113c355989881e4e030f695a9b59c3a";
				hash = "sha256-iBk672ocjUZi+VTAegcC5GWaeg+ZleVcuYzMkp1i5aI=";
			};
		};
	};
	overlay-unstable = final: prev: {
		# import input from flake.nix
		unstable = import inputs.nixpkgs-unstable {
			inherit system;
			overlays = [ overlay-yt-dlp ];
		};
	};
in { 
    nixpkgs.overlays = [ overlay-unstable ];
    environment.systemPackages = with pkgs; [ 
        (unstable.yt-dlp.override { ffmpeg = pkgs.unstable.ffmpeg_7; }) 
    ];
}
1 Like