From 0376023e7d60261eae59eb44ba660344848ba75c Mon Sep 17 00:00:00 2001 From: xjathie87 <165120461+xjathie87@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:17:24 +0000 Subject: [PATCH] add apps to support the nix run command (#46) --- flake.nix | 89 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/flake.nix b/flake.nix index 9d82b01..a05bf24 100644 --- a/flake.nix +++ b/flake.nix @@ -7,50 +7,51 @@ outputs = {self, nixpkgs, flake-utils}: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; + yaMusic = 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 + ''; + }; 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 - ''; - }; - }); - + packages.default = yaMusic; + apps.default = flake-utils.lib.mkApp { drv = yaMusic; }; + } + ); }