60 lines
1.4 KiB
Nix
Raw Normal View History

# unpackPhase
# patchPhase
# configurePhase
# buildPhase
# checkPhase
# installPhase
# fixupPhase
# installCheckPhase
# distPhase
{
config,
lib,
stdenv,
writeShellScript,
k8s,
openssh,
...
}:
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
./files/manifests/cilium.yaml
./files/manifests/coredns.yaml
./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}";
in
stdenv.mkDerivation (finalAttrs: {
name = "bootstrap-script";
nativeBuildInputs = [ ];
buildInputs = [ ];
unpackPhase = "true";
installPhase = ''
cp ${bootstrap_script} "$out"
'';
})