-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.nix
47 lines (45 loc) · 1.19 KB
/
lib.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
{ lib }:
let
packageListType = lib.types.listOf lib.types.package;
drvAttrsStub = {
name = "minimal-shell";
system = "x";
builder = "x";
};
in
lib.makeExtensible (self: {
stdenv = ./stdenv;
mkMinimalShell =
{ drvAttrs ? drvAttrsStub
, exports ? [ ]
, packages ? [ ]
}:
assert builtins.langVersion >= 5; # For structured attributes.
builtins.derivation (drvAttrs // {
outputs = [ "out" ];
stdenv = self.stdenv;
inherit exports;
# Reverse packages list so that paths are prepended to the PATH in the
# list order.
packages = lib.reverseList packages;
__structuredAttrs = true;
});
minimalShellType = lib.types.either packageListType (lib.types.submodule {
options = {
packages = lib.mkOption {
type = packageListType;
default = [ ];
description = lib.mdDoc ''
Packages to add to the PATH environment variable.
'';
};
exports = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = lib.mdDoc ''
Additional environment variables to export.
'';
};
};
});
})