0

Add nix support (#45)

This commit is contained in:
Andrei Borzenkov
2023-11-22 19:28:15 +04:00
committed by GitHub
parent 6b7df22624
commit 1a18e654a2
4 changed files with 124 additions and 0 deletions

56
flake.nix Normal file
View File

@@ -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
'';
};
});
}