Buildout recipe for creating Nix expressions from eggs list
Project description
collective.recipe.nix
This is an experimental buildout recipe for creating nix expression from a buildout eggs list. This is work in progress. Please, contribute.
The minimal buildout part should include recipe and eggs:
[releaser]
recipe = collective.recipe.nix
eggs = zest.releaser[recommended]
The recipe generates three kind of expressions:
mkDerivation based [name].nix usable with nix-shell and nix-build
buildEnv based [name]-env.nix usable with nix-build
buildPythonPackage based [name]-[package].nix usable with nix-env -i -f
Fo large projects like Plone, it’s recommended to use a local mirrored package index / find-links to avoid connection issues when recipe is resolving each package fetchurl information. Possible remedies include setting allow-from-cache to true to allow recipe to use configured buildout download cache (and create file:// urls), or just running the buildout again with help of recipe created cumulative cache ([~/][.]collective.recipe.nix.cfg).
Known issue: If a requirement package has setup dependencies defined in setup_requires, those must be defined manually using propagated-build-inputs option for this recipe.
Recipe options
- eggs
list of packages to generate expressions for
- name
string to define the name used in the resulting derivation and in the generated filenames (defaults to part name)
- prefix
string to set prefix (or path) for generated outputs (defaults to working directory)
- parts
list of existing buildout sections to install in mkDerivation based expression (defaults to all but the current section)
- outputs
list of full generated expression filenames to filter outputs to be generated (defaults to nothing to generate all)
- allow-from-cache
boolean (true) to allow generated expression to use package from buildout download cache (defaults to false)
- build-inputs
list of additional build-inputs from nixpkgs for generated expressions (to be available in nix-shell environment) or list of package=nixpkgsPackage mappings to inject build-inputs for each package’s buildPythonPackage-expression
- propagated-build-inputs
list of package=other.package mappings to inject additional requirements for packages (usually to enable some additional features)
- nixpkgs
list of package=pythonPackages.package mappings to use existing packages from nixpkgs instead of generating custom buildPythonPackage (useful with package like Pillow, which need additional care to get built properly)
- urls
list of package=url#md5=hash mappings to explicitly define package download URL and MD5 checksum for cases where the recipe fails to resolve it automatically
Example of generic use
At first, define ./default.nix with buildout:
with import <nixpkgs> {}; stdenv.mkDerivation { name = "myEnv"; buildInputs = [ libxml2 libxslt pythonPackages.ldap pythonPackages.pillow pythonPackages.readline pythonPackages.zc_buildout_nix ]; shellHook = '' export SSL_CERT_FILE=~/.nix-profile/etc/ca-bundle.crt ''; }
And example ./buildout.cfg:
[buildout]
parts = releaser
[releaser]
recipe = collective.recipe.nix
eggs = zest.releaser[recommended]
Run the buildout:
$ nix-shell --run buildout-nix
Now you should be able to run zest.releaser with recommended plugins with:
$ nix-shell releaser.nix --run fullrelease
Or install zest.releaser into your current Nix profile with:
$ nix-env -i -f releaser-zest_releaser.nix
Example of building Plone
Together with nixpkgs optimized buildout version (available in nixpkgs), this recipe can be used to build a Nix derivation using buildout install as in Nix derivation builder (see the generated mkDerivation based expression for current example implementation):
[buildout]
extends = https://dist.plone.org/release/5-latest/versions.cfg
parts = plone
versions = versions
[instance]
recipe = plone.recipe.zope2instance
eggs = Plone
user = admin:admin
environment-vars =
PTS_LANGUAGES en
zope_i18n_allowed_languages en
var = /tmp
[plone]
recipe = collective.recipe.nix
parts = instance
eggs = ${instance:eggs}
outputs = plone.nix
[versions]
Pillow =
setuptools =
zc.buildout =
zc.recipe.egg =
$ nix-shell --run buildout-nix
$ nix-build plone.nix -o plone
$ plone/bin/instance fg
Changelog
1.0.3 (2015-08-30)
Updated pre-defined propagated build inputs with some known setup requires [datakurre]
1.0.2 (2015-07-28)
Fix issue where c.recipe.nix part was included in resulting nix expression [datakurre]
1.0.1 (2015-07-28)
Fix issue where buildout could not include “ characters [datakurre]
Fix to remove ~/.installed.cfg from built derivation
1.0.0 (2015-07-26)
First release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for collective.recipe.nix-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 157c7c19fed2c75cbe9355d5721cd28b0bb5228a5c1fd22fdfc2b947af0731cf |
|
MD5 | 15e542af5d3e3e1051cedbbdf8d9c3f4 |
|
BLAKE2b-256 | 183b67256119721b31685043d48c3e9cad36b325d05c7dde610d647d71abd653 |