mirror of
https://github.com/cucumber-sp/yandex-music-linux.git
synced 2024-12-23 22:22:59 +03:00
[nix] Fix configuration
Reuse common shell for nix package. Add options for nix-way configuration of yandex music. Change-Id: I71a209a8ca8b5e3c5c08349b8da5ba91182a919e
This commit is contained in:
parent
e774ea65d9
commit
d1984db95c
27
README.md
27
README.md
@ -244,27 +244,24 @@ nix-build --expr '(import <nixpkgs> {}).callPackage ./nix {}'
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Import module in your `configuration.nix` or `home-manager.nix`
|
2. Import module in your `configuration.nix`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
imports = [
|
imports = [
|
||||||
yandex-music.nixosModule
|
yandex-music.nixosModules.default
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Add package `yandex-music`
|
or in `home-manager.nix`:
|
||||||
|
```nix
|
||||||
|
imports = [
|
||||||
|
yandex-music.homeManagerModules.default
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
For `configuration.nix`:
|
|
||||||
|
3. Enable `yandex-music`
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
environment.systemPackages = with pkgs; [
|
programs.yandex-music.enable = true;
|
||||||
yandex-music
|
programs.yandex-music.tray.enable = true; # to enable tray support
|
||||||
];
|
|
||||||
```
|
|
||||||
For Home Manager:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
home.packages = with pkgs; [
|
|
||||||
yandex-music
|
|
||||||
];
|
|
||||||
```
|
```
|
||||||
|
@ -42,6 +42,7 @@ build_tarball(){
|
|||||||
|
|
||||||
install -Dm755 "./templates/yandex-music.sh" "${app_dir}/usr/bin/yandex-music"
|
install -Dm755 "./templates/yandex-music.sh" "${app_dir}/usr/bin/yandex-music"
|
||||||
sed -i "s|%electron_path%|/usr/lib/yandex-music/electron/electron|g" "${app_dir}/usr/bin/yandex-music"
|
sed -i "s|%electron_path%|/usr/lib/yandex-music/electron/electron|g" "${app_dir}/usr/bin/yandex-music"
|
||||||
|
sed -i "s|%asar_path%|/usr/lib/yandex-music/yandex-music.asar|g" "${app_dir}/usr/bin/yandex-music"
|
||||||
|
|
||||||
cd "${app_dir}"
|
cd "${app_dir}"
|
||||||
tar -czf "${OUTPUT_DIR}/yandex-music_${version}_${arch}.tar.gz" *
|
tar -czf "${OUTPUT_DIR}/yandex-music_${version}_${arch}.tar.gz" *
|
||||||
|
20
flake.nix
20
flake.nix
@ -11,6 +11,12 @@
|
|||||||
yandex-music-with = pkgs: pkgs.callPackage ./nix {
|
yandex-music-with = pkgs: pkgs.callPackage ./nix {
|
||||||
inherit ymExe;
|
inherit ymExe;
|
||||||
};
|
};
|
||||||
|
modules = isHm: rec {
|
||||||
|
yandex-music = {
|
||||||
|
imports = [ (import ./nix/module.nix { inherit isHm yandex-music-with; }) ];
|
||||||
|
};
|
||||||
|
default = yandex-music;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
flake-utils.lib.eachDefaultSystem
|
flake-utils.lib.eachDefaultSystem
|
||||||
(system:
|
(system:
|
||||||
@ -20,21 +26,13 @@
|
|||||||
{
|
{
|
||||||
packages = rec {
|
packages = rec {
|
||||||
yandex-music = yandex-music-with pkgs;
|
yandex-music = yandex-music-with pkgs;
|
||||||
yandex-music-noflakes = pkgs.callPackage ./nix {};
|
yandex-music-noflakes = pkgs.callPackage ./nix { };
|
||||||
default = yandex-music;
|
default = yandex-music;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
) // {
|
) // {
|
||||||
nixosModules = rec {
|
nixosModules = modules false;
|
||||||
yandex-music = {
|
homeManagerModules = modules true;
|
||||||
nixpkgs.overlays = [
|
|
||||||
(final: prev: {
|
|
||||||
yandex-music = yandex-music-with prev;
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
default = yandex-music;
|
|
||||||
};
|
|
||||||
|
|
||||||
nixosModule = self.nixosModules.default;
|
nixosModule = self.nixosModules.default;
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
, electron
|
, electron
|
||||||
|
|
||||||
, ymExe ? null
|
, ymExe ? null
|
||||||
|
, electronArguments ? ""
|
||||||
|
, trayEnabled ? false
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
version_info = with builtins; fromJSON (readFile ../utility/version_info.json);
|
version_info = with builtins; fromJSON (readFile ../utility/version_info.json);
|
||||||
@ -32,6 +34,7 @@ stdenvNoCC.mkDerivation
|
|||||||
utility = ./../utility;
|
utility = ./../utility;
|
||||||
icons = ./../icons;
|
icons = ./../icons;
|
||||||
desktopItem = ../templates/desktop;
|
desktopItem = ../templates/desktop;
|
||||||
|
ymScript = ../templates/yandex-music.sh;
|
||||||
src =
|
src =
|
||||||
if ymExe != null
|
if ymExe != null
|
||||||
then ymExe
|
then ymExe
|
||||||
@ -54,10 +57,17 @@ stdenvNoCC.mkDerivation
|
|||||||
mkdir -p "$out/share/nodejs"
|
mkdir -p "$out/share/nodejs"
|
||||||
mv app/yandex-music.asar "$out/share/nodejs"
|
mv app/yandex-music.asar "$out/share/nodejs"
|
||||||
|
|
||||||
# use makeWrapper on electron binary to make it call our asar package
|
CONFIG_FILE="$out/share/yandex-music.conf"
|
||||||
makeWrapper "${electron}/bin/electron" "$out/bin/yandex-music" \
|
echo "TRAY_ENABLED=${if trayEnabled then "1" else "0"}" >> "$CONFIG_FILE"
|
||||||
--add-flags "$out/share/nodejs/yandex-music.asar" \
|
echo "ELECTRON_ARGS=\"${electronArguments}\"" >> "$CONFIG_FILE"
|
||||||
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
|
|
||||||
|
|
||||||
|
install -Dm755 "$ymScript" "$out/bin/yandex-music"
|
||||||
|
sed -i "s|%electron_path%|${electron}/bin/electron|g" "$out/bin/yandex-music"
|
||||||
|
sed -i "s|%asar_path%|$out/share/nodejs/yandex-music.asar|g" "$out/bin/yandex-music"
|
||||||
|
|
||||||
|
wrapProgram "$out/bin/yandex-music" \
|
||||||
|
--set-default YANDEX_MUSIC_CONFIG "$CONFIG_FILE"
|
||||||
|
|
||||||
install -Dm644 "./app/favicon.png" "$out/share/pixmaps/yandex-music.png"
|
install -Dm644 "./app/favicon.png" "$out/share/pixmaps/yandex-music.png"
|
||||||
install -Dm644 "./app/favicon.png" "$out/share/icons/hicolor/48x48/apps/yandex-music.png"
|
install -Dm644 "./app/favicon.png" "$out/share/icons/hicolor/48x48/apps/yandex-music.png"
|
||||||
|
53
nix/module.nix
Normal file
53
nix/module.nix
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
{ yandex-music-with
|
||||||
|
, isHm ? false
|
||||||
|
}:
|
||||||
|
{ lib, pkgs, config, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.programs.yandex-music;
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [{
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
yandex-music = yandex-music-with prev;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}];
|
||||||
|
|
||||||
|
options = {
|
||||||
|
programs.yandex-music = {
|
||||||
|
enable = lib.mkEnableOption "yandex music application";
|
||||||
|
tray.enable = lib.mkEnableOption "tray icon for yandex music application";
|
||||||
|
electronArguments = lib.mkOption {
|
||||||
|
description = "Extra electron arguments";
|
||||||
|
example = "--no-sandbox --trace-warnings";
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
|
package = lib.mkOption {
|
||||||
|
description = "Finalized package of yandex music application";
|
||||||
|
type = lib.types.package;
|
||||||
|
default = pkgs.yandex-music.override {
|
||||||
|
trayEnabled = cfg.tray.enable;
|
||||||
|
electronArguments = cfg.electronArguments;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable (
|
||||||
|
if isHm then
|
||||||
|
{
|
||||||
|
home.packages = [
|
||||||
|
cfg.package
|
||||||
|
];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
environment.systemPackages = [
|
||||||
|
cfg.package
|
||||||
|
];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
@ -36,4 +36,5 @@ package() {
|
|||||||
|
|
||||||
install -Dm755 "$srcdir/yandex-music-linux/templates/yandex-music.sh" "$pkgdir/usr/bin/yandex-music"
|
install -Dm755 "$srcdir/yandex-music-linux/templates/yandex-music.sh" "$pkgdir/usr/bin/yandex-music"
|
||||||
sed -i "s|%electron_path%|/usr/bin/electron29|g" "$pkgdir/usr/bin/yandex-music"
|
sed -i "s|%electron_path%|/usr/bin/electron29|g" "$pkgdir/usr/bin/yandex-music"
|
||||||
|
sed -i "s|%asar_path%|/usr/lib/yandex-music/yandex-music.asar|g" "$pkgdir/usr/bin/yandex-music"
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,4 @@ ELECTRON_BIN=${ELECTRON_CUSTOM_BIN:-%electron_path%}
|
|||||||
|
|
||||||
export TRAY_ENABLED=${TRAY_ENABLED:-0}
|
export TRAY_ENABLED=${TRAY_ENABLED:-0}
|
||||||
|
|
||||||
exec "${ELECTRON_BIN}" "/usr/lib/yandex-music/yandex-music.asar" $ELECTRON_ARGS $WAYLAND_FLAGS
|
exec "${ELECTRON_BIN}" "%asar_path%" $ELECTRON_ARGS $WAYLAND_FLAGS
|
||||||
|
Loading…
Reference in New Issue
Block a user