Begin getting unifi/openstack setup working
All checks were successful
/ dev-shell (push) Successful in 18s
/ terraform-providers (push) Successful in 11s
/ rust-packages (push) Successful in 23s
/ check (push) Successful in 1m29s

Now I can create an instance, get NixOS on it, with
working IPv6 connectivity
This commit is contained in:
Kaare Hoff Skovgaard 2025-07-08 16:33:18 +02:00
parent 1945038c90
commit fbed2265dd
Signed by: khs
GPG key ID: C7D890804F01E9F0
14 changed files with 47 additions and 18 deletions

View 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);
}

View file

@ -34,7 +34,7 @@ in
boot.kernelParams = lib.mkIf (system == "aarch64-linux") [ "console=tty" ]; boot.kernelParams = lib.mkIf (system == "aarch64-linux") [ "console=tty" ];
zramSwap.enable = lib.mkDefault true; zramSwap.enable = lib.mkDefault true;
khscodes.systemd-boot.enable = lib.mkDefault true; khscodes.systemd-boot.enable = lib.mkDefault true;
khscodes.qemu-guest.enable = true; khscodes.virtualisation.qemu-guest.enable = true;
networking = { networking = {
useDHCP = false; useDHCP = false;
useNetworkd = false; useNetworkd = false;

View file

@ -0,0 +1 @@
{ ... }: { }

View file

@ -5,7 +5,7 @@
... ...
}: }:
let let
cfg = config.khscodes.hetzner-instance; cfg = config.khscodes.infrastructure.hetzner-instance;
fqdn = config.khscodes.fqdn; fqdn = config.khscodes.fqdn;
firewallTcpRules = lib.lists.map (p: { firewallTcpRules = lib.lists.map (p: {
direction = "in"; direction = "in";
@ -47,7 +47,7 @@ let
lib.strings.removePrefix "${builtins.head split}." fqdn; lib.strings.removePrefix "${builtins.head split}." fqdn;
in in
{ {
options.khscodes.hetzner-instance = { options.khscodes.infrastructure.hetzner-instance = {
enable = lib.mkEnableOption "enables generating a opentofu config"; enable = lib.mkEnableOption "enables generating a opentofu config";
dnsNames = lib.mkOption { dnsNames = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
@ -210,7 +210,7 @@ in
} }
]; ];
khscodes.provisioning.pre = { khscodes.infrastructure.provisioning.pre = {
modules = modules; modules = modules;
secretsSource = cfg.secretsSource; secretsSource = cfg.secretsSource;
endpoints = [ endpoints = [

View file

@ -5,7 +5,7 @@
... ...
}: }:
let let
cfg = config.khscodes.khs-openstack-instance; cfg = config.khscodes.infrastructure.khs-openstack-instance;
fqdn = config.khscodes.fqdn; fqdn = config.khscodes.fqdn;
firewallTcpRules = lib.lists.flatten ( firewallTcpRules = lib.lists.flatten (
lib.lists.map (p: [ lib.lists.map (p: [
@ -69,7 +69,7 @@ let
lib.strings.removePrefix "${builtins.head split}." fqdn; lib.strings.removePrefix "${builtins.head split}." fqdn;
in in
{ {
options.khscodes.khs-openstack-instance = { options.khscodes.infrastructure.khs-openstack-instance = {
enable = lib.mkEnableOption "enables generating a opentofu config for khs openstack instance"; enable = lib.mkEnableOption "enables generating a opentofu config for khs openstack instance";
dnsNames = lib.mkOption { dnsNames = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
@ -237,7 +237,7 @@ in
} }
]; ];
khscodes.provisioning = { khscodes.infrastructure.provisioning = {
pre = { pre = {
modules = modules; modules = modules;
secretsSource = cfg.secretsSource; secretsSource = cfg.secretsSource;

View file

@ -6,7 +6,7 @@
... ...
}: }:
let let
cfg = config.khscodes.provisioning; cfg = config.khscodes.infrastructure.provisioning;
provisioning = { provisioning = {
modules = lib.mkOption { modules = lib.mkOption {
type = lib.types.listOf lib.types.anything; type = lib.types.listOf lib.types.anything;
@ -37,7 +37,7 @@ let
}; };
in in
{ {
options.khscodes.provisioning = { options.khscodes.infrastructure.provisioning = {
pre = provisioning; pre = provisioning;
post = provisioning; post = provisioning;
preConfig = lib.mkOption { preConfig = lib.mkOption {
@ -56,7 +56,7 @@ in
}; };
config = { config = {
khscodes.provisioning.preConfig = khscodes.infrastructure.provisioning.preConfig =
if lib.lists.length cfg.pre.modules > 0 then if lib.lists.length cfg.pre.modules > 0 then
inputs.terranix.lib.terranixConfiguration { inputs.terranix.lib.terranixConfiguration {
system = pkgs.hostPlatform.system; system = pkgs.hostPlatform.system;
@ -64,7 +64,7 @@ in
} }
else else
null; null;
khscodes.provisioning.postConfig = khscodes.infrastructure.provisioning.postConfig =
if lib.lists.length cfg.post.modules > 0 then if lib.lists.length cfg.post.modules > 0 then
inputs.terranix.lib.terranixConfiguration { inputs.terranix.lib.terranixConfiguration {
system = pkgs.hostPlatform.system; system = pkgs.hostPlatform.system;

View file

@ -22,6 +22,6 @@ in
}; };
boot.loader.grub.efiSupport = false; boot.loader.grub.efiSupport = false;
boot.loader.timeout = 1; boot.loader.timeout = 1;
khscodes.qemu-guest.enable = true; khscodes.virtualisation.qemu-guest.enable = true;
}; };
} }

View file

@ -0,0 +1,8 @@
{ ... }:
{ }
# let
# modules = lib.khscodes.dirsInPath ./.;
# in
# {
# imports = lib.lists.map (d: import d args) modules;
# }

View 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;
}

View file

@ -5,10 +5,10 @@
... ...
}: }:
let let
cfg = config.khscodes.qemu-guest; cfg = config.khscodes.virtualisation.qemu-guest;
in in
{ {
options.khscodes.qemu-guest = { options.khscodes.virtualisation.qemu-guest = {
enable = lib.mkEnableOption "Configures machine with NixOS profile for qemu guest"; enable = lib.mkEnableOption "Configures machine with NixOS profile for qemu guest";
}; };

View file

@ -15,7 +15,7 @@ pkgs.writeShellApplication {
nix build --no-link '${inputs.self}#nixosConfigurations."'"$hostname"'".config.system.build.toplevel' 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. # Allow overriding the host to connec tto, this is useful when testing and the DNS entries are stale with older IPs.
host="''${2:-$1}" 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")" config="$(nix build --no-link --print-out-paths "''${baseAttr}.preConfig")"
username="$(nix eval --raw "''${baseAttr}.preImageUsername")" username="$(nix eval --raw "''${baseAttr}.preImageUsername")"
if [[ "$config" == "null" ]]; then if [[ "$config" == "null" ]]; then

View file

@ -15,7 +15,7 @@ pkgs.writeShellApplication {
text = '' text = ''
hostname="$1" hostname="$1"
cmd="''${2:-apply}" 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")" config="$(nix build --no-link --print-out-paths "''${baseAttr}.preConfig")"
secretsSource="$(nix eval --raw "''${baseAttr}.pre.secretsSource")" secretsSource="$(nix eval --raw "''${baseAttr}.pre.secretsSource")"
endpoints="$(nix eval --json "''${baseAttr}.pre.endpoints")" endpoints="$(nix eval --json "''${baseAttr}.pre.endpoints")"

View file

@ -4,7 +4,7 @@
}: }:
{ {
imports = [ "${inputs.self}/nix/profiles/hetzner-server.nix" ]; imports = [ "${inputs.self}/nix/profiles/hetzner-server.nix" ];
khscodes.hetzner-instance = { khscodes.infrastructure.hetzner-instance = {
enable = true; enable = true;
mapRdns = true; mapRdns = true;
server_type = "cax11"; server_type = "cax11";

View file

@ -4,7 +4,7 @@
}: }:
{ {
imports = [ "${inputs.self}/nix/profiles/khs-openstack-server.nix" ]; imports = [ "${inputs.self}/nix/profiles/khs-openstack-server.nix" ];
khscodes.khs-openstack-instance = { khscodes.infrastructure.khs-openstack-instance = {
enable = true; enable = true;
flavor = "m.medium"; flavor = "m.medium";
secretsSource = "vault"; secretsSource = "vault";