forked from xtruder/kubenix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
57 lines (47 loc) · 1.25 KB
/
default.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
{ pkgs ? import <nixpkgs> {}, nixosPath ? toString <nixpkgs/nixos>, lib ? pkgs.lib }:
with lib;
let
kubenixLib = import ./lib { inherit lib pkgs; };
lib' = lib.extend (lib: self: import ./lib/extra.nix { inherit lib pkgs; });
defaultSpecialArgs = {
inherit kubenix nixosPath;
};
# evalModules with same interface as lib.evalModules and kubenix as
# special argument
evalModules = {
module ? null,
modules ? [module],
specialArgs ? defaultSpecialArgs, ...
}@attrs: let
attrs' = filterAttrs (n: _: n != "module") attrs;
in lib'.evalModules (recursiveUpdate {
inherit specialArgs modules;
args = {
inherit pkgs;
name = "default";
};
} attrs');
modules = import ./modules;
# legacy support for buildResources
buildResources = {
configuration ? {},
writeJSON ? true,
writeHash ? true
}: let
evaled = evalModules {
modules = [
configuration
modules.legacy
];
};
generated = evaled.config.kubernetes.generated;
result =
if writeJSON
then pkgs.writeText "resources.json" (builtins.toJSON generated)
else generated;
in result;
kubenix = {
inherit evalModules buildResources modules;
lib = kubenixLib;
};
in kubenix