84 lines
1.8 KiB
Nix
84 lines
1.8 KiB
Nix
{ pkgs }:
|
|
{
|
|
appOptions = opts: with pkgs.lib; {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = "Enable";
|
|
};
|
|
|
|
autoSync = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = "Auto sync";
|
|
};
|
|
|
|
prune = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = "Prune";
|
|
};
|
|
|
|
serverSideDiff = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = "Enable server-side diffing";
|
|
};
|
|
|
|
namespace = mkOption {
|
|
type = types.string;
|
|
default = null;
|
|
description = "Namespace";
|
|
};
|
|
|
|
project = mkOption {
|
|
type = types.string;
|
|
default = "default";
|
|
description = "Project";
|
|
};
|
|
|
|
cluster = mkOption {
|
|
type = types.string;
|
|
default = "https://kubernetes.default.svc";
|
|
description = "Cluster";
|
|
};
|
|
|
|
values = mkOption {
|
|
type = types.attrsOf types.anything;
|
|
default = {};
|
|
description = "Values";
|
|
};
|
|
} // opts;
|
|
|
|
appConfig = cfg: name: conf:
|
|
with pkgs.lib;
|
|
let
|
|
app = conf // {
|
|
createNamespace = true;
|
|
|
|
compareOptions = {
|
|
serverSideDiff = cfg.serverSideDiff;
|
|
};
|
|
|
|
syncPolicy = {
|
|
syncOptions = {
|
|
applyOutOfSyncOnly = true;
|
|
};
|
|
|
|
autoSync = mkIf cfg.autoSync {
|
|
prune = cfg.prune;
|
|
selfHeal = false;
|
|
};
|
|
};
|
|
};
|
|
|
|
in mkIf cfg.enable { applications.${name} = app; };
|
|
|
|
appValues = with pkgs.lib; vs: values:
|
|
attrsets.mergeAttrsList (lists.flatten [
|
|
(lib.kube.fromYAML (builtins.readFile "${vs}/values.yaml"))
|
|
(lib.kube.fromYAML (builtins.readFile "${vs}/values-${env}.yaml"))
|
|
[ values ]
|
|
]);
|
|
}
|