blob: ce1154c7fd3d7ad90e82b920a3c4a16eecea2320 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.python;
pythonWithPackages = (cfg.python.withPackages cfg.packages).override {
ignoreCollisions = cfg.ignoreCollisions;
};
in {
options.python = {
enable = mkEnableOption { name = "python"; };
python = mkOption {
type = types.package;
default = pkgs.python3;
defaultText = literalExample "pkgs.python3Minimal";
description = ''
The package providing python.
Use this option to set the version of Python.
'';
example = literalExample "pkgs.python310";
};
packages = mkOption {
type = with types; functionTo (listOf package);
default = _: [ ];
defaultText = literalExample "_: []";
description = ''
Python packages that will be made available to the environment.
'';
example = literalExample ''
pythonPackages: with pythonPackages; [
requests (callPackage ./my-package.nix {})
];
'';
};
ignoreCollisions = mkEnableOption "ignoring collisions when building the Python environnement";
};
config = mkIf cfg.enable {
buildInputs = [ pythonWithPackages ];
# shellHook = ''
# # Tells pip to put packages into $PIP_PREFIX instead of the usual locations.
# # See https://pip.pypa.io/en/stable/user_guide/#environment-variables.
# export PIP_PREFIX=$(pwd)/_build/pip_packages
# export PYTHONPATH="$PIP_PREFIX/${cfg.python.sitePackages}:$PYTHONPATH"
# export PATH="$PIP_PREFIX/bin:$PATH"
# unset SOURCE_DATE_EPOCH
# '';
};
}
|