From 3d4d3ba3934390bc31b4fe327c8b2a9bf01b741f Mon Sep 17 00:00:00 2001 From: winston Date: Thu, 19 Oct 2023 07:06:38 +0200 Subject: [PATCH] feat(linux): add apple-music chrome app --- home/apps/media.nix | 8 ++++++- pkgs/apple-music.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 pkgs/apple-music.nix diff --git a/home/apps/media.nix b/home/apps/media.nix index 57b0cf6..957a20f 100644 --- a/home/apps/media.nix +++ b/home/apps/media.nix @@ -1,4 +1,8 @@ -{pkgs, ...}: let +{ + lib, + pkgs, + ... +}: let inherit (pkgs.stdenv.hostPlatform) isDarwin isLinux; in { programs.imv = { @@ -7,6 +11,8 @@ in { programs.mpv.enable = isLinux; programs.zathura.enable = isLinux; + home.packages = lib.mkIf isLinux [(pkgs.callPackage ../../pkgs/apple-music.nix {})]; + services.discord-applemusic-rich-presence.enable = isDarwin; xdg.mimeApps.defaultApplications = { diff --git a/pkgs/apple-music.nix b/pkgs/apple-music.nix new file mode 100644 index 0000000..16bf875 --- /dev/null +++ b/pkgs/apple-music.nix @@ -0,0 +1,50 @@ +{ + fetchurl, + google-chrome, + lib, + makeDesktopItem, + runtimeShell, + symlinkJoin, + writeScriptBin, + # command line arguments which are always set e.g "--disable-gpu" + commandLineArgs ? [], +}: let + name = "apple-music-via-google-chrome"; + + meta = { + description = "Open Apple Music in Google Chrome app mode"; + homepage = google-chrome.meta.homepage or null; + license = lib.licenses.unfree; + maintainers = [lib.maintainers.roberth]; + platforms = google-chrome.meta.platforms or lib.platforms.all; + }; + + desktopItem = makeDesktopItem { + inherit name; + exec = name; + icon = fetchurl { + name = "apple-music-icon.png"; + url = "https://music.apple.com/assets/favicon/favicon-180.png"; + sha256 = "sha256-lZXt+kbYCBTLzK1S9QcxVwIhin2x8iNUAcrSHtmWmOY="; + meta.license = lib.licenses.unfree; + }; + desktopName = "Apple Music via Google Chrome"; + genericName = "Music streaming service"; + categories = ["AudioVideo"]; + startupNotify = true; + }; + + script = writeScriptBin name '' + #!${runtimeShell} + exec ${google-chrome}/bin/${google-chrome.meta.mainProgram} ${lib.escapeShellArgs commandLineArgs} \ + --app=https://music.apple.com/browse?l=en_US \ + --no-first-run \ + --no-default-browser-check \ + --no-crash-upload \ + "$@" + ''; +in + symlinkJoin { + inherit name meta; + paths = [script desktopItem]; + }