nixos-apple-silicon icon indicating copy to clipboard operation
nixos-apple-silicon copied to clipboard

Enable Widevine support

Open afilini opened this issue 1 year ago • 17 comments

In case anybody is interested i threw together this quick nix shell to package arm64 widevine for nixos. This uses the great widevine-installer tool from AsahiLinux.

Unfortunately I don't have much time to work on a proper contribution to this project, so I figured I would just leave this here in case anybody wants to use it/take it and add it to this repo!

https://gist.github.com/afilini/7fb5624c850f39af4938f4a5d087f2dc

afilini avatar Jan 18 '24 22:01 afilini

(Ideally I think this should be reworked into a nixpkgs pull req that uses widevine-installer on arm64 rather than downloading and extracting widevine from the .deb file like it currently does for x86)

afilini avatar Jan 18 '24 22:01 afilini

@afilini Where do you put the script or how do you run it?

bruhderek avatar Jan 21 '24 05:01 bruhderek

I turned this into an overlay if thats useful to anyone else: https://gist.github.com/psanford/1f70a0838c308d28478cf27a9b55c43d

I can confirm this works for me.

psanford avatar Jan 22 '24 23:01 psanford

@psanford How? Did you cd into downloads and run nix-shell or something else? Also, what's the difference between your script and Afilini's?

bruhderek avatar Jan 22 '24 23:01 bruhderek

You can run afilini's simply by running nix-shell shell.nix. You can add my overlay to your configuration.nix like so:

nixpkgs.overlays = [
 (import ./overlays/chromium-widevine-overlay.nix)
]

These are both pretty normal things in nix. I'd suggest you read the nix documentation for more details on how this works.

psanford avatar Jan 22 '24 23:01 psanford

@psanford so the nix shell doesn’t work on its own?

bruhderek avatar Jan 22 '24 23:01 bruhderek

@psanford so the nix shell doesn’t work on its own?

i'd take @psanford's advice on this:

These are both pretty normal things in nix. I'd suggest you read the nix documentation for more details on how this works.

cmacrae avatar Jan 24 '24 09:01 cmacrae

@cmacrae I ran the nix shell, and nothing happened

bruhderek avatar Jan 24 '24 15:01 bruhderek

This also works for Firefox by just setting MOZ_GMP_PATH to <widevine-path>/gmp-widevinecdm/system-installed, and adding the requisite preferences (https://github.com/AsahiLinux/widevine-installer/blob/main/conf/gmpwidevine.js).

Not sure of the best way to package this up, but I was able to make it work for myself by setting it in environment.sessionVariables and sticking the preferences in user.js.

3541 avatar Jan 24 '24 22:01 3541

@3541 I've added a comment to the overlay gist that shows how to modify it to include the preferences from widevine-installer without the need to set it in user.js.

diegobfernandez avatar Jan 25 '24 20:01 diegobfernandez

To be clear about the steps:

I've created a file in a new directory, /etc/nixos/overlays, then per @psanford 's comment above, added:

nixpkgs.overlays = [
 (import ./overlays/chromium-widevine-overlay.nix)
]

To my configuration.nix, with the few changed lines from @diegobfernandez as I'd like to enable this for Firefox.

Running a sudo nixos-rebuild switch runs a lot of the widevine-installer installPhase logic, and I can see the MOZ_GMP_PATH set in my environment.

MOZ_GMP_PATH=/nix/store/7hdjbkwphkfxhv7s4k849j9172yyxdz0-widevine/gmp-widevinecdm/system-installed
> ls /nix/store/7hdjbkwphkfxhv7s4k849j9172yyxdz0-widevine/gmp-widevinecdm/system-installed 
libwidevinecdm.so  manifest.json

I don't have any seemingly relevant preferences in the about:preferences view in firefox, nor any GMP widevine type strings in about:config, and DRM type pages like Spotify's web player are still throwing widevine errors. I had some custom firefox confs loaded prior as I've been testing trying to get this working for a while, but checking at the moment it doesn't look like they're loaded, so I don't think my prior dirty conf is colliding.

Any of those that are more knowledgeable see anything wrong with my approach as described? Thanks.

I have previously run some of the widevine installation logic from the Asahi project. Perhaps that's messed up this overlay approach? https://gist.github.com/DavidBuchanan314/c6b97add51b97e4c3ee95dc890f9e3c8

TLMcNulty avatar Apr 04 '24 03:04 TLMcNulty

I turned this into a flake, I have published it in case this speeds up anyone's workflow at all: https://github.com/epetousis/nixos-aarch64-widevine

epetousis avatar Apr 04 '24 13:04 epetousis

I don't have any seemingly relevant preferences in the about:preferences view in firefox, nor any GMP widevine type strings in about:config

@TLMcNulty I believe this is standard behaviour since the profile has already been created, not 100% sure though. The widevine-installer repo has a .js file that is meant to define these preferences, but you can use them as a reference point for creating the options manually in about:config too: https://github.com/AsahiLinux/widevine-installer/blob/main/conf/gmpwidevine.js

epetousis avatar Apr 05 '24 00:04 epetousis

I don't have any seemingly relevant preferences in the about:preferences view in firefox, nor any GMP widevine type strings in about:config

@TLMcNulty I believe this is standard behaviour since the profile has already been created, not 100% sure though. The widevine-installer repo has a .js file that is meant to define these preferences, but you can use them as a reference point for creating the options manually in about:config too: https://github.com/AsahiLinux/widevine-installer/blob/main/conf/gmpwidevine.js

Aye, that's what I understood. I included the logic I thought would put that in in the overlay, but don't see them loaded in firefox. The profile mention is a good one, I'll test that, and depending on whether or not that nets anything, test manually placing the prefs in.

TLMcNulty avatar Apr 05 '24 00:04 TLMcNulty

Changing the profile did not auto-load anything. Manually defining the preferences listed in the gmpwidevine.js file DID allow streaming protected content in Spotify.

I don't know enough to troubleshoot the manual loading of the JS into Firefox prefs, but that doesn't matter so much to me now that it's working.

I also don't know if the manual fixup steps I ran prior, or the overlay is what put the conf onto the system correctly. If/when I rebuild from scratch I can tell. Either way, it's incredibly handy to have it in the DSL, as the configuration can now be safely stored.

I am in all of your debts, many blessings.

TLMcNulty avatar Apr 05 '24 15:04 TLMcNulty