-
Notifications
You must be signed in to change notification settings - Fork 135
/
flake-module.nix
69 lines (63 loc) · 1.73 KB
/
flake-module.nix
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
60
61
62
63
64
65
66
67
68
69
top @ {
config,
flake-parts-lib,
lib,
...
}: let
inherit (lib) mkOption types;
in {
# User options defined in perSystem below.
options.jupyenv.flake = mkOption {
internal = true;
description = "The jupyenv flake";
};
options.perSystem = flake-parts-lib.mkPerSystemOption (
{
config,
pkgs,
system,
...
}: let
jupyenv = top.config.jupyenv.flake;
cfg = config.jupyenv;
inherit (jupyenv.lib.${system}) mkJupyterlabNew;
jupyterlab = mkJupyterlabNew ({...}: {
nixpkgs = pkgs;
imports = [cfg.kernels];
});
in {
options.jupyenv = {
kernels = mkOption {
type = types.deferredModule;
description = ''
A module that defines all the kernels to be installed.
You may reference a file, or multiple files using `imports`.
'';
};
pkgs = mkOption {
type = types.pkgs;
description = ''
Nixpkgs instance to use.
'';
default = pkgs;
defaultText = lib.literalMD "`pkgs` module argument";
};
packageName = mkOption {
description = ''
Attribute name to use for the generated `package` and `apps` definitions.
You will be able to run `nix run .#<packageName>` to start jupyterlab.
The default value, `"default"` also allows `nix run` without argument, but may compete with other modules' packages.
'';
default = "default";
};
};
config = {
packages.${cfg.packageName} = jupyterlab;
apps.${cfg.packageName} = {
program = "${jupyterlab}/bin/jupyter-lab";
type = "app";
};
};
}
);
}