{ description = "Spotify, native and fast"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # rust-toolchain.toml pins the compiler so local builds and CI agree. # This reads that file rather than restating the version here. rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, rust-overlay, ... }: let systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems ( system: f ( import nixpkgs { inherit system; overlays = [ (import rust-overlay) ]; } ) ); in { devShells = forAllSystems (pkgs: { default = pkgs.mkShell { packages = with pkgs; [ (rust-bin.fromRustupToolchainFile ./rust-toolchain.toml) rust-analyzer pkg-config # libprojectM (MilkDrop) is built from source by CMake, and its # bindings by bindgen, which needs libclang. cmake rustPlatform.bindgenHook ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk ] ++ lib.optionals stdenv.hostPlatform.isLinux [ alsa-lib libpulseaudio libxkbcommon wayland libGL libx11 libxcursor libxi libxrandr ]; # The GUI dlopens its Wayland, X11 and GL libraries at run time. LD_LIBRARY_PATH = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux ( pkgs.lib.makeLibraryPath ( with pkgs; [ libxkbcommon wayland libGL libx11 libxcursor libxi libxrandr ] ) ); }; }); packages = forAllSystems (pkgs: rec { default = fastpotify; fastpotify = let toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; rustPlatform = pkgs.makeRustPlatform { cargo = toolchain; rustc = toolchain; }; runtimeLibs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux ( with pkgs; [ libxkbcommon wayland libGL libx11 libxcursor libxi libxrandr ] ); in rustPlatform.buildRustPackage { pname = "fastpotify"; version = (pkgs.lib.importTOML ./Cargo.toml).package.version; src = self; cargoLock.lockFile = ./Cargo.lock; nativeBuildInputs = with pkgs; [ pkg-config # libprojectM (MilkDrop) is built from source by CMake, and # its bindings by bindgen, which needs libclang. cmake rustPlatform.bindgenHook ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ makeWrapper ]; buildInputs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux ( with pkgs; [ alsa-lib libpulseaudio # libprojectM links OpenGL directly. libGL ] ) ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ pkgs.apple-sdk ]; # The GUI dlopens its Wayland, X11 and GL libraries at run time. postFixup = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux '' wrapProgram $out/bin/fastpotify \ --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath runtimeLibs} ''; postInstall = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux '' install -Dm644 packaging/applications/fastpotify.desktop \ $out/share/applications/fastpotify.desktop install -Dm644 packaging/icons/fastpotify.svg \ $out/share/icons/hicolor/scalable/apps/fastpotify.svg ''; meta = { description = "Fast native Spotify client with local playback and Spotify Connect"; homepage = "https://fastpotify.rocks"; license = pkgs.lib.licenses.mit; mainProgram = "fastpotify"; }; }; }); formatter = forAllSystems (pkgs: pkgs.nixfmt-tree); }; }