From 1a18e654a25c28243545e18e9f880cfed46f7a44 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov <74188979+s-and-witch@users.noreply.github.com> Date: Wed, 22 Nov 2023 19:28:15 +0400 Subject: [PATCH] Add nix support (#45) --- .gitignore | 3 +++ README.md | 5 +++++ flake.lock | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 3dc461a..fcca57a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ [._]ss[a-gi-z] [._]sw[a-p] +# nix build +result + # Session Session.vim Sessionx.vim diff --git a/README.md b/README.md index 51229ff..e5b2618 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,11 @@ git clone https://github.com/kaimi-io/yandex-music-download.git cd yandex-music-download/src perl ya.pl -h ``` +### Nix / NixOS +```bash +nix shell github:kaimi-io/yandex-music-download +ya-music -h +``` ### MacOS 1. Install brew (https://brew.sh/). 2. Run: diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a469960 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1700650476, + "narHash": "sha256-V269pVJbPgXDdwCA6f2LRcIsnKg9K/RPE5gyxKkxty4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cb502b4d17fb2912444b0b6e9813f71ba2ebbfd9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9d82b01 --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = {self, nixpkgs, flake-utils}: flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + packages.default = pkgs.stdenv.mkDerivation + { + name = "yandex-download-music"; + version = "v1.5"; + src = ./.; + + nativeBuildInputs = [ + pkgs.makeWrapper + ]; + + buildInputs = [ + pkgs.perl + (pkgs.buildEnv { + name = "rt-perl-deps"; + paths = with pkgs.perlPackages; (requiredPerlModules [ + FileUtil + MP3Tag + GetoptLongDescriptive LWPUserAgent + LWPProtocolHttps + HTTPCookies + MozillaCA + ]); + }) + ]; + + installPhase = '' + mkdir -p $out/bin + cp src/ya.pl $out/bin/ya-music + # cat src/ya.pl | perl -p -e "s/basename\(__FILE__\)/'ya-music'/g" > $out/bin/ya-music + # chmod +x $out/bin/ya-music + ''; + + postFixup = '' + # wrapProgram will rename ya-music into .ya-music-wrapped + # so replace all __FILE__ calls + substituteInPlace $out/bin/ya-music \ + --replace "basename(__FILE__)" "'ya-music'" + + wrapProgram $out/bin/ya-music \ + --prefix PERL5LIB : $PERL5LIB + ''; + }; + }); + +}