From 533928a880c9f7962879bc937bca7dcfb9c1cd11 Mon Sep 17 00:00:00 2001 From: Jonas Juselius Date: Sat, 31 Oct 2020 09:16:52 +0100 Subject: [PATCH] Add toplevel module, and enable modules in config --- lib/default.nix | 8 ++++---- lib/fs.nix | 15 ++++++++------- lib/k8s.nix | 15 +++++++++------ lib/modules.nix | 7 +++++++ lib/os.nix | 4 ++-- 5 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 lib/modules.nix diff --git a/lib/default.nix b/lib/default.nix index 68f60d6..0ac22ac 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -40,7 +40,7 @@ in { } ]; - imports = [ host.hw ./k8s.nix ]; + imports = [ host.hw ./modules.nix ]; }; node = host: self: { @@ -57,7 +57,7 @@ in { } ]; - imports = [ host.hw ./k8s.nix ]; + imports = [ host.hw ./modules.nix ]; }; mkDeployment = master: nodes: @@ -82,7 +82,7 @@ in { } ]; - imports = [ host.hw ./fs.nix ]; + imports = [ host.hw ./modules.nix ]; }; mkDeployment = nodes: @@ -104,7 +104,7 @@ in { } ]; - imports = [ host.hw ./os.nix ]; + imports = [ host.hw ./modules.nix ]; }; mkDeployment = masterNode: workerNodes: diff --git a/lib/fs.nix b/lib/fs.nix index f52ab20..cb27144 100644 --- a/lib/fs.nix +++ b/lib/fs.nix @@ -42,6 +42,7 @@ let }; in { options.cluster.fs = { + enable = mkEnableOption "Enable nfs fileserver"; nfs = { enable = mkEnableOption "Enable nfs fileserver"; exports = mkOption { @@ -52,13 +53,13 @@ in { glusterfs.enable = mkEnableOption "Enable glusterfs fileserver"; }; - config = mkMerge [ - common - - (mkIf cfg.nfs.enable nfs) - - (mkIf cfg.glusterfs.enable glusterfs) - ]; + config = mkIf cfg.enable ( + mkMerge [ + common + (mkIf cfg.nfs.enable nfs) + (mkIf cfg.glusterfs.enable glusterfs) + ] + ); imports = [ ./os.nix ]; } diff --git a/lib/k8s.nix b/lib/k8s.nix index 3525056..ddc8160 100644 --- a/lib/k8s.nix +++ b/lib/k8s.nix @@ -204,6 +204,7 @@ let in { options.cluster.k8s = { + enable = mkEnableOption "Enable kubernetes"; nodes = mkOption { type = types.listOf types.attrs; default = []; @@ -211,12 +212,12 @@ in { fileserver = mkOption { type = types.str; - default = "127.0.0.1"; + default = null; }; cidr = mkOption { type = types.str; - default = "10.11.0.0/16"; + default = "10.0.0.0/16"; }; master = { @@ -270,10 +271,12 @@ in { }; }; - config = mkMerge [ - (mkIf cfg.k8s.master.enable kubeMaster) - (mkIf cfg.k8s.node.enable kubeNode) - ]; + config = mkIf cfg.k8s.enable ( + mkMerge [ + (mkIf cfg.k8s.master.enable kubeMaster) + (mkIf cfg.k8s.node.enable kubeNode) + ] + ); imports = [ ./os.nix ]; } diff --git a/lib/modules.nix b/lib/modules.nix new file mode 100644 index 0000000..2090f14 --- /dev/null +++ b/lib/modules.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ./os.nix + ./fs.nix + ./k8s.nix + ]; +} diff --git a/lib/os.nix b/lib/os.nix index 7397b42..2573216 100644 --- a/lib/os.nix +++ b/lib/os.nix @@ -55,8 +55,8 @@ in networking = { hostName = cfg.hostName; - domain = cfg.domain; - search = cfg.searchDomains; + # domain = cfg.domain; + # search = cfg.searchDomains; extraHosts = cfg.extraHosts; };