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}' \
|
2024-07-14 09:47:46 +00:00
|
|
|
--set APPLYSET 'applyset-${applyset}' \
|
2024-07-13 18:18:17 +00:00
|
|
|
--set NAMESPACE '${namespace}'
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
wrappedDeployScript;
|
|
|
|
|
|
|
|
mkDeployScriptAndManifest = module: applyset: namespace:
|
|
|
|
let
|
|
|
|
kubernetes = (kubenix.evalModules.${system} {
|
2024-07-17 08:30:50 +00:00
|
|
|
specialArgs = { inherit namespace myLib blog-pim dns; };
|
2024-07-14 09:47:46 +00:00
|
|
|
|
2024-07-13 18:18:17 +00:00
|
|
|
module = { kubenix, ... }:
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
kubenix.modules.k8s
|
|
|
|
"${self}/kubenix-modules/custom"
|
|
|
|
module
|
|
|
|
];
|
2024-07-14 09:47:46 +00:00
|
|
|
|
|
|
|
config = {
|
|
|
|
kubenix.project = applyset;
|
|
|
|
kubernetes.namespace = namespace;
|
|
|
|
};
|
2024-07-13 18:18:17 +00:00
|
|
|
};
|
|
|
|
}).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
|
2024-07-14 13:31:58 +00:00
|
|
|
"${self}/kubenix-modules/cyberchef.nix" "cyberchef" "static-websites";
|
2024-07-14 09:47:46 +00:00
|
|
|
kubenix.freshrss = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/freshrss.nix" "freshrss" "freshrss";
|
2024-07-14 11:48:17 +00:00
|
|
|
kubenix.radicale = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/radicale.nix" "radicale" "radicale";
|
2024-07-14 11:58:08 +00:00
|
|
|
kubenix.kms = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/kms.nix" "kms" "kms";
|
2024-07-14 12:14:08 +00:00
|
|
|
kubenix.atuin = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/atuin.nix" "atuin" "atuin";
|
2024-07-14 13:31:58 +00:00
|
|
|
kubenix.blog = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/blog.nix" "blog" "static-websites";
|
2024-07-14 13:56:38 +00:00
|
|
|
kubenix.nextcloud = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/nextcloud.nix" "nextcloud" "nextcloud";
|
2024-07-14 14:20:24 +00:00
|
|
|
kubenix.hedgedoc = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/hedgedoc.nix" "hedgedoc" "hedgedoc";
|
2024-07-14 17:59:49 +00:00
|
|
|
kubenix.kitchenowl = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/kitchenowl.nix" "kitchenowl" "kitchenowl";
|
2024-07-14 18:14:48 +00:00
|
|
|
kubenix.forgejo = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/forgejo" "forgejo" "forgejo";
|
2024-07-14 20:58:06 +00:00
|
|
|
kubenix.paperless = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/paperless.nix" "paperless" "paperless";
|
2024-07-16 13:31:47 +00:00
|
|
|
kubenix.syncthing = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/syncthing.nix" "syncthing" "syncthing";
|
2024-07-16 13:46:13 +00:00
|
|
|
kubenix.pihole = mkDeployScriptAndManifest
|
2024-07-17 08:25:23 +00:00
|
|
|
"${self}/kubenix-modules/pihole.nix" "pihole" "dns";
|
2024-07-16 14:13:29 +00:00
|
|
|
kubenix.immich = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/immich.nix" "immich" "immich";
|
2024-07-16 16:38:47 +00:00
|
|
|
kubenix.attic = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/attic.nix" "attic" "attic";
|
2024-07-16 17:56:18 +00:00
|
|
|
kubenix.inbucket = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/inbucket.nix" "inbucket" "inbucket";
|
2024-07-17 08:25:23 +00:00
|
|
|
kubenix.dnsmasq = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/dnsmasq.nix" "dnsmasq" "dns";
|
2024-07-17 08:30:50 +00:00
|
|
|
kubenix.bind9 = mkDeployScriptAndManifest
|
|
|
|
"${self}/kubenix-modules/bind9" "bind9" "dns";
|
2024-04-13 14:37:18 +00:00
|
|
|
})
|