Fix nasty attrset merge bug

This commit is contained in:
Jonas Juselius
2020-10-31 08:54:28 +01:00
parent 07de9bd42f
commit ec98ac483e
2 changed files with 38 additions and 39 deletions

View File

@@ -1,6 +1,8 @@
{ pkgs, cfg, customize, lib, config, ... }: { pkgs, cluster, customize ? {}, lib, config, ... }:
with lib; with lib;
let let
cfg = cluster;
pki = import ./pki.nix { inherit pkgs; ca = cfg.initca; }; pki = import ./pki.nix { inherit pkgs; ca = cfg.initca; };
mkCert = host: { mkCert = host: {
@@ -11,21 +13,6 @@ let
}; };
}; };
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: baseDeployment = nodes: attrs:
let let
hosts = hosts =
@@ -43,12 +30,15 @@ in {
inherit customize; inherit customize;
cluster = cfg // { cluster = mkMerge [
hostName = host.name; cfg
cert = mkCert host.name; {
k8s.master.enable = true; hostName = host.name;
k8s.node.enable = true; cert = mkCert host.name;
}; k8s.master.enable = true;
k8s.node.enable = true;
}
];
imports = [ host.hw ./k8s.nix ]; imports = [ host.hw ./k8s.nix ];
}; };
@@ -58,11 +48,14 @@ in {
inherit customize; inherit customize;
cluster = cfg // { cluster = mkMerge [
hostName = host.name; cfg
cert = mkCert host.name; {
k8s.node.enable = true; hostName = host.name;
}; cert = mkCert host.name;
k8s.node.enable = true;
}
];
imports = [ host.hw ./k8s.nix ]; imports = [ host.hw ./k8s.nix ];
}; };
@@ -81,10 +74,13 @@ in {
inherit customize; inherit customize;
cluster = cfg // { cluster = mkMerge [
hostName = host.name; cfg
cert = mkCert host.name; {
}; hostName = host.name;
cert = mkCert host.name;
}
];
imports = [ host.hw ./fs.nix ]; imports = [ host.hw ./fs.nix ];
}; };
@@ -100,10 +96,13 @@ in {
inherit customize; inherit customize;
cluster = cfg // { cluster = mkMerge [
hostName = host.name; cfg
cert = mkCert host.name; {
}; hostName = host.name;
cert = mkCert host.name;
}
];
imports = [ host.hw ./os.nix ]; imports = [ host.hw ./os.nix ];
}; };

View File

@@ -5,10 +5,10 @@ let
pki = import ./pki.nix { inherit pkgs; ca = cfg.initca; }; pki = import ./pki.nix { inherit pkgs; ca = cfg.initca; };
apiserverAddress = "https://${masterAddress}:4443";
masterAddress = cfg.k8s.master.address; masterAddress = cfg.k8s.master.address;
apiserverAddress = "https://${masterAddress}:4443";
cfssl-apitoken = cfssl-apitoken =
let let
apitoken = pkgs.stdenv.mkDerivation { apitoken = pkgs.stdenv.mkDerivation {
@@ -224,12 +224,12 @@ in {
address = mkOption { address = mkOption {
type = types.str; type = types.str;
default = "127.0.0.1"; default = null;
}; };
name = mkOption { name = mkOption {
type = types.str; type = types.str;
default = "apiserver"; default = null;
}; };
extraSANs = mkOption { extraSANs = mkOption {