Begin getting unifi/openstack setup working
Now I can create an instance, get NixOS on it, with working IPv6 connectivity
This commit is contained in:
parent
1945038c90
commit
fbed2265dd
14 changed files with 47 additions and 18 deletions
10
nix/lib/dirs-in-path/default.nix
Normal file
10
nix/lib/dirs-in-path/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ lib, ... }:
|
||||
{
|
||||
dirsInPath =
|
||||
path:
|
||||
let
|
||||
files = builtins.readDir path;
|
||||
dirs = lib.filterAttrs (name: kind: kind == "directory") files;
|
||||
in
|
||||
lib.lists.map (n: "${path}/${n}") (lib.attrNames dirs);
|
||||
}
|
|
@ -34,7 +34,7 @@ in
|
|||
boot.kernelParams = lib.mkIf (system == "aarch64-linux") [ "console=tty" ];
|
||||
zramSwap.enable = lib.mkDefault true;
|
||||
khscodes.systemd-boot.enable = lib.mkDefault true;
|
||||
khscodes.qemu-guest.enable = true;
|
||||
khscodes.virtualisation.qemu-guest.enable = true;
|
||||
networking = {
|
||||
useDHCP = false;
|
||||
useNetworkd = false;
|
||||
|
|
1
nix/modules/nixos/infrastructure/default.nix
Normal file
1
nix/modules/nixos/infrastructure/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ ... }: { }
|
|
@ -5,7 +5,7 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.khscodes.hetzner-instance;
|
||||
cfg = config.khscodes.infrastructure.hetzner-instance;
|
||||
fqdn = config.khscodes.fqdn;
|
||||
firewallTcpRules = lib.lists.map (p: {
|
||||
direction = "in";
|
||||
|
@ -47,7 +47,7 @@ let
|
|||
lib.strings.removePrefix "${builtins.head split}." fqdn;
|
||||
in
|
||||
{
|
||||
options.khscodes.hetzner-instance = {
|
||||
options.khscodes.infrastructure.hetzner-instance = {
|
||||
enable = lib.mkEnableOption "enables generating a opentofu config";
|
||||
dnsNames = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
|
@ -210,7 +210,7 @@ in
|
|||
}
|
||||
];
|
||||
|
||||
khscodes.provisioning.pre = {
|
||||
khscodes.infrastructure.provisioning.pre = {
|
||||
modules = modules;
|
||||
secretsSource = cfg.secretsSource;
|
||||
endpoints = [
|
|
@ -5,7 +5,7 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.khscodes.khs-openstack-instance;
|
||||
cfg = config.khscodes.infrastructure.khs-openstack-instance;
|
||||
fqdn = config.khscodes.fqdn;
|
||||
firewallTcpRules = lib.lists.flatten (
|
||||
lib.lists.map (p: [
|
||||
|
@ -69,7 +69,7 @@ let
|
|||
lib.strings.removePrefix "${builtins.head split}." fqdn;
|
||||
in
|
||||
{
|
||||
options.khscodes.khs-openstack-instance = {
|
||||
options.khscodes.infrastructure.khs-openstack-instance = {
|
||||
enable = lib.mkEnableOption "enables generating a opentofu config for khs openstack instance";
|
||||
dnsNames = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
|
@ -237,7 +237,7 @@ in
|
|||
}
|
||||
];
|
||||
|
||||
khscodes.provisioning = {
|
||||
khscodes.infrastructure.provisioning = {
|
||||
pre = {
|
||||
modules = modules;
|
||||
secretsSource = cfg.secretsSource;
|
|
@ -6,7 +6,7 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.khscodes.provisioning;
|
||||
cfg = config.khscodes.infrastructure.provisioning;
|
||||
provisioning = {
|
||||
modules = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.anything;
|
||||
|
@ -37,7 +37,7 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
options.khscodes.provisioning = {
|
||||
options.khscodes.infrastructure.provisioning = {
|
||||
pre = provisioning;
|
||||
post = provisioning;
|
||||
preConfig = lib.mkOption {
|
||||
|
@ -56,7 +56,7 @@ in
|
|||
};
|
||||
|
||||
config = {
|
||||
khscodes.provisioning.preConfig =
|
||||
khscodes.infrastructure.provisioning.preConfig =
|
||||
if lib.lists.length cfg.pre.modules > 0 then
|
||||
inputs.terranix.lib.terranixConfiguration {
|
||||
system = pkgs.hostPlatform.system;
|
||||
|
@ -64,7 +64,7 @@ in
|
|||
}
|
||||
else
|
||||
null;
|
||||
khscodes.provisioning.postConfig =
|
||||
khscodes.infrastructure.provisioning.postConfig =
|
||||
if lib.lists.length cfg.post.modules > 0 then
|
||||
inputs.terranix.lib.terranixConfiguration {
|
||||
system = pkgs.hostPlatform.system;
|
|
@ -22,6 +22,6 @@ in
|
|||
};
|
||||
boot.loader.grub.efiSupport = false;
|
||||
boot.loader.timeout = 1;
|
||||
khscodes.qemu-guest.enable = true;
|
||||
khscodes.virtualisation.qemu-guest.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
8
nix/modules/nixos/services/default.nix
Normal file
8
nix/modules/nixos/services/default.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{ ... }:
|
||||
{ }
|
||||
# let
|
||||
# modules = lib.khscodes.dirsInPath ./.;
|
||||
# in
|
||||
# {
|
||||
# imports = lib.lists.map (d: import d args) modules;
|
||||
# }
|
10
nix/modules/nixos/virtualisation/default.nix
Normal file
10
nix/modules/nixos/virtualisation/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
# TODO: Why is this needed just for this directory?
|
||||
# In the other directories this will create the modules twice.
|
||||
# Perhaps because there's only a single sub directory here?
|
||||
args@{ lib, ... }:
|
||||
let
|
||||
modules = lib.khscodes.dirsInPath ./.;
|
||||
in
|
||||
{
|
||||
imports = lib.lists.map (d: import d args) modules;
|
||||
}
|
|
@ -5,10 +5,10 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.khscodes.qemu-guest;
|
||||
cfg = config.khscodes.virtualisation.qemu-guest;
|
||||
in
|
||||
{
|
||||
options.khscodes.qemu-guest = {
|
||||
options.khscodes.virtualisation.qemu-guest = {
|
||||
enable = lib.mkEnableOption "Configures machine with NixOS profile for qemu guest";
|
||||
};
|
||||
|
|
@ -15,7 +15,7 @@ pkgs.writeShellApplication {
|
|||
nix build --no-link '${inputs.self}#nixosConfigurations."'"$hostname"'".config.system.build.toplevel'
|
||||
# Allow overriding the host to connec tto, this is useful when testing and the DNS entries are stale with older IPs.
|
||||
host="''${2:-$1}"
|
||||
baseAttr='${inputs.self}#nixosConfigurations."'"$hostname"'".config.khscodes.provisioning'
|
||||
baseAttr='${inputs.self}#nixosConfigurations."'"$hostname"'".config.khscodes.infrastructure.provisioning'
|
||||
config="$(nix build --no-link --print-out-paths "''${baseAttr}.preConfig")"
|
||||
username="$(nix eval --raw "''${baseAttr}.preImageUsername")"
|
||||
if [[ "$config" == "null" ]]; then
|
||||
|
|
|
@ -15,7 +15,7 @@ pkgs.writeShellApplication {
|
|||
text = ''
|
||||
hostname="$1"
|
||||
cmd="''${2:-apply}"
|
||||
baseAttr='${inputs.self}#nixosConfigurations."'"$hostname"'".config.khscodes.provisioning'
|
||||
baseAttr='${inputs.self}#nixosConfigurations."'"$hostname"'".config.khscodes.infrastructue.provisioning'
|
||||
config="$(nix build --no-link --print-out-paths "''${baseAttr}.preConfig")"
|
||||
secretsSource="$(nix eval --raw "''${baseAttr}.pre.secretsSource")"
|
||||
endpoints="$(nix eval --json "''${baseAttr}.pre.endpoints")"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
}:
|
||||
{
|
||||
imports = [ "${inputs.self}/nix/profiles/hetzner-server.nix" ];
|
||||
khscodes.hetzner-instance = {
|
||||
khscodes.infrastructure.hetzner-instance = {
|
||||
enable = true;
|
||||
mapRdns = true;
|
||||
server_type = "cax11";
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
}:
|
||||
{
|
||||
imports = [ "${inputs.self}/nix/profiles/khs-openstack-server.nix" ];
|
||||
khscodes.khs-openstack-instance = {
|
||||
khscodes.infrastructure.khs-openstack-instance = {
|
||||
enable = true;
|
||||
flavor = "m.medium";
|
||||
secretsSource = "vault";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue