nixpkgs-suyu/pkgs/development/tools/pypi2nix/default.nix

77 lines
1.9 KiB
Nix
Raw Normal View History

2016-05-07 05:04:25 +02:00
{ stdenv, fetchurl, python, zip, makeWrapper
}:
let
deps = import ./deps.nix { inherit fetchurl; };
2016-08-15 03:46:43 +02:00
version = "1.4.0";
2016-05-07 05:04:25 +02:00
src = fetchurl {
url = "https://github.com/garbas/pypi2nix/archive/v${version}.tar.gz";
2016-08-15 04:01:14 +02:00
sha256 = "0w5f10p4d4ppwg2plbbrmqwmi1ycgpaidyajza11c9svka014zrb";
2016-05-07 05:04:25 +02:00
};
in stdenv.mkDerivation rec {
name = "pypi2nix-${version}";
2016-07-25 04:25:51 +02:00
srcs = with deps; [
src
click
requests
]; # six attrs effect ];
2016-05-07 05:04:25 +02:00
buildInputs = [ python zip makeWrapper ];
sourceRoot = ".";
postUnpack = ''
mkdir -p $out/pkgs
mv click-*/click $out/pkgs/click
2016-07-25 04:25:51 +02:00
# mv six-*/six.py $out/pkgs/
# mv attrs-*/src/attr $out/pkgs/attrs
# mv effect-*/effect $out/pkgs/effect
mv requests-*/requests $out/pkgs/
2016-05-07 05:04:25 +02:00
2016-08-15 03:46:43 +02:00
if [ "$IN_NIX_SHELL" != "1" ]; then
2016-05-07 05:04:25 +02:00
if [ -e git-export ]; then
mv git-export/src/pypi2nix $out/pkgs/pypi2nix
else
mv pypi2nix*/src/pypi2nix $out/pkgs/pypi2nix
fi
fi
'';
commonPhase = ''
mkdir -p $out/bin
2016-08-15 03:46:43 +02:00
echo "#!${python.interpreter}" > $out/bin/pypi2nix
echo "import pypi2nix.cli" >> $out/bin/pypi2nix
echo "pypi2nix.cli.main()" >> $out/bin/pypi2nix
2016-05-07 05:04:25 +02:00
chmod +x $out/bin/pypi2nix
export PYTHONPATH=$out/pkgs:$PYTHONPATH
'';
installPhase = commonPhase + ''
wrapProgram $out/bin/pypi2nix --prefix PYTHONPATH : "$PYTHONPATH"
'';
shellHook = ''
export home=`pwd`
export out=/tmp/`pwd | md5sum | cut -f 1 -d " "`-$name
rm -rf $out
mkdir -p $out
cd $out
runHook unpackPhase
runHook commonPhase
cd $home
export PATH=$out/bin:$PATH
export PYTHONPATH=`pwd`/src:$PYTHONPATH
'';
2016-06-29 01:48:38 +02:00
2016-05-07 05:04:25 +02:00
meta = {
homepage = https://github.com/garbas/pypi2nix;
description = "A tool that generates nix expressions for your python packages, so you don't have to.";
maintainers = with stdenv.lib.maintainers; [ garbas ];
};
}