chore: nf-fmt-nix

This commit is contained in:
arcnmx 2024-05-13 15:13:58 -07:00
parent 7486517713
commit 9903866044
160 changed files with 4570 additions and 3019 deletions

View file

@ -1,4 +1,8 @@
{config, lib, ...}: let
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
cfg = config.proxmox.container;
in {

View file

@ -1,4 +1,10 @@
{config, gensokyo-zone, lib, Std, ...}: let
{
config,
gensokyo-zone,
lib,
Std,
...
}: let
inherit (Std) UInt;
inherit (gensokyo-zone.lib) unmerged eui64 mkAlmostOptionDefault mapAlmostOptionDefaults;
inherit (lib.options) mkOption mkEnableOption;
@ -9,11 +15,18 @@
inherit (lib.trivial) mapNullable;
cfg = config.proxmox.network;
internalOffset = 32;
networkInterfaceModule = { config, name, system, ... }: {
networkInterfaceModule = {
config,
name,
system,
...
}: {
options = with lib.types; {
enable = mkEnableOption "network interface" // {
default = true;
};
enable =
mkEnableOption "network interface"
// {
default = true;
};
bridge = mkOption {
type = str;
default = "vmbr0";
@ -30,7 +43,7 @@
default = null;
};
address4 = mkOption {
type = nullOr (either (enum [ "dhcp" ]) str);
type = nullOr (either (enum ["dhcp"]) str);
default = null;
};
gateway4 = mkOption {
@ -38,7 +51,7 @@
default = null;
};
address6 = mkOption {
type = nullOr (either (enum [ "auto" "dhcp" ]) str);
type = nullOr (either (enum ["auto" "dhcp"]) str);
default = null;
};
gateway6 = mkOption {
@ -47,13 +60,15 @@
};
firewall.enable = mkEnableOption "firewall";
vm.model = mkOption {
type = enum [ "virtio" "e1000" "rtl8139" "vmxnet3" ];
type = enum ["virtio" "e1000" "rtl8139" "vmxnet3"];
default = "virtio";
};
mdns = {
enable = mkEnableOption "mDNS" // {
default = config.local.enable && config.id == "net0";
};
enable =
mkEnableOption "mDNS"
// {
default = config.local.enable && config.id == "net0";
};
};
slaac = {
postfix = mkOption {
@ -76,9 +91,11 @@
};
};
networkd = {
enable = mkEnableOption "systemd.network" // {
default = true;
};
enable =
mkEnableOption "systemd.network"
// {
default = true;
};
name = mkOption {
type = str;
default = config.name;
@ -90,14 +107,20 @@
};
};
config = let
hasAddr4 = ! elem config.address4 [ null "dhcp" ];
hasAddr6 = ! elem config.address6 [ null "dhcp" "auto" ];
hasAddr4 = ! elem config.address4 [null "dhcp"];
hasAddr6 = ! elem config.address6 [null "dhcp" "auto"];
conf = {
local = mkIf config.local.enable {
address4 = mkOptionDefault (if hasAddr4 then config.address4 else null);
address4 = mkOptionDefault (
if hasAddr4
then config.address4
else null
);
address6 = mkOptionDefault (
if config.address6 == "auto" && config.slaac.postfix != null then "fd0a::${config.slaac.postfix}"
else if hasAddr6 then config.address6
if config.address6 == "auto" && config.slaac.postfix != null
then "fd0a::${config.slaac.postfix}"
else if hasAddr6
then config.address6
else null
);
};
@ -123,7 +146,7 @@
Type = mkOptionDefault "ether";
};
linkConfig = mkMerge [
(mkIf config.mdns.enable { Multicast = mkOptionDefault true; })
(mkIf config.mdns.enable {Multicast = mkOptionDefault true;})
];
networkConfig = mkMerge [
(mkIf (config.address6 == "auto") {
@ -134,17 +157,20 @@
})
];
address = mkMerge [
(mkIf (! elem config.address4 [ null "dhcp" ]) [ config.address4 ])
(mkIf (! elem config.address6 [ null "auto" "dhcp" ]) [ config.address6 ])
(mkIf (! elem config.address4 [null "dhcp"]) [config.address4])
(mkIf (! elem config.address6 [null "auto" "dhcp"]) [config.address6])
];
gateway = mkMerge [
(mkIf (config.gateway4 != null) [ config.gateway4 ])
(mkIf (config.gateway6 != null) [ config.gateway6 ])
(mkIf (config.gateway4 != null) [config.gateway4])
(mkIf (config.gateway6 != null) [config.gateway6])
];
DHCP = mkAlmostOptionDefault (
if config.address4 == "dhcp" && config.address6 == "dhcp" then "yes"
else if config.address6 == "dhcp" then "ipv6"
else if config.address4 == "dhcp" then "ipv4"
if config.address4 == "dhcp" && config.address6 == "dhcp"
then "yes"
else if config.address6 == "dhcp"
then "ipv6"
else if config.address4 == "dhcp"
then "ipv4"
else "no"
);
};
@ -157,11 +183,11 @@
address4 = mkAlmostOptionDefault "10.9.1.${toString index}/24";
address6 = mkAlmostOptionDefault "fd0c::${UInt.toHexLower index}/64";
macAddress = mkIf (system.proxmox.network.interfaces.net0.macAddress or null != null && hasPrefix "BC:24:11:" system.proxmox.network.interfaces.net0.macAddress) (mkAlmostOptionDefault (
replaceStrings [ "BC:24:11:" ] [ "BC:24:19:" ] system.proxmox.network.interfaces.net0.macAddress
replaceStrings ["BC:24:11:"] ["BC:24:19:"] system.proxmox.network.interfaces.net0.macAddress
));
networkd.name = mkDefault "_00-int";
networkd.networkSettings = {
domains = mkDefault [ ]; # int.${domain}?
domains = mkDefault []; # int.${domain}?
linkConfig.RequiredForOnline = false;
ipv6AcceptRAConfig = {
Token = mkOptionDefault "static:::${UInt.toHexLower index}";
@ -172,21 +198,22 @@
};
};
};
in mkMerge [
conf
(mkIf config.internal.enable confInternal)
];
in
mkMerge [
conf
(mkIf config.internal.enable confInternal)
];
};
in {
options.proxmox.network = with lib.types; {
interfaces = mkOption {
type = attrsOf (submoduleWith {
modules = [ networkInterfaceModule ];
modules = [networkInterfaceModule];
specialArgs = {
system = config;
};
});
default = { };
default = {};
};
internal = {
interface = mkOption {

View file

@ -1,4 +1,9 @@
{config, lib, gensokyo-zone, ...}: let
{
config,
lib,
gensokyo-zone,
...
}: let
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf;

View file

@ -1,4 +1,8 @@
{config, lib, ...}: let
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
cfg = config.proxmox;
in {