Files
machine_setup/nix/kubernetes/keys/package/bootstrap-script/package.nix

82 lines
2.7 KiB
Nix
Raw Normal View History

# unpackPhase
# patchPhase
# configurePhase
# buildPhase
# checkPhase
# installPhase
# fixupPhase
# installCheckPhase
# distPhase
{
lib,
stdenv,
fetchFromGitHub,
writeShellScript,
k8s,
...
}:
let
bootstrap_script = (writeShellScript "bootstrap-script" bootstrap_script_body);
bootstrap_script_body = (''
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "''${BASH_SOURCE[0]}" )" && pwd )"
${apply_manifests}
echo "Bootstrap finished"
'');
manifests = (
2025-12-21 22:41:21 -05:00
lib.concatMapStringsSep "," lib.escapeShellArg (
[
./files/manifests/initial_clusterrole.yaml
2026-01-04 22:27:00 -05:00
]
++ gateway_crds
++ [
"${k8s.cilium-manifest}/cilium.yaml"
"${k8s.coredns-manifest}/coredns.yaml"
2025-12-21 22:41:21 -05:00
./files/manifests/flux_namespace.yaml
./files/manifests/flux.yaml
./files/manifests/flux_instance.yaml
]
++ (lib.attrsets.mapAttrsToList (
secret_name: secret_value: "${secret_value}/${secret_name}.yaml"
) k8s.k8s-secrets-generic)
++ [
./files/manifests/flux_apply_git.yaml
]
2025-12-21 22:41:21 -05:00
)
);
apply_manifests = "kubectl --kubeconfig=${k8s.client-configs.admin}/admin.kubeconfig apply --server-side --force-conflicts -f ${manifests}";
gateway_crds_repo = fetchFromGitHub {
owner = "kubernetes-sigs";
repo = "gateway-api";
rev = "v1.4.1";
sha256 = "sha256-/GHyikcC2QGDN0ndpY6/xvSEEnpSsLrNU+lFElCKBs8=";
};
2026-01-04 22:27:00 -05:00
gateway_crds = [
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_backendtlspolicies.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_referencegrants.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.x-k8s.io_xmeshes.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_gatewayclasses.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_udproutes.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_tlsroutes.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.x-k8s.io_xbackendtrafficpolicies.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_gateways.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.x-k8s.io_xlistenersets.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_tcproutes.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_httproutes.yaml"
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_grpcroutes.yaml"
2026-01-04 22:27:00 -05:00
];
in
stdenv.mkDerivation (finalAttrs: {
name = "bootstrap-script";
nativeBuildInputs = [ ];
buildInputs = [ ];
unpackPhase = "true";
installPhase = ''
cp ${bootstrap_script} "$out"
'';
})