nixpkgs/pkgs/servers/misc/navidrome/default.nix
Martin Weinelt 7ed419e80f
Merge pull request #261215 from erdnaxe/navidrome-fix
navidrome: fix cross-compilation
2023-12-17 17:14:25 +01:00

88 lines
1.9 KiB
Nix

{ buildGoModule
, buildPackages
, fetchFromGitHub
, fetchNpmDeps
, lib
, nodejs
, npmHooks
, pkg-config
, stdenv
, ffmpeg-headless
, taglib
, zlib
, makeWrapper
, nixosTests
, nix-update-script
, ffmpegSupport ? true
}:
buildGoModule rec {
pname = "navidrome";
version = "0.50.2";
src = fetchFromGitHub {
owner = "navidrome";
repo = "navidrome";
rev = "v${version}";
hash = "sha256-SZ9wVOHtmkrWfYGA0hNCXag2Yp17glOQpBsEQRK6Npg=";
};
vendorHash = "sha256-PKj2zJhGR1yETLZ4as35cuwil3vfyFKfkKF/32YdAt8=";
npmRoot = "ui";
npmDeps = fetchNpmDeps {
inherit src;
sourceRoot = "${src.name}/ui";
hash = "sha256-7wMMBJE3zSm+eCIaLBjt+Q0OWh3u0XpS0XHnaH17Xsc=";
};
nativeBuildInputs = [
buildPackages.makeWrapper
nodejs
npmHooks.npmConfigHook
pkg-config
];
overrideModAttrs = oldAttrs: {
nativeBuildInputs = lib.filter (drv: drv != npmHooks.npmConfigHook) oldAttrs.nativeBuildInputs;
preBuild = null;
};
buildInputs = [
taglib
zlib
];
ldflags = [
"-X github.com/navidrome/navidrome/consts.gitSha=${src.rev}"
"-X github.com/navidrome/navidrome/consts.gitTag=v${version}"
];
CGO_CFLAGS = lib.optionals stdenv.cc.isGNU [ "-Wno-return-local-addr" ];
preBuild = ''
make buildjs
'';
postFixup = lib.optionalString ffmpegSupport ''
wrapProgram $out/bin/navidrome \
--prefix PATH : ${lib.makeBinPath [ ffmpeg-headless ]}
'';
passthru = {
tests.navidrome = nixosTests.navidrome;
updateScript = nix-update-script { };
};
meta = {
description = "Navidrome Music Server and Streamer compatible with Subsonic/Airsonic";
homepage = "https://www.navidrome.org/";
license = lib.licenses.gpl3Only;
sourceProvenance = with lib.sourceTypes; [ fromSource ];
maintainers = with lib.maintainers; [ aciceri squalus ];
# Broken on Darwin: sandbox-exec: pattern serialization length exceeds maximum (NixOS/nix#4119)
broken = stdenv.isDarwin;
};
}