Skip to content

Commit

Permalink
add apps to support the nix run command (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
xjathie87 authored Mar 27, 2024
1 parent 1a18e65 commit 0376023
Showing 1 changed file with 45 additions and 44 deletions.
89 changes: 45 additions & 44 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
}
);
}

0 comments on commit 0376023

Please sign in to comment.