-
Notifications
You must be signed in to change notification settings - Fork 0
/
module-options.nix
113 lines (103 loc) · 2.95 KB
/
module-options.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkOption types;
# A new kind of option type that calls lib.getExe on derivations
in {
# Schema
options = {
projectRootFile = mkOption {
description = ''
File to look for to determine the root of the project in the
build.wrapper.
'';
example = "flake.nix";
};
shellPreHook = mkOption {
type = types.lines;
description = "Bash code to execute when entering the shell.";
default = "";
};
shellPostHook = mkOption {
type = types.lines;
description = "Bash code to execute when entering the shell but after `shellPreHook`.";
default = "";
};
packages = mkOption {
type = types.listOf types.package;
description = "A list of packages to expose inside the developer environment. See https://search.nixos.org/packages for packages.";
default = [];
};
stdenv = mkOption {
type = types.package;
description = "The stdenv to use for the developer environment.";
default = pkgs.stdenv;
};
shell = lib.mkOption {
type = types.package;
internal = true;
};
assertions = lib.mkOption {
type = types.listOf types.unspecified;
internal = true;
default = [];
example = [
{
assertion = false;
message = "you can't enable this for that reason";
}
];
description = ''
This option allows modules to express conditions that must
hold for the evaluation of the configuration to succeed,
along with associated error messages for the user.
'';
};
warnings = lib.mkOption {
type = types.listOf types.str;
internal = true;
default = [];
example = ["you should fix this or that"];
description = ''
This option allows modules to express warnings about the
configuration. For example, `lib.mkRenamedOptionModule` uses this to
display a warning message when a renamed option is used.
'';
};
enableDefaultExcludes = mkOption {
description = ''
Enable the default excludes in the treefmt configuration.
'';
type = types.bool;
default = true;
};
# Outputs
build = {
devShell = mkOption {
description = "The development shell with Snow Blower and its underlying programs";
type = types.package;
readOnly = true;
};
};
};
# Config
config.build = {
devShell = (pkgs.mkShell.override {stdenv = config.stdenv;}) {
packages = config.packages;
shellHook = ''
${config.shellPreHook}
${config.shellPostHook}
echo
echo "Snow Blower: Simple, Fast, Declarative, Reproducible, and Composable Developer Environments"
echo
echo "Run 'just <recipe>' to get started"
just --list
'';
nativeBuildInputs = [];
# ++ (lib.attrValues config.build.programs);
};
};
}