diff --git a/nixos/hosts/sunken-ship.nix b/nixos/hosts/sunken-ship.nix index c929d84..2614410 100644 --- a/nixos/hosts/sunken-ship.nix +++ b/nixos/hosts/sunken-ship.nix @@ -106,6 +106,12 @@ # Web UI + Substreamer client on port 4533. services.navidrome = { enable = true; + # Bumped to 0.62.0 ahead of nixpkgs (#529720) for navidrome PR + # #5411 ("Relax playlist visibility in inPlaylist/notInPlaylist + # rules"). Without this the smart playlist Unrated (de-duped) + # silently keeps dupe-losers members. Drop this line + nixos/pkgs/ + # navidrome/ when nixpkgs-unstable has 0.62.x. + package = pkgs.callPackage ../pkgs/navidrome { }; settings = { Address = "0.0.0.0"; Port = 4533; diff --git a/nixos/pkgs/navidrome/default.nix b/nixos/pkgs/navidrome/default.nix new file mode 100644 index 0000000..3f1b5db --- /dev/null +++ b/nixos/pkgs/navidrome/default.nix @@ -0,0 +1,134 @@ +# Local bump of nixpkgs navidrome (0.61.2) to 0.62.0, ahead of the +# nixpkgs PR landing. Tracks NixOS/nixpkgs#529720 (tebriel) - identical +# patch (3 lines: version + src hash + vendorHash). +# +# Why bumped: 0.62.0 ships PR navidrome/navidrome#5411, which "Relax +# playlist visibility in inPlaylist/notInPlaylist rules" - lets a smart +# playlist owner reference their own PRIVATE playlists. Without it the +# operator silently matches no tracks for private references, which +# made `Unrated (de-duped)` retain all the dupe-losers members. +# +# REMOVE this file (and the services.navidrome.package line in +# sunken-ship.nix) once nixpkgs-unstable has 0.62.x. Check: +# nix-instantiate --eval -E '(import {}).navidrome.version' +{ + buildGoModule, + buildPackages, + fetchFromGitHub, + fetchNpmDeps, + fetchpatch, + lib, + nodejs_24, + npmHooks, + pkg-config, + stdenv, + ffmpeg-headless, + taglib, + zlib, + nixosTests, + nix-update-script, + ffmpegSupport ? true, + versionCheckHook, + plugins ? [ ], +}: + +buildGoModule (finalAttrs: { + pname = "navidrome"; + version = "0.62.0"; + + src = fetchFromGitHub { + owner = "navidrome"; + repo = "navidrome"; + rev = "v${finalAttrs.version}"; + hash = "sha256-pLhb2x3dGLsCk405rBVdMwazhf0EQd72VLKtlzGoJDA="; + }; + + vendorHash = "sha256-3ciCzFhJi4YTIjGbPJ2UP8mPzQe3vBgZ+Pc7Nto1LEw="; + + npmRoot = "ui"; + + npmDeps = fetchNpmDeps { + inherit (finalAttrs) src; + sourceRoot = "${finalAttrs.src.name}/ui"; + hash = "sha256-7hy2vLCEicKzjORpJZ0mrRS8PT3GsJ8DWdvj/7SrB70="; + }; + + nativeBuildInputs = [ + buildPackages.makeWrapper + nodejs_24 + npmHooks.npmConfigHook + pkg-config + ]; + + runtimeInputs = plugins; + + overrideModAttrs = oldAttrs: { + nativeBuildInputs = lib.filter (drv: drv != npmHooks.npmConfigHook) oldAttrs.nativeBuildInputs; + preBuild = null; + }; + + buildInputs = [ + taglib + zlib + ]; + + excludedPackages = [ + "plugins" + ]; + + ldflags = [ + "-X github.com/navidrome/navidrome/consts.gitSha=${finalAttrs.src.rev}" + "-X github.com/navidrome/navidrome/consts.gitTag=v${finalAttrs.version}" + ]; + + env = lib.optionalAttrs stdenv.cc.isGNU { + CGO_CFLAGS = toString [ "-Wno-return-local-addr" ]; + }; + + postPatch = '' + patchShebangs ui/bin/update-workbox.sh + ''; + + preBuild = '' + make buildjs + ''; + + postInstall = '' + mkdir -p $out/share/plugins/ + ${lib.concatMapStringsSep "\n" (plugin: '' + ln -s ${plugin}/share/${plugin.pname}.ndp $out/share/plugins/ + '') plugins} + ''; + + tags = [ + "netgo" + "sqlite_fts5" + ]; + + nativeInstallCheckInputs = [ versionCheckHook ]; + doInstallCheck = true; + + postFixup = lib.optionalString ffmpegSupport '' + wrapProgram $out/bin/navidrome \ + --prefix PATH : ${lib.makeBinPath [ ffmpeg-headless ]} + ''; + + passthru = { + inherit plugins; + tests.navidrome = nixosTests.navidrome; + updateScript = nix-update-script { }; + }; + + meta = { + description = "Music Server and Streamer compatible with Subsonic/Airsonic"; + mainProgram = "navidrome"; + homepage = "https://www.navidrome.org/"; + license = lib.licenses.gpl3Only; + sourceProvenance = with lib.sourceTypes; [ fromSource ]; + maintainers = with lib.maintainers; [ + aciceri + tebriel + ]; + broken = stdenv.hostPlatform.isDarwin; + }; +})