mirror of
https://github.com/cucumber-sp/yandex-music-linux.git
synced 2024-12-23 14:12: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
|
||||
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
|
||||
```
|
||||
|
@ -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" *
|
||||
|
20
flake.nix
20
flake.nix
@ -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:
|
||||
@ -20,21 +26,13 @@
|
||||
{
|
||||
packages = rec {
|
||||
yandex-music = yandex-music-with pkgs;
|
||||
yandex-music-noflakes = pkgs.callPackage ./nix {};
|
||||
yandex-music-noflakes = pkgs.callPackage ./nix { };
|
||||
default = yandex-music;
|
||||
};
|
||||
}
|
||||
) // {
|
||||
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;
|
||||
};
|
||||
|
@ -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
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"
|
||||
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}
|
||||
|
||||
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