WIP: Module tweaks
This commit is contained in:
44
lib/base.nix
44
lib/base.nix
@@ -1,11 +1,13 @@
|
||||
{ pkgs, config, lib, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.k8s;
|
||||
|
||||
in
|
||||
rec {
|
||||
pki = import ./pki.nix { inherit pkgs; ca = cfg.initca; };
|
||||
|
||||
baseNixos = name: {
|
||||
baseNixos = name:
|
||||
{
|
||||
users.extraUsers.admin.openssh.authorizedKeys.keys =
|
||||
cfg.adminAuthorizedKeys;
|
||||
|
||||
@@ -18,9 +20,7 @@ let
|
||||
./nixos/configuration.nix
|
||||
];
|
||||
|
||||
security.pki.certificateFiles = [
|
||||
pki.ca.cert
|
||||
];
|
||||
security.pki.certificateFiles = [ pki.ca.cert ];
|
||||
|
||||
networking = {
|
||||
hostName = name;
|
||||
@@ -50,41 +50,13 @@ let
|
||||
];
|
||||
};
|
||||
|
||||
baseDeployment = attrs:
|
||||
baseDeployment = nodes: attrs:
|
||||
let
|
||||
hosts =
|
||||
builtins.foldl'
|
||||
(a: x: a // { ${x.name} = mkHost x _; }) {} cfg.hosts;
|
||||
(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
|
||||
{
|
||||
options.k8s = {
|
||||
initca = mkOption {
|
||||
type = types.path;
|
||||
};
|
||||
|
||||
clusterName = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
hosts = mkOption {
|
||||
type = types.listOf types.set;
|
||||
default = [];
|
||||
};
|
||||
|
||||
clusterHosts = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
adminAuthorizedKeys = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
};
|
||||
}
|
||||
|
||||
33
lib/module.nix
Normal file
33
lib/module.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
{ pkgs, config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.k8s;
|
||||
in
|
||||
{
|
||||
options.k8s = {
|
||||
initca = mkOption {
|
||||
type = types.path;
|
||||
};
|
||||
|
||||
clusterName = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
hosts = mkOption {
|
||||
type = types.listOf types.set;
|
||||
default = [];
|
||||
};
|
||||
|
||||
clusterHosts = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
adminAuthorizedKeys = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user