From 86580b04ee38944e9f634f15187349a3e8989705 Mon Sep 17 00:00:00 2001 From: Sergey Bubnov Date: Thu, 25 Oct 2018 12:13:36 +0400 Subject: [PATCH] refactor shell.nix --- nix/ansible/default.nix | 38 ++++++++++++++++++++++++ nix/glob2/default.nix | 22 ++++++++++++++ nix/proxmoxer/default.nix | 20 +++++++++++++ nix/pytest-bdd/default.nix | 25 ++++++++++++++++ shell.nix | 59 ++++---------------------------------- 5 files changed, 110 insertions(+), 54 deletions(-) create mode 100644 nix/ansible/default.nix create mode 100644 nix/glob2/default.nix create mode 100644 nix/proxmoxer/default.nix create mode 100644 nix/pytest-bdd/default.nix diff --git a/nix/ansible/default.nix b/nix/ansible/default.nix new file mode 100644 index 0000000..6ff452f --- /dev/null +++ b/nix/ansible/default.nix @@ -0,0 +1,38 @@ +{ pkgs ? import {} +, windowsSupport ? false +}: + +with pkgs; + +pythonPackages.buildPythonPackage rec { + pname = "ansible"; + version = "devel"; + name = "${pname}-${version}"; + + src = fetchFromGitHub { + owner = "ansible"; + repo = "ansible"; + rev = "f0fd0f219de80a8f682b80e1ccdb83fd4988da64"; + sha256 = "128847r4bc650lcpc2z1wxjgdnh07zhxfd9m2bi3wfl069dvhjk9"; + }; + + prePatch = '' + sed -i "s,/usr/,$out," lib/ansible/constants.py + ''; + + doCheck = false; + dontStrip = true; + dontPatchELF = true; + dontPatchShebangs = false; + + propagatedBuildInputs = with pythonPackages; [ + pycrypto paramiko jinja2 pyyaml httplib2 boto six netaddr dnspython + ] ++ stdenv.lib.optional windowsSupport pywinrm; + + meta = with stdenv.lib; { + homepage = http://www.ansible.com; + description = "A simple automation tool"; + license = with licenses; [ gpl3 ]; + platforms = with platforms; linux ++ darwin; + }; +} diff --git a/nix/glob2/default.nix b/nix/glob2/default.nix new file mode 100644 index 0000000..21b98fe --- /dev/null +++ b/nix/glob2/default.nix @@ -0,0 +1,22 @@ +{ pkgs ? import {} }: + +with pkgs; + +python27.pkgs.buildPythonPackage rec { + pname = "glob2"; + version = "0.6"; + + src = python36.pkgs.fetchPypi { + inherit pname version; + sha256 = "1miyz0pjyji4gqrzl04xsxcylk3h2v9fvi7hsg221y11zy3adc7m"; + }; + + nativeBuildInputs = with pythonPackages; [ setuptools_scm ]; + buildInputs = with pythonPackages; [ ]; + doCheck = false; + + meta = { + homepage = "https://github.com/miracle2k/python-glob2"; + description = "extended version of Python's builtin glob module"; + }; +} diff --git a/nix/proxmoxer/default.nix b/nix/proxmoxer/default.nix new file mode 100644 index 0000000..7ad660e --- /dev/null +++ b/nix/proxmoxer/default.nix @@ -0,0 +1,20 @@ +{ pkgs ? import {} }: + +with pkgs; + +python27.pkgs.buildPythonPackage rec { + pname = "proxmoxer"; + version = "1.0.3"; + + src = python36.pkgs.fetchPypi { + inherit pname version; + sha256 = "145hvphvlzvwq6sn31ldnin0ii50blsapxz0gv2zx3grzp6x9hvh"; + }; + + doCheck = false; + + meta = { + homepage = "https://github.com/swayf/proxmoxer"; + description = "Proxmoxer is a wrapper around the Proxmox REST API v2"; + }; +} diff --git a/nix/pytest-bdd/default.nix b/nix/pytest-bdd/default.nix new file mode 100644 index 0000000..87cc79b --- /dev/null +++ b/nix/pytest-bdd/default.nix @@ -0,0 +1,25 @@ +{ pkgs ? import {} }: + +with pkgs; + +python27.pkgs.buildPythonPackage rec { + pname = "pytest-bdd"; + version = "3.0.0"; + + src = python36.pkgs.fetchPypi { + inherit pname version; + sha256 = "1np2qvfnhz3amd02f2y4shp4pracnfdkcdxkhkigv997iwc4sih0"; + }; + + glob2 = callPackage ../glob2 {}; + + nativeBuildInputs = with pythonPackages; [ setuptools_scm ]; + propagatedBuildInputs = with pythonPackages; [ glob2 pytest pytest-forked mock pytest_xdist Mako parse-type ]; + + doCheck = false; + + meta = { + homepage = "https://github.com/pytest-dev/pytest-bdd"; + description = "BDD library for the py.test runner"; + }; +} diff --git a/shell.nix b/shell.nix index d9869f2..88df1f1 100644 --- a/shell.nix +++ b/shell.nix @@ -5,67 +5,18 @@ with pkgs; let - myAnsible = pythonPackages.buildPythonPackage rec { - pname = "ansible"; - version = "devel"; - name = "${pname}-${version}"; + pytest-bdd = callPackage nix/pytest-bdd {}; + proxmoxer = callPackage nix/proxmoxer {}; + ansible = callPackage nix/ansible {}; - src = fetchFromGitHub { - owner = "ansible"; - repo = "ansible"; - rev = "f0fd0f219de80a8f682b80e1ccdb83fd4988da64"; - sha256 = "128847r4bc650lcpc2z1wxjgdnh07zhxfd9m2bi3wfl069dvhjk9"; - }; - - prePatch = '' - sed -i "s,/usr/,$out," lib/ansible/constants.py - ''; - - doCheck = false; - dontStrip = true; - dontPatchELF = true; - dontPatchShebangs = false; - - propagatedBuildInputs = with pythonPackages; [ - pycrypto paramiko jinja2 pyyaml httplib2 boto six netaddr dnspython - ] ++ stdenv.lib.optional windowsSupport pywinrm; - - meta = with stdenv.lib; { - homepage = http://www.ansible.com; - description = "A simple automation tool"; - license = with licenses; [ gpl3 ]; - maintainers = with maintainers; [ - jgeerds - joamaki - ]; - platforms = with platforms; linux ++ darwin; - }; - }; - - myProxmoxer = python27.pkgs.buildPythonPackage rec { - pname = "proxmoxer"; - version = "1.0.2"; - - src = python36.pkgs.fetchPypi { - inherit pname version; - sha256 = "0vpb3b1b8w4r4c28kfhyviw4q70s3vwwirkq6rywryl4wqc3fyra"; - }; - - doCheck = false; - - meta = { - homepage = "https://github.com/swayf/proxmoxer"; - description = "Proxmoxer is a wrapper around the Proxmox REST API v2"; - }; - }; - myPython = python27.withPackages (ps: with ps; [ myProxmoxer jmespath virtualenv pip hypothesis pytest_xdist pytest ]); + myPython = python27.withPackages (ps: with ps; [ pytest-bdd proxmoxer jmespath virtualenv pip hypothesis pytest_xdist pytest ]); in stdenv.mkDerivation { name = "alt-infra-ansible"; buildInputs = [ openssh - myAnsible + ansible myPython pass ];