WIP: Module tweaks
This commit is contained in:
@@ -1,11 +1,17 @@
|
|||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
with import ../../lib/base.nix { inherit pkgs lib config; };
|
||||||
let
|
let
|
||||||
settings = {
|
|
||||||
initca = ./ca;
|
|
||||||
clusterName = "fs2";
|
|
||||||
hosts = [
|
hosts = [
|
||||||
{ name = "fs2-0"; address = "10.1.2.117"; }
|
{ name = "fs2-0"; address = "10.1.2.117"; }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
fsConfig = node:
|
||||||
|
let
|
||||||
|
cert = base.hostCerts.${node};
|
||||||
|
in {
|
||||||
|
k8s = {
|
||||||
|
initca = ./ca;
|
||||||
|
clusterName = "fs2";
|
||||||
clusterHosts = ''
|
clusterHosts = ''
|
||||||
10.253.18.106 fs0-0 fs0-0.itpartner.no fs0-0.itpartner.intern
|
10.253.18.106 fs0-0 fs0-0.itpartner.no fs0-0.itpartner.intern
|
||||||
|
|
||||||
@@ -32,12 +38,6 @@ let
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
base = import ../../lib/base.nix { inherit pkgs lib settings here; };
|
|
||||||
|
|
||||||
fsConfig = node:
|
|
||||||
let cert = base.hostCerts.${node};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
boot.kernelModules = [
|
boot.kernelModules = [
|
||||||
"dm_snapshot"
|
"dm_snapshot"
|
||||||
"dm_mirror"
|
"dm_mirror"
|
||||||
@@ -69,13 +69,10 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.lvm2 ];
|
environment.systemPackages = [ pkgs.lvm2 ];
|
||||||
|
|
||||||
|
imports = [ ./fs2-0.nix ];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
baseDeployment hosts {
|
||||||
local = {
|
fs2-0 = fsConfig "fs2-0";
|
||||||
};
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# base.baseDeployment {
|
|
||||||
# fs2-0 = fsConfig "fs2-0";
|
|
||||||
# }
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{ pkgs, config, ...}:
|
|
||||||
{
|
|
||||||
hostName = "";
|
|
||||||
desktop = false;
|
|
||||||
lan = false;
|
|
||||||
uefi = false;
|
|
||||||
bootdisk = "/dev/sda";
|
|
||||||
eth = "ens32";
|
|
||||||
virtualization = "vmware-guest";
|
|
||||||
kernelExtras = false;
|
|
||||||
}
|
|
||||||
44
lib/base.nix
44
lib/base.nix
@@ -1,11 +1,13 @@
|
|||||||
{ pkgs, config, lib, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.k8s;
|
cfg = config.k8s;
|
||||||
|
in
|
||||||
|
rec {
|
||||||
pki = import ./pki.nix { inherit pkgs; ca = cfg.initca; };
|
pki = import ./pki.nix { inherit pkgs; ca = cfg.initca; };
|
||||||
|
|
||||||
baseNixos = name: {
|
baseNixos = name:
|
||||||
|
{
|
||||||
users.extraUsers.admin.openssh.authorizedKeys.keys =
|
users.extraUsers.admin.openssh.authorizedKeys.keys =
|
||||||
cfg.adminAuthorizedKeys;
|
cfg.adminAuthorizedKeys;
|
||||||
|
|
||||||
@@ -18,9 +20,7 @@ let
|
|||||||
./nixos/configuration.nix
|
./nixos/configuration.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
security.pki.certificateFiles = [
|
security.pki.certificateFiles = [ pki.ca.cert ];
|
||||||
pki.ca.cert
|
|
||||||
];
|
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
hostName = name;
|
hostName = name;
|
||||||
@@ -50,41 +50,13 @@ let
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
baseDeployment = attrs:
|
baseDeployment = nodes: attrs:
|
||||||
let
|
let
|
||||||
hosts =
|
hosts =
|
||||||
builtins.foldl'
|
builtins.foldl'
|
||||||
(a: x: a // { ${x.name} = mkHost x _; }) {} cfg.hosts;
|
(a: x: a // { ${x.name} = mkHost x _; }) {} nodes;
|
||||||
hosts' = lib.recursiveUpdate hosts attrs;
|
hosts' = lib.recursiveUpdate hosts attrs;
|
||||||
names = builtins.attrNames hosts;
|
names = builtins.attrNames hosts;
|
||||||
in
|
in
|
||||||
builtins.foldl' (a: x: a // { ${x} = self: hosts'.${x}; }) {} names;
|
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