@heywoodlh

heywoodlh thoughts

DRM (for Spotify) on M1 Macbook with Asahi Linux and NixOS

I recently installed NixOS on my M2 Macbook Air using nixos-apple-silicon. For those not familiar with the nixos-apple-silicon project, it packages the great work of the Asahi Linux project for NixOS.

Despite Linux on 64 bit ARM being around for a long time – outside of Asahi Linux – I haven’t seriously used ARM64 Linux specifically on the desktop. I did not realize the DRM-specific web applications like Spotify or Netflix just didn’t work on 64 bit ARM on Linux until recently because Widevine didn’t support ARM64 Linux until recently. See this thread for more context if interested: Widevine for 64-bit chromium now achievable #248

It was surprisingly difficult for me to discover how to fix this, so I’m writing this post to hopefully help any future NixOS ARM64 wayfarer wanting to run Spotify, Netflix or any other DRM-protected web app.

How I fixed it #

Thankfully, others had already done most of the work. These three links were immensely helpful for me:

AsahiLinux/widevine-installer

nixos/nixpkgs #251085: chromium: add widevine support on aarch64

shell.nix

My solution was to package a Nix Flake for ARM64 for Chromium, here:

chromium-widevine

You can run it with the following command:

nix run "github:heywoodlh/flakes?dir=chromium-widevine"

Or install it with this command:

nix profile install "github:heywoodlh/flakes?dir=chromium-widevine"

Spotify #

After installing my Flake, this is essentially how I’m launching Spotify (with the wrapper provided by my chromium-widevine flake):

chromium --app="https://open.spotify.com"

As a reference/example, here’s how I’ve created a .desktop entry for Chromium and Spotify using my chromium-widevine wrapper:

heywoodlh/nixos-configs: roles/home-manager/linux/desktop.nix

  home.file.".local/share/applications/chromium-browser.desktop" = {
    enable = system == "aarch64-linux";
    text = ''
      [Desktop Entry]
      Name=Chromium
      GenericName=browser
      Comment=Chromium browser with Widevine
      Exec=${myFlakes.packages.aarch64-linux.chromium-widevine}/bin/chromium
      Terminal=false
      Type=Application
      Keywords=browser;internet;
      Icon=${snowflake}
      Categories=Utility;
    '';
  };

  home.file.".local/share/applications/spotify.desktop" = {
    enable = system == "aarch64-linux";
    text = ''
      [Desktop Entry]
      Name=Spotify
      GenericName=music
      Comment=Listen to Spotify
      Exec=${myFlakes.packages.aarch64-linux.chromium-widevine}/bin/chromium --app=https://open.spotify.com
      Terminal=false
      Type=Application
      Keywords=music;
      Icon=${snowflake}
      Categories=Music;
    '';
  };

Conclusion #

It was interesting for me to learn that this was an issue on ARM64 Linux. I’m very grateful to the Asahi Linux folk for all the work they are doing in addition to the work that the NixOS folks do that I benefit from on a daily basis. Despite the currently unfinished features of Asahi Linux with the Macbook I’m on, it’s a pretty polished experience so far!

Written on February 12, 2024

linux nixos drm spotify asahi m1