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

Enable Widevine support #145

Open
afilini opened this issue Jan 18, 2024 · 17 comments
Open

Enable Widevine support #145

afilini opened this issue Jan 18, 2024 · 17 comments

Comments

@afilini
Copy link

afilini commented Jan 18, 2024

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
Copy link
Author

afilini commented Jan 18, 2024

(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)

@bruhderek
Copy link

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

@psanford
Copy link

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.

@bruhderek
Copy link

@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?

@psanford
Copy link

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.

@bruhderek
Copy link

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

@cmacrae
Copy link

cmacrae commented Jan 24, 2024

@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.

@bruhderek
Copy link

@cmacrae I ran the nix shell, and nothing happened

@3541
Copy link

3541 commented Jan 24, 2024

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.

@diegobfernandez
Copy link

@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.

@TLMcNulty
Copy link

TLMcNulty commented Apr 4, 2024

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

@epetousis
Copy link

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
Copy link

epetousis commented Apr 5, 2024

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

@TLMcNulty
Copy link

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
Copy link

TLMcNulty commented Apr 5, 2024

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.

@dxwil
Copy link

dxwil commented Aug 23, 2024

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.

It seems as there was something wrong with extraPrefsFiles, it was not being applied. Perhaps something is wrong in the firefox wrapper itself. I modified that part to work around this issue. I also wrapped the environmental variable right into firefox, so now just applying the overlay will be enough for widevine to work on firefox.

@dxwil
Copy link

dxwil commented Aug 25, 2024

#337261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants