Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

spotube: init at 3.4.1 #282975

Merged
merged 1 commit into from Jan 29, 2024
Merged

spotube: init at 3.4.1 #282975

merged 1 commit into from Jan 29, 2024

Conversation

TomaSajt
Copy link
Contributor

@TomaSajt TomaSajt commented Jan 22, 2024

Description of changes

Related issue: #200120

This PR adds 1 package: spotube

I used the prebuilt binary distribution, as the flutter version of Nixpkgs is not low enough for building from source.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 馃憤 reaction to pull requests you find important.

@TomaSajt TomaSajt mentioned this pull request Jan 22, 2024
homepage = "https://spotube.netlify.app/";
license = lib.licenses.bsdOriginal;
maintainers = with lib.maintainers; [ tomasajt ];
platforms = [ "x86_64-linux" ];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if you naively add darwin Apple Silicon and Intel here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we are only fetching Spotube-linux-x86_64.deb from the prebuilt artifacts, so it's only going to work on x86_64-linux for now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this :)

@Steinhagen
Copy link
Contributor

Gave it a try again and everything is working as expected. Looks good!

@nephalemsec
Copy link
Contributor

nephalemsec commented Jan 23, 2024

I've made some amendments so that the darwin and linux derivations are in a single file:

{ stdenv, fetchurl, lib, makeDesktopItem, makeWrapper, undmg, autoPatchelfHook
, dpkg, wrapGAppsHook

, libappindicator, libnotify, libsecret, mpv-unwrapped, xdg-user-dirs }:
let
  pname = "spotube";
  version = "3.4.0";
  appname = "Spotube";
  meta = with lib; {
    description = ''
      An open source, cross-platform Spotify client compatible across multiple platforms
              utilizing Spotify's data API and YouTube (or Piped.video or JioSaavn) as an audio source,
              eliminating the need for Spotify Premium'';
    homepage = "https://spotube.netlify.app/";
    downloadPage = "https://github.com/KRTirtho/spotube/releases";
    license = licenses.bsdOriginal;
    maintainers = with lib.maintainers; [ tomasajt ];
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
  };

  filename = if stdenv.isDarwin then
    "${appname}-macos-universal.dmg"
  else
    "${appname}-linux-x86_64.deb";

  src = fetchurl {
    url =
      "https://github.com/KRTirtho/spotube/releases/download/v${version}/${filename}";
    hash = if stdenv.isDarwin then
      "sha256-dif2ec37QL9FVPGgqqvtB2zRX6P3NCth5FFnpASR/As="
    else
      "sha256-XBciTNWsmaY1C8ji+SCWWP/M/uIDZHM9fi9wucHJsBY=";
  };

  icon = fetchurl {
    url =
      "https://raw.githubusercontent.com/KRTirtho/spotube/nightly/assets/spotube-logo.png";
    hash = "sha256-gyzP3ynzuZFN0osmEAjwGfYmbfVxE9Nm2fLJ8q8G6BE=";
  };

  desktopItem = makeDesktopItem {
    name = "${pname}";
    desktopName = "${appname}";
    comment = "An open source spotify client.";
    icon = "${pname}";
    exec = "feishin %U";
    categories = [ "Audio" ];
    mimeTypes = [ "x-scheme-handler/${pname}" ];
  };

  darwin = stdenv.mkDerivation {
    inherit pname version src appname;

    meta = meta // { platforms = [ "x86_64-darwin" "aarch64-darwin" ]; };

    sourceRoot = "${appname}.app";
    nativeBuildInputs = [ makeWrapper undmg ];
    installPhase = ''
      runHook preInstall
      mkdir -p $out/{Applications/${appname}.app,bin}
      cp -R . $out/Applications/${appname}.app
      makeWrapper $out/Applications/${appname}.app/Contents/MacOS/${appname} $out/bin/${pname}
      runHook postInstall
    '';
  };

  linux = stdenv.mkDerivation {
    inherit pname version src appname;

    meta = meta // { platforms = [ "x86_64-linux" ]; };

    nativeBuildInputs = [ autoPatchelfHook dpkg makeWrapper wrapGAppsHook ];

    buildInputs = [ libappindicator libnotify libsecret mpv-unwrapped ];

    dontWrapGApps = true;

    installPhase = ''
      runHook preInstall
      mkdir -p $out
      mv usr/* $out
      runHook postInstall
    '';

    preFixup = ''
      patchelf $out/share/spotube/lib/libmedia_kit_native_event_loop.so \
          --replace-needed libmpv.so.1 libmpv.so.2
    '';

    postFixup = ''
      makeWrapper $out/share/spotube/spotube $out/bin/spotube \
          "''${gappsWrapperArgs[@]}" \
          --prefix LD_LIBRARY_PATH : $out/share/spotube/lib:${
            lib.makeLibraryPath [ mpv-unwrapped ]
          } \
          --prefix PATH : ${lib.makeBinPath [ xdg-user-dirs ]}
    '';
  };

in if stdenv.isDarwin then darwin else linux

I'm not on my linux boxen atm so I'm assuming your above derivation builds correctly and just modularised it. Appreciate the effort you put in <3

N.B the desktopItem is redundant, but left it in there just in case the linux derivation doesn't make one in current state.

Copy link
Member

@tomodachi94 tomodachi94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, but 3.4.1 just got released so we might want to update to that before we merge this PR.

@SuperSandro2000 SuperSandro2000 changed the title spotube: init at 3.4.0 spotube: init at 3.4.1 Jan 29, 2024
@SuperSandro2000 SuperSandro2000 merged commit 4be50ec into NixOS:master Jan 29, 2024
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants