2023-11-30 06:49:58 +00:00
|
|
|
{
|
|
|
|
charts,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
user ? {},
|
|
|
|
}: let
|
2023-12-04 01:07:21 +00:00
|
|
|
mkNamespace = name: extraMetadata: {
|
|
|
|
};
|
|
|
|
|
2023-11-30 06:49:58 +00:00
|
|
|
flakeBuilders = (import ./flake-builders.nix) {inherit charts lib pkgs user;};
|
|
|
|
|
2023-12-04 01:07:21 +00:00
|
|
|
buildServices = roots: kubeVersion: {};
|
2023-11-30 06:49:58 +00:00
|
|
|
in {
|
2023-12-04 01:07:21 +00:00
|
|
|
inherit flakeBuilders; # TODO: remove after debugging
|
|
|
|
|
|
|
|
inherit (lib) mkCharts;
|
|
|
|
|
|
|
|
mkNamespaces = {
|
|
|
|
roots,
|
|
|
|
extraMetadata ? {},
|
|
|
|
}: let
|
|
|
|
objs = with builtins;
|
|
|
|
map
|
|
|
|
(name: let
|
|
|
|
eM =
|
|
|
|
# Can't use `set?name` or `set.name`
|
|
|
|
# because "name" is taken literally.
|
|
|
|
if hasAttr name extraMetadata
|
|
|
|
then getAttr name extraMetadata
|
|
|
|
else extraMetadata.DEFAULT;
|
|
|
|
in {
|
|
|
|
apiVersion = "v1";
|
|
|
|
kind = "Namespace";
|
|
|
|
metadata = {inherit name;} // eM;
|
|
|
|
})
|
|
|
|
(concatLists (map ls roots));
|
|
|
|
in
|
|
|
|
lib.builders.yamlStream {
|
|
|
|
name = "namespaces";
|
|
|
|
namespace = "CLUSTER"; # ignored in `kubectl create`
|
|
|
|
inherit objs;
|
|
|
|
};
|
|
|
|
|
2023-11-30 06:49:58 +00:00
|
|
|
mkDerivation = {
|
|
|
|
pname,
|
|
|
|
version,
|
|
|
|
serviceData,
|
|
|
|
namespaceData,
|
|
|
|
kubeVersion,
|
|
|
|
src,
|
|
|
|
}: let
|
|
|
|
builtServices = buildServices serviceData kubeVersion;
|
|
|
|
in
|
|
|
|
pkgs.stdenv.mkDerivation {
|
|
|
|
inherit pname version src;
|
|
|
|
derivation_paths = flakeBuilders.paths {
|
|
|
|
services = builtServices;
|
|
|
|
};
|
|
|
|
namespace_drv = flakeBuilders.namespaces namespaceData;
|
|
|
|
|
|
|
|
phases = ["installPhase"];
|
|
|
|
installPhase = builtins.readFile ./src/output.sh;
|
|
|
|
};
|
|
|
|
}
|