-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.nix
More file actions
59 lines (54 loc) · 1.48 KB
/
python.nix
File metadata and controls
59 lines (54 loc) · 1.48 KB
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
53
54
55
56
57
58
59
{
config,
lib,
pkgs,
slib,
...
}:
let
cfg = config.nixcfg.languages.python;
configPath =
{
darwin = "Library/Application Support";
linux = ".config";
}
.${slib.kernel pkgs.stdenv.hostPlatform.system};
in
{
options.nixcfg.languages.python = {
enable = lib.mkEnableOption "Python runtime and REPL tools";
interpreter = lib.mkOption {
type = lib.types.package;
default = pkgs.python3;
description = "Python interpreter package used to build the user environment.";
};
packages = lib.mkOption {
type = lib.types.functionTo (lib.types.listOf lib.types.package);
default =
pyps: with pyps; [
ptpython
catppuccin
];
description = "Python packages to install in the user interpreter environment.";
};
ptpythonConfig = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = ./ptpython.py;
description = "Optional ptpython config file path installed into the platform config directory.";
};
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = cfg.interpreter ? withPackages;
message = "nixcfg.languages.python.interpreter must provide withPackages (e.g. pkgs.python3).";
}
];
home = {
file = lib.mkIf (cfg.ptpythonConfig != null) {
"${configPath}/ptpython/config.py".source = cfg.ptpythonConfig;
};
packages = [ (cfg.interpreter.withPackages cfg.packages) ];
};
};
}