0
0
mirror of https://github.com/cucumber-sp/yandex-music-linux.git synced 2024-12-23 22:22:59 +03:00

Merge pull request #79 from ein-shved/master

[nix] Fix configuration
This commit is contained in:
Andrey Onischenko 2024-05-22 18:36:56 +03:00 committed by GitHub
commit 5b9fd6fa77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 111 additions and 51 deletions

View File

@ -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
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
environment.systemPackages = with pkgs; [
yandex-music
];
```
For Home Manager:
```nix
home.packages = with pkgs; [
yandex-music
];
programs.yandex-music.enable = true;
programs.yandex-music.tray.enable = true; # to enable tray support
```

View File

@ -42,6 +42,7 @@ build_tarball(){
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|%asar_path%|/usr/lib/yandex-music/yandex-music.asar|g" "${app_dir}/usr/bin/yandex-music"
cd "${app_dir}"
tar -czf "${OUTPUT_DIR}/yandex-music_${version}_${arch}.tar.gz" *

View File

@ -11,6 +11,12 @@
yandex-music-with = pkgs: pkgs.callPackage ./nix {
inherit ymExe;
};
modules = isHm: rec {
yandex-music = {
imports = [ (import ./nix/module.nix { inherit isHm yandex-music-with; }) ];
};
default = yandex-music;
};
in
flake-utils.lib.eachDefaultSystem
(system:
@ -25,16 +31,8 @@
};
}
) // {
nixosModules = rec {
yandex-music = {
nixpkgs.overlays = [
(final: prev: {
yandex-music = yandex-music-with prev;
})
];
};
default = yandex-music;
};
nixosModules = modules false;
homeManagerModules = modules true;
nixosModule = self.nixosModules.default;
};

View File

@ -10,6 +10,8 @@
, electron
, ymExe ? null
, electronArguments ? ""
, trayEnabled ? false
}:
let
version_info = with builtins; fromJSON (readFile ../utility/version_info.json);
@ -32,6 +34,7 @@ stdenvNoCC.mkDerivation
utility = ./../utility;
icons = ./../icons;
desktopItem = ../templates/desktop;
ymScript = ../templates/yandex-music.sh;
src =
if ymExe != null
then ymExe
@ -54,10 +57,17 @@ stdenvNoCC.mkDerivation
mkdir -p "$out/share/nodejs"
mv app/yandex-music.asar "$out/share/nodejs"
# use makeWrapper on electron binary to make it call our asar package
makeWrapper "${electron}/bin/electron" "$out/bin/yandex-music" \
--add-flags "$out/share/nodejs/yandex-music.asar" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
CONFIG_FILE="$out/share/yandex-music.conf"
echo "TRAY_ENABLED=${if trayEnabled then "1" else "0"}" >> "$CONFIG_FILE"
echo "ELECTRON_ARGS=\"${electronArguments}\"" >> "$CONFIG_FILE"
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/icons/hicolor/48x48/apps/yandex-music.png"

53
nix/module.nix Normal file
View 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
];
}
);
}

View File

@ -36,4 +36,5 @@ package() {
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|%asar_path%|/usr/lib/yandex-music/yandex-music.asar|g" "$pkgdir/usr/bin/yandex-music"
}

View File

@ -24,4 +24,4 @@ ELECTRON_BIN=${ELECTRON_CUSTOM_BIN:-%electron_path%}
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