From ec926bad0f1b26a540cfe923282b34a9d2c58a54 Mon Sep 17 00:00:00 2001 From: Yury Shvedov Date: Sun, 9 Mar 2025 16:21:15 +0300 Subject: [PATCH 1/3] nix: fix-up nixpkgs input version in flake --- flake.lock | 26 ++++++++++++++------------ flake.nix | 2 ++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index d971b43..bb6015c 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -19,16 +19,18 @@ }, "nixpkgs": { "locked": { - "lastModified": 1708093448, - "narHash": "sha256-gohEm3/NVyu7WINFhRf83yJH8UM2ie/KY9Iw3VN6fiE=", - "owner": "NixOS", + "lastModified": 1741379970, + "narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "c7763249f02b7786b4ca36e13a4d7365cfba162f", + "rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f", "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { @@ -56,13 +58,13 @@ "ymExe": { "flake": false, "locked": { - "narHash": "sha256-JPwe9Pqwytze3O1lB9yzeA3Th+Ni9ZVuOjjCa8BwH9s=", + "narHash": "sha256-4rhdb0Mz3LosMj0GlIkOuryNXcLl+DSOp+WIe30a1lY=", "type": "file", - "url": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.39.0.exe" + "url": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.41.1.exe" }, "original": { "type": "file", - "url": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.39.0.exe" + "url": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.41.1.exe" } } }, diff --git a/flake.nix b/flake.nix index 6c66caf..ec82792 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,8 @@ inputs = { ymExe.url = "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.41.1.exe"; ymExe.flake = false; + + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; }; outputs = { self, ymExe, nixpkgs, flake-utils }: From d45af61f820d60ab72a137c2e925558b412ca2ac Mon Sep 17 00:00:00 2001 From: Yury Shvedov Date: Sun, 9 Mar 2025 16:24:22 +0300 Subject: [PATCH 2/3] nix: perform autoformatting --- flake.nix | 44 +++++++++++++++++----------- nix/default.nix | 76 +++++++++++++++++++++++++++---------------------- nix/module.nix | 28 +++++++++++------- 3 files changed, 87 insertions(+), 61 deletions(-) diff --git a/flake.nix b/flake.nix index ec82792..7c3b33a 100644 --- a/flake.nix +++ b/flake.nix @@ -8,11 +8,19 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; }; - outputs = { self, ymExe, nixpkgs, flake-utils }: + outputs = + { + self, + ymExe, + nixpkgs, + flake-utils, + }: let - yandex-music-with = pkgs: pkgs.callPackage ./nix { - inherit ymExe; - }; + yandex-music-with = + pkgs: + pkgs.callPackage ./nix { + inherit ymExe; + }; modules = isHm: rec { yandex-music = { imports = [ (import ./nix/module.nix { inherit isHm yandex-music-with; }) ]; @@ -20,19 +28,21 @@ default = yandex-music; }; in - flake-utils.lib.eachDefaultSystem - (system: - let - pkgs = import nixpkgs { inherit system; }; - in - { - packages = rec { - yandex-music = yandex-music-with pkgs; - yandex-music-noflakes = pkgs.callPackage ./nix { }; - default = yandex-music; - }; - } - ) // { + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + packages = rec { + yandex-music = yandex-music-with pkgs; + yandex-music-noflakes = pkgs.callPackage ./nix { }; + default = yandex-music; + }; + formatter = pkgs.nixfmt-rfc-style; + } + ) + // { nixosModules = modules false; homeManagerModules = modules true; diff --git a/nix/default.nix b/nix/default.nix index 193dbae..c80ce83 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,22 +1,23 @@ -{ fetchurl -, stdenvNoCC -, lib -, makeWrapper +{ + fetchurl, + stdenvNoCC, + lib, + makeWrapper, -, p7zip -, asar -, jq -, python3 -, electron + p7zip, + asar, + jq, + python3, + electron, -, ymExe ? null -, electronArguments ? "" -, trayEnabled ? false -, trayStyle ? 1 -, trayAlways ? false -, devTools ? false -, vibeAnimationMaxFps ? 25 -, customTitleBar ? false + ymExe ? null, + electronArguments ? "", + trayEnabled ? false, + trayStyle ? 1, + trayAlways ? false, + devTools ? false, + vibeAnimationMaxFps ? 25, + customTitleBar ? false, }: let inherit (lib) optionalString assertMsg; @@ -24,8 +25,7 @@ let in assert assertMsg (trayStyle >= 1 && trayStyle <= 3) "Tray style must be withing 1 and 3"; assert assertMsg (vibeAnimationMaxFps >= 0) "Vibe animation max FPS must be greater then 0"; -stdenvNoCC.mkDerivation -{ +stdenvNoCC.mkDerivation { name = "yandex-music"; inherit (version_info.ym) version; @@ -44,8 +44,8 @@ stdenvNoCC.mkDerivation desktopItem = ../templates/desktop; ymScript = ../templates/yandex-music.sh; src = - if ymExe != null - then ymExe + if ymExe != null then + ymExe else fetchurl { url = version_info.ym.exe_link; @@ -61,18 +61,23 @@ stdenvNoCC.mkDerivation ''; dontPatch = true; - config ='' - ELECTRON_ARGS="${electronArguments}" - VIBE_ANIMATION_MAX_FPS=${toString vibeAnimationMaxFps} - '' + optionalString trayEnabled '' - TRAY_ENABLED=${toString trayStyle} - '' + optionalString trayAlways '' - ALWAYS_LEAVE_TO_TRAY=1 - '' + optionalString devTools '' - DEV_TOOLS=1 - '' + optionalString customTitleBar '' - CUSTOM_TITLE_BAR=1 - ''; + config = + '' + ELECTRON_ARGS="${electronArguments}" + VIBE_ANIMATION_MAX_FPS=${toString vibeAnimationMaxFps} + '' + + optionalString trayEnabled '' + TRAY_ENABLED=${toString trayStyle} + '' + + optionalString trayAlways '' + ALWAYS_LEAVE_TO_TRAY=1 + '' + + optionalString devTools '' + DEV_TOOLS=1 + '' + + optionalString customTitleBar '' + CUSTOM_TITLE_BAR=1 + ''; installPhase = '' mkdir -p "$out/share/nodejs" @@ -101,7 +106,10 @@ stdenvNoCC.mkDerivation homepage = "https://music.yandex.ru/"; downloadPage = "https://music.yandex.ru/download/"; license = lib.licenses.unfree; - platforms = [ "x86_64-linux" "aarch64-linux" ]; + platforms = [ + "x86_64-linux" + "aarch64-linux" + ]; maintainers = [ { name = "Yury Shvedov"; diff --git a/nix/module.nix b/nix/module.nix index 76f3e76..5c3ccc7 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -1,19 +1,27 @@ -{ yandex-music-with -, isHm ? false +{ + yandex-music-with, + isHm ? false, +}: +{ + lib, + pkgs, + config, + ... }: -{ lib, pkgs, config, ... }: let cfg = config.programs.yandex-music; in { - imports = [{ - nixpkgs.overlays = [ - (final: prev: { - yandex-music = yandex-music-with prev; - }) - ]; - }]; + imports = [ + { + nixpkgs.overlays = [ + (final: prev: { + yandex-music = yandex-music-with prev; + }) + ]; + } + ]; options = { programs.yandex-music = { From c5a4204f17bd2612afbd6582607788cf0b0984a9 Mon Sep 17 00:00:00 2001 From: Yury Shvedov Date: Tue, 11 Mar 2025 20:08:54 +0300 Subject: [PATCH 3/3] github/actions: add format checks --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66bf3e5..72a0f85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,8 +96,12 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v2 + - name: Check formatting + run: nix fmt -- -c . + - name: Build yandex-music run: nix build --impure .#yandex-music + - name: Build yandex-music without flakes binaries run: nix build --impure .#yandex-music-noflakes