1
0
Fork 0
mirror of https://git.sr.ht/~goorzhel/turboprop synced 2024-12-14 11:37:37 +00:00
turboprop/src/default.nix

65 lines
1.4 KiB
Nix
Raw Normal View History

{
charts,
lib,
pkgs,
user ? {},
}: let
2023-12-04 01:07:21 +00:00
mkNamespace = name: extraMetadata: {
};
flakeBuilders = (import ./flake-builders.nix) {inherit charts lib pkgs user;};
2023-12-04 01:07:21 +00:00
buildServices = roots: kubeVersion: {};
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;
};
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;
};
}