Add toplevel module, and enable modules in config

This commit is contained in:
Jonas Juselius
2020-10-31 09:16:52 +01:00
parent 375a26915f
commit 533928a880
5 changed files with 30 additions and 19 deletions

View File

@@ -40,7 +40,7 @@ in {
} }
]; ];
imports = [ host.hw ./k8s.nix ]; imports = [ host.hw ./modules.nix ];
}; };
node = host: self: { node = host: self: {
@@ -57,7 +57,7 @@ in {
} }
]; ];
imports = [ host.hw ./k8s.nix ]; imports = [ host.hw ./modules.nix ];
}; };
mkDeployment = master: nodes: mkDeployment = master: nodes:
@@ -82,7 +82,7 @@ in {
} }
]; ];
imports = [ host.hw ./fs.nix ]; imports = [ host.hw ./modules.nix ];
}; };
mkDeployment = nodes: mkDeployment = nodes:
@@ -104,7 +104,7 @@ in {
} }
]; ];
imports = [ host.hw ./os.nix ]; imports = [ host.hw ./modules.nix ];
}; };
mkDeployment = masterNode: workerNodes: mkDeployment = masterNode: workerNodes:

View File

@@ -42,6 +42,7 @@ let
}; };
in { in {
options.cluster.fs = { options.cluster.fs = {
enable = mkEnableOption "Enable nfs fileserver";
nfs = { nfs = {
enable = mkEnableOption "Enable nfs fileserver"; enable = mkEnableOption "Enable nfs fileserver";
exports = mkOption { exports = mkOption {
@@ -52,13 +53,13 @@ in {
glusterfs.enable = mkEnableOption "Enable glusterfs fileserver"; glusterfs.enable = mkEnableOption "Enable glusterfs fileserver";
}; };
config = mkMerge [ config = mkIf cfg.enable (
common mkMerge [
common
(mkIf cfg.nfs.enable nfs) (mkIf cfg.nfs.enable nfs)
(mkIf cfg.glusterfs.enable glusterfs)
(mkIf cfg.glusterfs.enable glusterfs) ]
]; );
imports = [ ./os.nix ]; imports = [ ./os.nix ];
} }

View File

@@ -204,6 +204,7 @@ let
in { in {
options.cluster.k8s = { options.cluster.k8s = {
enable = mkEnableOption "Enable kubernetes";
nodes = mkOption { nodes = mkOption {
type = types.listOf types.attrs; type = types.listOf types.attrs;
default = []; default = [];
@@ -211,12 +212,12 @@ in {
fileserver = mkOption { fileserver = mkOption {
type = types.str; type = types.str;
default = "127.0.0.1"; default = null;
}; };
cidr = mkOption { cidr = mkOption {
type = types.str; type = types.str;
default = "10.11.0.0/16"; default = "10.0.0.0/16";
}; };
master = { master = {
@@ -270,10 +271,12 @@ in {
}; };
}; };
config = mkMerge [ config = mkIf cfg.k8s.enable (
(mkIf cfg.k8s.master.enable kubeMaster) mkMerge [
(mkIf cfg.k8s.node.enable kubeNode) (mkIf cfg.k8s.master.enable kubeMaster)
]; (mkIf cfg.k8s.node.enable kubeNode)
]
);
imports = [ ./os.nix ]; imports = [ ./os.nix ];
} }

7
lib/modules.nix Normal file
View File

@@ -0,0 +1,7 @@
{
imports = [
./os.nix
./fs.nix
./k8s.nix
];
}

View File

@@ -55,8 +55,8 @@ in
networking = { networking = {
hostName = cfg.hostName; hostName = cfg.hostName;
domain = cfg.domain; # domain = cfg.domain;
search = cfg.searchDomains; # search = cfg.searchDomains;
extraHosts = cfg.extraHosts; extraHosts = cfg.extraHosts;
}; };