From 6bf88ff2137a7dd8da4bd48b4c90558c94283945 Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Wed, 9 Apr 2025 19:48:39 -0400 Subject: [PATCH] spicetify-cli: rework --- pkgs/by-name/sp/spicetify-cli/package.nix | 56 +++++++++++++-------- pkgs/by-name/sp/spicetify-cli/version.patch | 14 ++++++ 2 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 pkgs/by-name/sp/spicetify-cli/version.patch diff --git a/pkgs/by-name/sp/spicetify-cli/package.nix b/pkgs/by-name/sp/spicetify-cli/package.nix index 24ba6b58db2c..be7a97d4b719 100644 --- a/pkgs/by-name/sp/spicetify-cli/package.nix +++ b/pkgs/by-name/sp/spicetify-cli/package.nix @@ -3,17 +3,20 @@ buildGoModule, fetchFromGitHub, testers, + replaceVars, spicetify-cli, }: - -buildGoModule rec { - pname = "spicetify-cli"; +let version = "2.39.6"; +in +buildGoModule { + pname = "spicetify-cli"; + inherit version; src = fetchFromGitHub { owner = "spicetify"; repo = "cli"; - rev = "v${version}"; + tag = "v${version}"; hash = "sha256-rdyHVHKVgl9fOviFYQuXY8Ko+/XwpKlKDfriQAgkusE="; }; @@ -24,28 +27,41 @@ buildGoModule rec { "-X 'main.version=${version}'" ]; - # used at runtime, but not installed by default - postInstall = '' - mv $out/bin/cli $out/bin/spicetify - ln -s $out/bin/spicetify $out/bin/spicetify-cli - cp -r ${src}/jsHelper $out/bin/jsHelper - cp -r ${src}/CustomApps $out/bin/CustomApps - cp -r ${src}/Extensions $out/bin/Extensions - cp -r ${src}/Themes $out/bin/Themes - ''; + patches = [ + # Stops spicetify from attempting to fetch a newer css-map.json + (replaceVars ./version.patch { + inherit version; + }) + ]; - doInstallCheck = true; - installCheckPhase = '' - $out/bin/spicetify --help > /dev/null - ''; + postInstall = + /* + jsHelper and css-map.json are required at runtime + and are looked for in the directory of the spicetify binary + so here we move spicetify to /share/spicetify + so that css-map.json and jsHelper don't pollute PATH + */ + '' + mkdir -p $out/share/spicetify + + cp -r $src/jsHelper $out/share/spicetify/jsHelper + cp $src/css-map.json $out/share/spicetify/css-map.json + + mv $out/bin/cli $out/share/spicetify/spicetify + + ln -s $out/share/spicetify/spicetify $out/bin/spicetify + ''; passthru.tests.version = testers.testVersion { package = spicetify-cli; }; - meta = with lib; { + meta = { description = "Command-line tool to customize Spotify client"; homepage = "https://github.com/spicetify/cli"; - license = licenses.gpl3Plus; - maintainers = [ maintainers.mdarocha ]; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ + mdarocha + gerg-l + ]; mainProgram = "spicetify"; }; } diff --git a/pkgs/by-name/sp/spicetify-cli/version.patch b/pkgs/by-name/sp/spicetify-cli/version.patch new file mode 100644 index 000000000000..a6e1fede5a2d --- /dev/null +++ b/pkgs/by-name/sp/spicetify-cli/version.patch @@ -0,0 +1,14 @@ +diff --git a/src/preprocess/preprocess.go b/src/preprocess/preprocess.go +index ac0f084..f38ece2 100644 +--- a/src/preprocess/preprocess.go ++++ b/src/preprocess/preprocess.go +@@ -66,7 +66,7 @@ func Start(version string, extractedAppsPath string, flags Flag) { + var cssTranslationMap = make(map[string]string) + // readSourceMapAndGenerateCSSMap(appPath) + +- if version != "Dev" { ++ if version != "@version@" { + tag, err := FetchLatestTagMatchingOrMain(version) + if err != nil { + utils.PrintWarning("Cannot fetch version tag for CSS mappings") +