2024-07-13 18:18:17 +00:00
|
|
|
{ self, pkgs, machines, dns, myLib, flake-utils, kubenix, nixhelm, blog-pim, ... }: flake-utils.lib.eachDefaultSystem
|
2024-04-13 21:25:48 +00:00
|
|
|
(system:
|
|
|
|
let
|
|
|
|
mkKubenixPackage = module: kubenix.packages.${system}.default.override
|
2024-04-13 14:37:18 +00:00
|
|
|
{
|
2024-05-24 21:40:19 +00:00
|
|
|
specialArgs = { inherit myLib kubenix nixhelm system dns blog-pim machines; };
|
2024-04-13 21:25:48 +00:00
|
|
|
module = { imports = [ module ]; };
|
2024-04-13 14:37:18 +00:00
|
|
|
};
|
2024-07-13 18:18:17 +00:00
|
|
|
|
|
|
|
deployScript = (pkgs.writeScriptBin "kubenix" (builtins.readFile ./kubenix-deploy.sh)).overrideAttrs (old: {
|
|
|
|
buildCommand = "${old.buildCommand}\npatchShebangs $out";
|
|
|
|
});
|
|
|
|
|
|
|
|
mkDeployScript = kubernetes: applyset: namespace:
|
|
|
|
let
|
|
|
|
kubeconfig = kubernetes.kubeconfig or "";
|
|
|
|
result = kubernetes.result or "";
|
|
|
|
|
|
|
|
wrappedDeployScript = pkgs.symlinkJoin
|
|
|
|
{
|
|
|
|
name = "kubenix";
|
|
|
|
paths = [ deployScript pkgs.vals pkgs.kubectl ];
|
|
|
|
buildInputs = [ pkgs.makeWrapper ];
|
|
|
|
passthru.manifest = result;
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
wrapProgram $out/bin/kubenix \
|
|
|
|
--suffix PATH : "$out/bin" \
|
|
|
|
--run 'export KUBECONFIG=''${KUBECONFIG:-${toString kubeconfig}}' \
|
|
|
|
--set MANIFEST '${result}' \
|
|
|
|
--set APPLYSET '${applyset}' \
|
|
|
|
--set NAMESPACE '${namespace}'
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
wrappedDeployScript;
|
|
|
|
|
|
|
|
mkDeployScriptAndManifest = module: applyset: namespace:
|
|
|
|
let
|
|
|
|
kubernetes = (kubenix.evalModules.${system} {
|
|
|
|
module = { kubenix, ... }:
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
kubenix.modules.k8s
|
|
|
|
"${self}/kubenix-modules/custom"
|
|
|
|
module
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}).config.kubernetes;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
manifest = kubernetes.result;
|
|
|
|
deploy = mkDeployScript kubernetes applyset namespace;
|
|
|
|
};
|
2024-04-13 21:25:48 +00:00
|
|
|
in
|
|
|
|
{
|
2024-07-13 18:18:17 +00:00
|
|
|
kubenix.all.deploy = mkKubenixPackage "${self}/kubenix-modules/all.nix";
|
|
|
|
kubenix.bootstrap.deploy = mkKubenixPackage "${self}/kubenix-modules/base.nix";
|
|
|
|
|
|
|
|
kubenix.cyberchef = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/cyberchef.nix" "cyberchef" "cyberchef";
|
2024-04-13 14:37:18 +00:00
|
|
|
})
|