How to install and use a python package from GitHub?

Thanks to @benley and @jonringer the following works

with import <nixpkgs> {};

let
    vpn-slice = pkgs.python3Packages.buildPythonPackage rec {
      name = "vpn-slice";
      version = "v0.13";

      src = pkgs.fetchFromGitHub {
      	 owner = "dlenski";
	 repo = "${name}";
	 rev = "${version}";
	 sha256 = "1ibrwal80z27c2mh9hx85idmzilx6cpcmgc15z3lyz57bz0krigb";
      };

      propagatedBuildInputs = with pkgs.python3Packages; [ setproctitle ];

      meta = {
        homepage = "https://github.com/dlenski/vpn-slice";
        description = "vpnc-script replacement for easy and secure split-tunnel VPN setup";
        license = stdenv.lib.licenses.gpl3Plus;
        maintainers = with maintainers; [ dlenski ];
      };
    };

in mkShell {
   name = "vpn-env";
   buildInputs = with pkgs.python3Packages; [ numpy toolz vpn-slice ];
   shellHook = ''
     echo "Whatever makes this happen."
   '';
}
1 Like