194 lines
5.7 KiB
Nix
194 lines
5.7 KiB
Nix
{
|
|
description = "Native high-performance, ultra-low-RAM Yandex Music desktop client in Rust";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
};
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
|
|
|
mkPackage = pkgs:
|
|
let
|
|
runtimeLibs = with pkgs; [
|
|
alsa-lib
|
|
libxkbcommon
|
|
wayland
|
|
xorg.libX11
|
|
xorg.libXcursor
|
|
xorg.libXi
|
|
xorg.libXrandr
|
|
vulkan-loader
|
|
libGL
|
|
libEGL
|
|
];
|
|
|
|
# Isolated OAuth WebView helper binary (requires GTK + WebKitGTK)
|
|
authHelper = pkgs.rustPlatform.buildRustPackage {
|
|
pname = "yandex-music-auth";
|
|
version = cargoToml.package.version;
|
|
src = self;
|
|
|
|
cargoLock = {
|
|
lockFile = ./Cargo.lock;
|
|
};
|
|
|
|
cargoBuildFlags = [
|
|
"--features"
|
|
"linux-webview"
|
|
"--bin"
|
|
"yandex-music-auth"
|
|
];
|
|
doCheck = false;
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
pkg-config
|
|
wrapGAppsHook3
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
alsa-lib
|
|
glib
|
|
gtk3
|
|
libsoup_3
|
|
openssl
|
|
webkitgtk_4_1
|
|
];
|
|
};
|
|
in
|
|
pkgs.rustPlatform.buildRustPackage {
|
|
pname = "yandex-music-rs";
|
|
version = cargoToml.package.version;
|
|
src = self;
|
|
|
|
cargoLock = {
|
|
lockFile = ./Cargo.lock;
|
|
};
|
|
|
|
cargoBuildFlags = [
|
|
"--bin"
|
|
"yandex-music-rs"
|
|
];
|
|
doCheck = false;
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
pkg-config
|
|
makeWrapper
|
|
];
|
|
|
|
buildInputs = runtimeLibs;
|
|
|
|
postInstall = ''
|
|
# Install isolated OAuth helper alongside main binary
|
|
cp -a ${authHelper}/bin/yandex-music-auth "$out/bin/yandex-music-auth"
|
|
|
|
# Ensure Vulkan, OpenGL, Wayland, X11, and ALSA shared libs are discoverable via dlopen
|
|
wrapProgram "$out/bin/yandex-music-rs" \
|
|
--prefix LD_LIBRARY_PATH : "${pkgs.lib.makeLibraryPath runtimeLibs}" \
|
|
--prefix PATH : "$out/bin"
|
|
|
|
# Desktop shortcut entry
|
|
install -Dm644 packaging/yandex-music-rs.desktop \
|
|
"$out/share/applications/yandex-music-rs.desktop"
|
|
substituteInPlace "$out/share/applications/yandex-music-rs.desktop" \
|
|
--replace-fail "Exec=/usr/bin/yandex-music-rs" "Exec=$out/bin/yandex-music-rs"
|
|
|
|
# Application icons (hicolor theme + pixmaps)
|
|
install -Dm644 assets/icons/app_icon.png \
|
|
"$out/share/pixmaps/yandex-music-rs.png"
|
|
install -Dm644 assets/icons/app_48.png \
|
|
"$out/share/icons/hicolor/48x48/apps/yandex-music-rs.png"
|
|
install -Dm644 packaging/icons/64x64.png \
|
|
"$out/share/icons/hicolor/64x64/apps/yandex-music-rs.png"
|
|
install -Dm644 packaging/icons/128x128.png \
|
|
"$out/share/icons/hicolor/128x128/apps/yandex-music-rs.png"
|
|
install -Dm644 packaging/icons/256x256.png \
|
|
"$out/share/icons/hicolor/256x256/apps/yandex-music-rs.png"
|
|
'';
|
|
|
|
meta = with pkgs.lib; {
|
|
description = cargoToml.package.description;
|
|
homepage = "https://git.tatar/marwy/yandex-music-rs";
|
|
platforms = supportedSystems;
|
|
mainProgram = "yandex-music-rs";
|
|
};
|
|
};
|
|
in
|
|
{
|
|
packages = forAllSystems (system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
{
|
|
default = mkPackage pkgs;
|
|
yandex-music-rs = mkPackage pkgs;
|
|
});
|
|
|
|
apps = forAllSystems (system: {
|
|
default = {
|
|
type = "app";
|
|
program = "${self.packages.${system}.default}/bin/yandex-music-rs";
|
|
};
|
|
});
|
|
|
|
overlays.default = final: _prev: {
|
|
yandex-music-rs = mkPackage final;
|
|
};
|
|
|
|
nixosModules.default = { config, lib, pkgs, ... }:
|
|
let
|
|
cfg = config.programs.yandex-music-rs;
|
|
in
|
|
{
|
|
options.programs.yandex-music-rs = {
|
|
enable = lib.mkEnableOption "Yandex Music native Rust desktop client";
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
|
description = "The yandex-music-rs package to install.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
environment.systemPackages = [ cfg.package ];
|
|
};
|
|
};
|
|
|
|
devShells = forAllSystems (system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
runtimeLibs = with pkgs; [
|
|
alsa-lib
|
|
libxkbcommon
|
|
wayland
|
|
xorg.libX11
|
|
xorg.libXcursor
|
|
xorg.libXi
|
|
xorg.libXrandr
|
|
vulkan-loader
|
|
libGL
|
|
libEGL
|
|
];
|
|
in
|
|
{
|
|
default = pkgs.mkShell {
|
|
nativeBuildInputs = with pkgs; [
|
|
cargo
|
|
rustc
|
|
pkg-config
|
|
];
|
|
buildInputs = runtimeLibs ++ (with pkgs; [
|
|
glib
|
|
gtk3
|
|
libsoup_3
|
|
openssl
|
|
webkitgtk_4_1
|
|
]);
|
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath runtimeLibs;
|
|
};
|
|
});
|
|
};
|
|
}
|