diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/languages-frameworks/python.md | 44 | ||||
-rw-r--r-- | doc/languages-frameworks/ruby.xml | 9 |
2 files changed, 38 insertions, 15 deletions
diff --git a/doc/languages-frameworks/python.md b/doc/languages-frameworks/python.md index 6f09962094d7..c8add96a1482 100644 --- a/doc/languages-frameworks/python.md +++ b/doc/languages-frameworks/python.md @@ -423,7 +423,7 @@ and in this case the `python35` interpreter is automatically used. ### Interpreters Versions 2.7, 3.3, 3.4, 3.5 and 3.6 of the CPython interpreter are available as -respectively `python27`, `python33`, `python34`, `python35` and `python36`. The PyPy interpreter +respectively `python27`, `python34`, `python35` and `python36`. The PyPy interpreter is available as `pypy`. The aliases `python2` and `python3` correspond to respectively `python27` and `python35`. The default interpreter, `python`, maps to `python2`. The Nix expressions for the interpreters can be found in @@ -469,7 +469,6 @@ sets are * `pkgs.python26Packages` * `pkgs.python27Packages` -* `pkgs.python33Packages` * `pkgs.python34Packages` * `pkgs.python35Packages` * `pkgs.python36Packages` @@ -546,6 +545,35 @@ All parameters from `mkDerivation` function are still supported. * `catchConflicts` If `true`, abort package build if a package name appears more than once in dependency tree. Default is `true`. * `checkInputs` Dependencies needed for running the `checkPhase`. These are added to `buildInputs` when `doCheck = true`. +##### Overriding Python packages + +The `buildPythonPackage` function has a `overridePythonPackage` method that +can be used to override the package. In the following example we create an +environment where we have the `blaze` package using an older version of `pandas`. +We override first the Python interpreter and pass +`packageOverrides` which contains the overrides for packages in the package set. + +```nix +with import <nixpkgs> {}; + +(let + python = let + packageOverrides = self: super: { + pandas = super.pandas.overridePythonPackage(old: rec { + version = "0.19.1"; + name = "pandas-${version}"; + src = super.fetchPypi { + pname = "pandas"; + inherit version; + sha256 = "08blshqj9zj1wyjhhw3kl2vas75vhhicvv72flvf1z3jvapgw295"; + }; + }); + }; + in pkgs.python3.override {inherit packageOverrides;}; + +in python.withPackages(ps: [ps.blaze])).env +``` + #### `buildPythonApplication` function The `buildPythonApplication` function is practically the same as `buildPythonPackage`. @@ -622,7 +650,7 @@ attribute. The `shell.nix` file from the previous section can thus be also writt ```nix with import <nixpkgs> {}; -(python33.withPackages (ps: [ps.numpy ps.requests])).env +(python36.withPackages (ps: [ps.numpy ps.requests])).env ``` In contrast to `python.buildEnv`, `python.withPackages` does not support the more advanced options @@ -755,17 +783,17 @@ In the following example we rename the `pandas` package and build it. ```nix with import <nixpkgs> {}; -let +(let python = let packageOverrides = self: super: { - pandas = super.pandas.override {name="foo";}; + pandas = super.pandas.overridePythonPackage(old: {name="foo";}); }; in pkgs.python35.override {inherit packageOverrides;}; -in python.pkgs.pandas +in python.withPackages(ps: [ps.pandas])).env ``` -Using `nix-build` on this expression will build the package `pandas` -but with the new name `foo`. +Using `nix-build` on this expression will build an environment that contains the +package `pandas` but with the new name `foo`. All packages in the package set will use the renamed package. A typical use case is to switch to another version of a certain package. diff --git a/doc/languages-frameworks/ruby.xml b/doc/languages-frameworks/ruby.xml index 4b48f7ffa1b9..647a30481e3e 100644 --- a/doc/languages-frameworks/ruby.xml +++ b/doc/languages-frameworks/ruby.xml @@ -82,7 +82,7 @@ versions available from various packages. </para> <para>Resulting derivations for both builders also have two helpful -attributes, <literal>env</literal> and <literal>wrapper</literal>. +attributes, <literal>env</literal> and <literal>wrappedRuby</literal>. The first one allows one to quickly drop into <command>nix-shell</command> with the specified environment present. E.g. <command>nix-shell -A sensu.env</command> would give you an @@ -110,15 +110,10 @@ the needed dependencies. For example, to make a derivation in stdenv.mkDerivation { name = "my-script"; - - buildInputs = [ env.wrapper ]; - + buildInputs = [ env.wrappedRuby ]; script = ./my-script.rb; - buildCommand = '' - mkdir -p $out/bin install -D -m755 $script $out/bin/my-script - patchShebangs $out/bin/my-script ''; }]]> </programlisting> |