mirror of
https://github.com/cucumber-sp/yandex-music-linux.git
synced 2024-12-24 14:34:39 +03:00
[nix] Prettify code
* Make all build with one mkDerivation procedure * Use version from version_info.json file * Add meta field * Use version_info.json to download exe file if none given * Add noflake version for testing previous * Use common desktop file * Install icon with package Change-Id: I2fecc74859f3c788161bb2f96bd5aa950d6433ae
This commit is contained in:
parent
9464224efb
commit
9363d12ba7
11
flake.nix
11
flake.nix
@ -6,7 +6,7 @@
|
|||||||
};
|
};
|
||||||
outputs = { self, ymExe, nixpkgs, flake-utils }:
|
outputs = { self, ymExe, nixpkgs, flake-utils }:
|
||||||
let
|
let
|
||||||
yandex-music-with = pkgs: pkgs.callPackage ./nix {
|
yandexmusic-with = pkgs: pkgs.callPackage ./nix {
|
||||||
inherit ymExe;
|
inherit ymExe;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
@ -17,19 +17,20 @@
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = rec {
|
packages = rec {
|
||||||
yandex-music = yandex-music-with pkgs;
|
yandexmusic = yandexmusic-with pkgs;
|
||||||
yandex-music-backgroud = yandex-music.override {
|
yandexmusic-backgroud = yandexmusic.override {
|
||||||
fixQuit = false;
|
fixQuit = false;
|
||||||
};
|
};
|
||||||
|
yandexmusic-noflakes = pkgs.callPackage ./nix {};
|
||||||
generate_packages = pkgs.callPackage ./nix/generate_packages.nix {};
|
generate_packages = pkgs.callPackage ./nix/generate_packages.nix {};
|
||||||
default = yandex-music;
|
default = yandexmusic;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
) // {
|
) // {
|
||||||
modules = [{
|
modules = [{
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
(final: prev: {
|
(final: prev: {
|
||||||
yandex-music = yandex-music-with prev;
|
yandexmusic = yandexmusic-with prev;
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}];
|
}];
|
||||||
|
107
nix/default.nix
107
nix/default.nix
@ -1,48 +1,81 @@
|
|||||||
{ fetchurl
|
{ fetchurl
|
||||||
, runCommand
|
, stdenvNoCC
|
||||||
, writeShellApplication
|
, lib
|
||||||
, makeDesktopItem
|
, makeWrapper
|
||||||
, symlinkJoin
|
|
||||||
|
|
||||||
, p7zip
|
, p7zip
|
||||||
, asar
|
, asar
|
||||||
, electron
|
|
||||||
, jq
|
, jq
|
||||||
|
, electron
|
||||||
|
|
||||||
, ymExe
|
, ymExe ? null
|
||||||
, fixQuit ? true
|
, fixQuit ? true
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
app = runCommand "yandex-music-app"
|
version_info = with builtins; fromJSON (readFile ../version_info.json);
|
||||||
{
|
|
||||||
nativeBuildInputs = [ p7zip asar jq ];
|
|
||||||
repack = ./../repack.sh;
|
|
||||||
src = ymExe;
|
|
||||||
} ''
|
|
||||||
bash "$repack" ${if !fixQuit then "-q" else ""} -o "$out" "$src"
|
|
||||||
'';
|
|
||||||
launcher = writeShellApplication {
|
|
||||||
name = "yandex-music";
|
|
||||||
runtimeInputs = [ electron ];
|
|
||||||
text = ''
|
|
||||||
electron ${app}/yandexmusic.asar "$@"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
desktopItem = makeDesktopItem {
|
|
||||||
name = "yandex-music";
|
|
||||||
desktopName = "Yandex Music";
|
|
||||||
comment = "Yandex Music - we collect music for you";
|
|
||||||
exec = "${launcher}/bin/yandex-music";
|
|
||||||
terminal = false;
|
|
||||||
icon = "${app}/favicon.svg";
|
|
||||||
categories = [ "Audio" "Music" "Player" "AudioVideo" ];
|
|
||||||
extraConfig = {
|
|
||||||
"Name[ru]" = "Яндекс Музыка";
|
|
||||||
"Comment[ru]" = "Яндекс Музыка — собираем музыку для вас";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
symlinkJoin {
|
stdenvNoCC.mkDerivation
|
||||||
name = "yandex-music";
|
{
|
||||||
paths = [ launcher desktopItem ];
|
name = "yandexmusic";
|
||||||
|
inherit (version_info) version;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
p7zip
|
||||||
|
asar
|
||||||
|
jq
|
||||||
|
makeWrapper
|
||||||
|
];
|
||||||
|
|
||||||
|
repack = ./../repack.sh;
|
||||||
|
desktopItem = ../templates/desktop;
|
||||||
|
src =
|
||||||
|
if ymExe != null
|
||||||
|
then ymExe
|
||||||
|
else
|
||||||
|
fetchurl {
|
||||||
|
url = version_info.exe_link;
|
||||||
|
sha256 = version_info.exe_sha256;
|
||||||
|
};
|
||||||
|
|
||||||
|
unpackPhase = ''
|
||||||
|
bash "$repack" ${if !fixQuit then "-q" else ""} -o "./app" "$src"
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p "$out/share/nodejs"
|
||||||
|
mv app/yandexmusic.asar "$out/share/nodejs"
|
||||||
|
|
||||||
|
# use makeWrapper on electron binary to make it call our asar package
|
||||||
|
makeWrapper "${electron}/bin/electron" "$out/bin/yandexmusic" \
|
||||||
|
--add-flags "$out/share/nodejs/yandexmusic.asar"
|
||||||
|
|
||||||
|
mkdir -p "$out/share/pixmaps"
|
||||||
|
mkdir -p "$out/share/icons/hicolor/48x48/apps/"
|
||||||
|
cp ./app/favicon.png "$out/share/icons/hicolor/48x48/apps/yandexmusic.png"
|
||||||
|
ln -s ../icons/hicolor/48x48/apps/yandexmusic.png "$out/share/pixmaps"
|
||||||
|
|
||||||
|
mkdir -p $out/share/applications
|
||||||
|
cp $desktopItem $out/share/applications/yandexmusic.desktop
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Yandex Music - Personal recommendations, selections for any occasion and new music";
|
||||||
|
homepage = "https://music.yandex.ru/";
|
||||||
|
downloadPage = "https://music.yandex.ru/download/";
|
||||||
|
license = lib.licenses.unfree;
|
||||||
|
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
||||||
|
maintainers = [
|
||||||
|
{
|
||||||
|
name = "Yury Shvedov";
|
||||||
|
email = "mestofel13@gmail.com";
|
||||||
|
github = "ein-shved";
|
||||||
|
githubId = 3513222;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
github = "cucumber-sp";
|
||||||
|
githubId = 100789522;
|
||||||
|
name = "Andrey Onishchenko";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user