2021-04-28 14:40:30 -05:00
|
|
|
let
|
|
|
|
|
fetch = import ./lib/compat.nix;
|
|
|
|
|
in
|
|
|
|
|
{ pkgs ? import (fetch "nixpkgs") { }
|
|
|
|
|
, nixosPath ? toString (fetch "nixpkgs") + "/nixos"
|
|
|
|
|
, lib ? pkgs.lib
|
|
|
|
|
}:
|
2017-11-11 11:52:17 +01:00
|
|
|
|
2019-03-07 18:02:26 +01:00
|
|
|
with lib;
|
2017-11-11 11:52:17 +01:00
|
|
|
let
|
2019-03-07 18:02:26 +01:00
|
|
|
kubenixLib = import ./lib { inherit lib pkgs; };
|
|
|
|
|
lib' = lib.extend (lib: self: import ./lib/extra.nix { inherit lib pkgs; });
|
2019-02-10 21:03:47 +01:00
|
|
|
|
2019-03-07 18:02:26 +01:00
|
|
|
defaultSpecialArgs = {
|
2019-10-06 21:42:19 +02:00
|
|
|
inherit kubenix nixosPath;
|
2019-02-10 21:03:47 +01:00
|
|
|
};
|
|
|
|
|
|
2019-03-07 23:23:07 +01:00
|
|
|
# evalModules with same interface as lib.evalModules and kubenix as
|
|
|
|
|
# special argument
|
2021-05-13 17:27:08 -04:00
|
|
|
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');
|
2017-11-11 11:52:17 +01:00
|
|
|
|
2019-03-05 20:57:55 +01:00
|
|
|
modules = import ./modules;
|
|
|
|
|
|
2020-01-14 19:08:59 +00:00
|
|
|
# legacy support for buildResources
|
2021-05-13 17:27:08 -04:00
|
|
|
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;
|
2020-01-14 19:08:59 +00:00
|
|
|
|
2019-02-10 21:03:47 +01:00
|
|
|
kubenix = {
|
2020-01-14 19:08:59 +00:00
|
|
|
inherit evalModules buildResources modules;
|
2017-11-11 11:52:17 +01:00
|
|
|
|
2019-03-07 18:02:26 +01:00
|
|
|
lib = kubenixLib;
|
2019-03-07 23:23:07 +01:00
|
|
|
};
|
2021-05-13 17:27:08 -04:00
|
|
|
in
|
|
|
|
|
kubenix
|