diff --git a/pkgs/by-name/so/soundalike/package.nix b/pkgs/by-name/so/soundalike/package.nix new file mode 100644 index 000000000000..b38b65b7422d --- /dev/null +++ b/pkgs/by-name/so/soundalike/package.nix @@ -0,0 +1,73 @@ +{ + lib, + buildGoModule, + fetchFromGitea, + chromaprint, + makeWrapper, + versionCheckHook, +}: + +buildGoModule rec { + pname = "soundalike"; + version = "0.1.2"; + + src = fetchFromGitea { + domain = "codeberg.org"; + owner = "derat"; + repo = "soundalike"; + tag = "v${version}"; + hash = "sha256-mpYUVTj3Zll6kNuK5Mdzv1R7k5FZy6XFghhzmAPPVM8="; + }; + + vendorHash = "sha256-7hRezOBcjB2wsx/SwV519wg3Azh+0kHMcAoc9aYPM3A="; + + ldflags = [ + "-s" + "-w" + "-X" + "main.buildVersion=${version}" + ]; + + nativeBuildInputs = [ + makeWrapper + chromaprint + ]; + + doCheck = true; + # need to grab another repo for music test data + testDataVersion = "0.0.1"; + testData = fetchFromGitea { + domain = "codeberg.org"; + owner = "derat"; + repo = "soundalike-testdata"; + tag = "v${testDataVersion}"; + hash = "sha256-7JQTnEjoYiiaQlnxsGcfj/9PYDWAkWq4/oxyczjEMo4="; + }; + preCheck = '' + # add soundalike to PATH to be available for unit tests + export PATH="$GOPATH/bin:$PATH" + # need to symlink test data to a relative path + # that the unit tests are expecting + ln -sfv ${testData} ./testdata + ''; + + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgramArg = "-version"; + doInstallCheck = true; + + # soundalike depends on fpcalc (chromparint) at runtime, so we + # need to use wrapProgram to make it available + postInstall = '' + wrapProgram $out/bin/soundalike \ + --prefix PATH : ${lib.makeBinPath [ chromaprint ]} + ''; + + meta = with lib; { + description = "Find duplicate audio files using acoustic fingerprints"; + homepage = "https://codeberg.org/derat/soundalike"; + changelog = "https://codeberg.org/derat/soundalike/releases/tag/v${version}"; + license = licenses.bsd3; + maintainers = with maintainers; [ atar13 ]; + mainProgram = "soundalike"; + }; +}