diff --git a/flake.nix b/flake.nix index 4c5194e..aa4d893 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,8 @@ { self, ... }@inputs: let + pname = "spotiflac-cli"; + version = "7.0.9"; goVersion = 24; # Change this to update the whole stack supportedSystems = [ @@ -26,6 +28,18 @@ }; } ); + + pkgs = import inputs.nixpkgs { + system = "x86_64-linux"; + overlays = [ inputs.self.overlays.default ]; + }; + + spotiflac = pkgs.fetchFromGitHub { + owner = "afkarxyz"; + repo = "SpotiFLAC"; + tag = "v${version}"; + hash = "sha256-VHYof17C+eRoZfssXRQpbB8GXlcfPhyRiWltM6yDqe0="; + }; in { overlays.default = final: prev: { @@ -43,5 +57,26 @@ }; } ); + packages = forEachSupportedSystem ( + { pkgs }: + { + default = pkgs.buildGoModule (finalAttrs: { + inherit pname version; + src = ./.; + vendorHash = "sha256-EpGgfiCqJjHEOphV2x8FmXeIFls7eq2NVxb/or4NLUo="; + + subPackages = [ + "." + ]; + + postPatch = '' + cp -r ${spotiflac} ./SpotiFLAC/ + sed -i "s/git clone https:\/\/github.com\/afkarxyz\/SpotiFLAC.git//g" ./tools/fetch_spotiflac_backend.sh + sed -i "s/rm -rf SpotiFLAC//g" ./tools/fetch_spotiflac_backend.sh + ./tools/fetch_spotiflac_backend.sh + ''; + }); + } + ); }; } diff --git a/go.mod b/go.mod index 2b06d36..24bbd7c 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/Superredstone/spotiflac-cli go 1.24.4 +replace github.com/Superredstone/spotiflac-cli/app => ./app + require ( github.com/bogem/id3v2/v2 v2.1.4 // indirect github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect diff --git a/tools/fetch_spotiflac_backend.sh b/tools/fetch_spotiflac_backend.sh index 98c8e82..7fcb85f 100755 --- a/tools/fetch_spotiflac_backend.sh +++ b/tools/fetch_spotiflac_backend.sh @@ -6,7 +6,7 @@ FOLDER=lib rm -rf lib/ git clone https://github.com/afkarxyz/SpotiFLAC.git -mv SpotiFLAC/backend/ lib/ +cp -r SpotiFLAC/backend/ lib/ mkdir -p app/ cp SpotiFLAC/app.go app/app.go rm -rf SpotiFLAC @@ -14,6 +14,9 @@ rm -rf SpotiFLAC sed -i "s/package main/package app/g" app/app.go sed -i "s/\"spotiflac\/backend\"/backend \"github.com\/Superredstone\/spotiflac-cli\/lib\"/g" app/app.go +# Nix shenanigans +chmod -R 777 lib + for i in $(ls lib/); do sed -i "s/package backend/package $FOLDER/g" $FOLDER/$i done