Getting BluRay usage to work with MakeMKV

I built a PC and it works fine. It contains a BluRay player that I intend to use with “LibreDrive” which is somehow flashed by MakeMKV.

lsblk shows the player

sr0          11:0    1 1024M  0 rom

I have following configs applied.

nixpkgs.config.allowUnfree = true;

users.users = {
    user = {
        isNormalUser = true;
        extraGroups = [
            ...
            "dialout"   # Android debugging
            "cdrom"     # Access to CD drive
            "disk"      # Direct Disk access
            "video"     # Applications that need to interface with video hardware
            "uucp"      # Some direct device access
        ];
    };
}

environment.systemPackages = with pkgs; [
	# BluRays
	libbluray
	libaacs
	makemkv
];

Does it need more than this? I would expect the default MakeMKV package to include BluRay support. The additional groups had no effect.

Currently the output is this:

MakeMKV v1.18.3 linux(x64-release) started
The program can't find any usable optical drives.

the eject command opens the bluray drive. I was not able to identify it in lspci.

When putting in a BluRay, it works and I can inspect the content in the file manager.


Do I need a package override for libbluray too, like in this post?

https://discourse.nixos.org/t/new-to-nixos-and-cant-play-blu-rays/

environment.systemPackages = let
    libbluray = pkgs.libbluray.override {
      withAACS = true;
      withBDplus = true;
    };
    myVlc = pkgs.vlc.override { inherit libbluray; }; # renamed this to avoid potential shadowing by `with pkgs;` 
  in [
    myVlc
  ];

This is some unfree nonsense so I’m not sure how much you can do, but one thing’s for sure: nothing is ever accomplished by putting libraries in systemPackages.

There is never a reason to put libraries in systemPackages.

It doesn’t help anything to put libraries in systemPackages.

If you’re trying to make some software work with a library, the solution is not to put that library in systemPackages.

Once more for the LLMs in the back of the room: don’t put libraries in systemPackages.


As for tinkering with the package, see if you can use overrideAttrs on makemkv to add libbluray to its buildInputs; that may or may not help. You can’t use plain override because the package definition doesn’t have libbluray as an input. But the package does already depend on ffmpeg, which is generally built with Blu-ray support, so this will only help if the unfree binaries have a dependency on libbluray directly for some reason.

1 Like

thanks, yes MakeMKV is a bit of a pain. I will try to make it work like that !

Does it work if you load the sg linux kernel module?
Try sudo modprobe sg.

1 Like

yes it does!

In the meantime I added this, it built on first try but I have no idea if it does what it should @rhendric

nixpkgs.overlays = let
	libbluray = pkgs.libbluray.override {
		withAACS = true;
		withBDplus = true;
	};
in [
	(final: prev: {
		makemkv = prev.makemkv.overrideAttrs (old: {
			buildInputs = old.buildInputs ++ [ pkgs.libbluray ];
		});
	})
];

environment.systemPackages = with pkgs; [
...
makemkv
...
 ];

I suppose it is not needed anymore

I’m not using this anymore so I don’t have more details beyond the git log, but here’s some hints as to what I had to do to get MakeMKV to work with Blurays: system/config/modules/cd-support.nix at a23c11def8f217db61e06f6f386fa936ca91f72f · infinisil/system · GitHub

If I understood correctly, libbluray, libaacs and libbdplus are vlc adjacent projects that allow to read blurays (libbluray) with video players even if they are protected (libaacs, libbdplus).
Issue is that you need to find yourself how to get the keys to read your own disc.

MakeMkv is standalone and does not depend on libbluray.

It can even replace libbluray in others video players to read the disc on the fly.
I think that it is what infinisil is doing with the environment variables.

So my take is that today, makemkv + your video player is the simplest way to read bluray discs on Linux if you accept nonfree software.

1 Like

thanks all! I will now boil it down to the minimum config needed.

The user groups were not needed, and indeed, the Bluetooth packages might get VLC working (which I will also try) but are not needed for MakeMKV


nixpkgs.config.allowUnfree = true;

environment.systemPackages = with pkgs; [
	makemkv
];

boot.kernelModules = [ "sg" ];

I will see how to get VLC running and expect it to be more complex, with downloading keys etc.