-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathhare.nix
More file actions
61 lines (60 loc) · 1.68 KB
/
hare.nix
File metadata and controls
61 lines (60 loc) · 1.68 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
60
61
{
config,
lib,
pkgs,
...
}:
let
cfg = config.language.hare;
strOrPackage = import ../../nix/strOrPackage.nix { inherit lib pkgs; };
makeHareFullPath =
userHareLibs:
let
allHareThirdPartyLibs = builtins.attrValues (pkgs.hareThirdParty.packages pkgs);
propagatedLibs = lib.unique (
builtins.foldl' (
acc: userLib: acc ++ (lib.intersectLists userLib.propagatedBuildInputs allHareThirdPartyLibs)
) [ ] userHareLibs
);
in
lib.makeSearchPath "src/hare/third-party" (userHareLibs ++ propagatedLibs);
in
{
options.language.hare = with lib; {
thirdPartyLibs = mkOption {
type = types.listOf strOrPackage;
default = [ ];
example = literalExpression "[ hareThirdParty.hare-compress ]";
description = "List of extra packages (coming from hareThirdParty) to add";
};
vendoredLibs = mkOption {
type = types.listOf types.str;
default = [ ];
example = literalExpression "[ ./vendor/lib ]";
description = "List of paths to add to HAREPATH";
};
package = mkOption {
type = strOrPackage;
default = pkgs.hare;
example = literalExpression "pkgs.hare";
description = "Which Hare package to use";
};
};
config = {
env = [
{
name = "HAREPATH";
value = lib.makeSearchPath "src/hare/stdlib" [ cfg.package ];
}
(lib.mkIf (cfg.thirdPartyLibs != [ ]) {
name = "HAREPATH";
prefix = makeHareFullPath cfg.thirdPartyLibs;
})
(lib.mkIf (cfg.vendoredLibs != [ ]) {
name = "HAREPATH";
prefix = lib.concatStringsSep ":" cfg.vendoredLibs;
})
];
devshell.packages = [ cfg.package ];
};
}