Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

Asko Soukka: Creating Nix-expressions with buildout

$
0
0

The greatest blocker for using Nix or complex Python projects like Plone, I think, is the work needed to make all required Python-packages (usally very specific versions) available in nix expression. Also, in the most extreme, that would require every version for every package in PyPI in nixpkgs.

Announcing collective.recipe.nix

collective.recipe.nix is my try for generating nix expressions for arbitrary Python projects. It's an experimental buildout recipe, which re-uses zc.recipe.egg for figuring out all the required packages and their dependencies.

Example of usage

At first, bootstrap your environment by defining python with buildout in ./default.nix:


with import <nixpkgs> {}; {
myEnv = stdenv.mkDerivation {
name = "myEnv";
buildInputs = [
pythonPackages.buildout
];
shellHook = ''
export SSL_CERT_FILE=~/.nix-profile/etc/ca-bundle.crt
'';
};
}

And example ./buildout.cfg:


[buildout]
parts=
i18ndude
releaser
robot
sphinx


[i18ndude]
recipe=collective.recipe.nix
eggs=i18ndude

[releaser]
recipe=collective.recipe.nix
eggs=zest.releaser[recommended]

[robot]
recipe=collective.recipe.nix
eggs=robotframework
propagated-build-inputs=
robotframework=robotframework-debuglibrary
robotframework=robotframework-selenium2library
robotframework=robotframework-selenium2screenshots


[sphinx]
recipe=collective.recipe.nix
eggs=sphinx
propagated-build-inputs=
sphinx=sphinxcontrib_robotframework[docs]

Run the buildout:


$ nix-shell --run buildout

The recipe generates three kind of expressions:

  • default [name].nix usable with nix-shell
  • buildEnv based [name]-env.nix usable with nix-build
  • buildPythonPackage based [name]-package.nix usable with nix-env -i -f

So, now you should be able to run zest.releaser with:


$ nix-shell releaser.nix --run fullrelease

You could also build Nix-environment with symlinks in folder ./releaser or into a Docker image with:


$ nix-build releaser-env.nix -o releaser

Finally, you could install zest.releaser into your current Nix-profile with:


$ nix-env -i -f releaser-zest_releaser.nix

Viewing all articles
Browse latest Browse all 3535

Trending Articles