Files
platform/lib/default.nix
2020-10-30 14:14:36 +01:00

101 lines
2.3 KiB
Nix

{ pkgs, cfg, lib, config, ... }:
with lib;
let
pki = import ./pki.nix { inherit pkgs; ca = cfg.initca; };
mkCert = host: {
${host.name} = pki.gencert {
cn = host.name;
ca = cfg.ca;
o = cfg.clusterName;
};
};
# hostCerts = builtins.foldl'
# (a: x: a // { ${x.name} = pki.gencert {
# cn = x.name;
# ca = x.ca;
# o = cfg.clusterName;
# };
# }) {} cfg.hosts;
# mkHost = host: self: {
# deployment.targetHost = host.address;
# require = [
# (baseNixos host.name)
# ];
# };
# baseDeployment = nodes: attrs:
# let
# hosts =
# builtins.foldl'
# (a: x: a // { ${x.name} = mkHost x _; }) {} nodes;
# hosts' = lib.recursiveUpdate hosts attrs;
# names = builtins.attrNames hosts;
# in
# builtins.foldl' (a: x: a // { ${x} = self: hosts'.${x}; }) {} names;
in {
# k8s = import ./k8s.nix { inherit pgks lib config; };
# k8s = rec {
# apiserver = host: self: {
# deployment.targetHost = host.address;
# require = [
# (os.baseNixos host.name)
# k8s.kubeMaster
# ];
# };
# node = host: self: {
# deployment.targetHost = host.address;
# require = [
# (os.baseNixos host.name)
# k8s.kubeWorker
# ];
# };
# deployment = masterNode: workerNodes:
# let
# master = { "${master.name}" = apiserver masterNode; };
# in
# builtins.foldl' (a: x:
# a // { "${x.name}" = mkWorker x; }) master workerNodes;
# };
fs = rec {
mkNode = host: self: {
deployment.targetHost = host.address;
imports = [ host.hw ./fs.nix ];
cluster = cfg // {
hostName = host.name;
cert = mkCert host.name;
};
};
mkDeployment = nodes:
builtins.foldl' (a: x:
a // { "${x.name}" = mkNode x; }) {} nodes;
} ;
# host = rec {
# node = host: self: {
# deployment.targetHost = host.address;
# require = [
# (os.baseNixos host.name)
# ];
# };
# deployment = masterNode: workerNodes:
# let
# master = { "${master.name}" = apiserver masterNode; };
# in
# builtins.foldl' (a: x:
# a // { "${x.name}" = mkWorker x; }) master workerNodes;
# };
}