nixos: Add domain to assignments

This commit is contained in:
Jack O'Sullivan 2022-06-05 16:40:44 +01:00
parent fd4fcdc2a4
commit 4e36748154
6 changed files with 12 additions and 9 deletions

View File

@ -9,6 +9,7 @@
assignments = { assignments = {
internal = { internal = {
altNames = [ "vm" ]; altNames = [ "vm" ];
domain = lib.my.colony.domain;
ipv4.address = "${lib.my.colony.start.base.v4}2"; ipv4.address = "${lib.my.colony.start.base.v4}2";
ipv6 = { ipv6 = {
iid = "::2"; iid = "::2";
@ -32,8 +33,6 @@
{ {
imports = [ "${modulesPath}/profiles/qemu-guest.nix" ]; imports = [ "${modulesPath}/profiles/qemu-guest.nix" ];
networking.domain = lib.my.colony.domain;
boot.kernelParams = [ "intel_iommu=on" ]; boot.kernelParams = [ "intel_iommu=on" ];
boot.loader.systemd-boot.configurationLimit = 20; boot.loader.systemd-boot.configurationLimit = 20;
fileSystems = { fileSystems = {

View File

@ -8,6 +8,7 @@
internal = { internal = {
name = "estuary-vm"; name = "estuary-vm";
altNames = [ "fw" ]; altNames = [ "fw" ];
domain = lib.my.colony.domain;
ipv4 = { ipv4 = {
address = "80.111.124.10"; address = "80.111.124.10";
gateway = null; gateway = null;
@ -37,8 +38,6 @@
config = mkMerge [ config = mkMerge [
{ {
networking.domain = lib.my.colony.domain;
boot.kernelParams = [ "console=ttyS0,115200n8" ]; boot.kernelParams = [ "console=ttyS0,115200n8" ];
fileSystems = { fileSystems = {
"/boot" = { "/boot" = {

View File

@ -7,6 +7,7 @@
internal = { internal = {
name = "middleman-ctr"; name = "middleman-ctr";
altNames = [ "http" ]; altNames = [ "http" ];
domain = lib.my.colony.domain;
ipv4.address = "${lib.my.colony.start.ctrs.v4}2"; ipv4.address = "${lib.my.colony.start.ctrs.v4}2";
ipv6 = { ipv6 = {
iid = "::2"; iid = "::2";

View File

@ -6,6 +6,7 @@
assignments = { assignments = {
internal = { internal = {
name = "vaultwarden-ctr"; name = "vaultwarden-ctr";
domain = lib.my.colony.domain;
ipv4.address = "${lib.my.colony.start.ctrs.v4}3"; ipv4.address = "${lib.my.colony.start.ctrs.v4}3";
ipv6 = { ipv6 = {
iid = "::3"; iid = "::3";

View File

@ -9,6 +9,7 @@
internal = { internal = {
name = "shill-vm"; name = "shill-vm";
altNames = [ "ctr" ]; altNames = [ "ctr" ];
domain = lib.my.colony.domain;
ipv4.address = "${lib.my.colony.start.vms.v4}2"; ipv4.address = "${lib.my.colony.start.vms.v4}2";
ipv6 = { ipv6 = {
iid = "::2"; iid = "::2";
@ -35,8 +36,6 @@
config = mkMerge [ config = mkMerge [
{ {
networking.domain = lib.my.colony.domain;
boot.kernelParams = [ "console=ttyS0,115200n8" ]; boot.kernelParams = [ "console=ttyS0,115200n8" ];
fileSystems = { fileSystems = {
"/boot" = { "/boot" = {

View File

@ -1,8 +1,8 @@
{ lib, pkgsFlakes, hmFlakes, inputs, pkgs', config, ... }: { lib, pkgsFlakes, hmFlakes, inputs, pkgs', config, ... }:
let let
inherit (builtins) attrValues mapAttrs; inherit (builtins) attrValues mapAttrs;
inherit (lib) substring flatten optional optionals mkDefault mkForce mkOption mkOptionType; inherit (lib) substring flatten optional optionals mkIf mkDefault mkForce mkOption mkOptionType;
inherit (lib.my) naiveIPv4Gateway homeStateVersion mkOpt' mkBoolOpt' commonOpts inlineModule'; inherit (lib.my) naiveIPv4Gateway homeStateVersion mkOpt' mkBoolOpt' mkDefault' commonOpts inlineModule';
cfg = config.nixos; cfg = config.nixos;
@ -50,7 +50,10 @@ let
}; };
system.name = name; system.name = name;
networking.hostName = mkDefault (config'.assignments.internal.name or name); networking = {
domain = let d = config'.assignments.internal.domain; in mkIf (d != null) (mkDefault' d);
hostName = mkDefault (config'.assignments.internal.name or name);
};
nixpkgs = { nixpkgs = {
inherit (config') system; inherit (config') system;
# Make sure any previously set overlays (e.g. lib which will be inherited by home-manager down the # Make sure any previously set overlays (e.g. lib which will be inherited by home-manager down the
@ -94,6 +97,7 @@ let
name = mkOpt' str name "Name of assignment."; name = mkOpt' str name "Name of assignment.";
altNames = mkOpt' (listOf str) [ ] "Extra names to assign."; altNames = mkOpt' (listOf str) [ ] "Extra names to assign.";
visible = mkBoolOpt' true "Whether or not this assignment should be visible."; visible = mkBoolOpt' true "Whether or not this assignment should be visible.";
domain = mkOpt' (nullOr str) null "Domain for this assignment.";
ipv4 = { ipv4 = {
address = mkOpt' str null "IPv4 address."; address = mkOpt' str null "IPv4 address.";
mask = mkOpt' ints.u8 24 "Network mask."; mask = mkOpt' ints.u8 24 "Network mask.";