refactor(lib): start using Std

This commit is contained in:
arcnmx 2024-05-02 11:01:10 -07:00
parent 9184146fed
commit 0a9747c396
5 changed files with 32 additions and 43 deletions

View file

@ -1,6 +1,6 @@
let
allowListModule = {config, name, gensokyo-zone, lib, ...}: let
inherit (gensokyo-zone.lib) hexToInt;
inherit (gensokyo-zone.Std) UInt;
inherit (lib.options) mkOption;
inherit (lib.modules) mkOptionDefault;
inherit (builtins) typeOf;
@ -26,7 +26,7 @@ let
};
config = let
xuid = {
string = toString (hexToInt config.xuid);
string = toString (UInt.FromHex config.xuid);
int = toString config.xuid;
}.${typeOf config.xuid};
in {

View file

@ -3,6 +3,7 @@
config,
meta,
std,
Std,
lib,
inputs,
...
@ -104,7 +105,7 @@ in {
inherit (config) system modules specialArgs;
}) config.builder);
specialArgs = {
inherit name inputs std meta;
inherit name inputs std Std meta;
inherit (inputs.self.lib) gensokyo-zone;
systemType = config.folder;
system = config;

View file

@ -1,5 +1,6 @@
{config, lib, inputs, ...}: let
inherit (inputs.self.lib.lib) unmerged eui64 toHexStringLower mkAlmostOptionDefault mapAlmostOptionDefaults;
{config, gensokyo-zone, lib, Std, ...}: let
inherit (Std) UInt;
inherit (gensokyo-zone.lib) unmerged eui64 mkAlmostOptionDefault mapAlmostOptionDefaults;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge mkDefault mkOptionDefault;
inherit (lib.attrsets) attrValues;
@ -154,7 +155,7 @@
name = mkIf system.proxmox.container.enable (mkAlmostOptionDefault "eth9");
bridge = mkAlmostOptionDefault "vmbr9";
address4 = mkAlmostOptionDefault "10.9.1.${toString index}/24";
address6 = mkAlmostOptionDefault "fd0c::${toHexStringLower index}/64";
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
));
@ -163,7 +164,7 @@
domains = mkDefault [ ]; # int.${domain}?
linkConfig.RequiredForOnline = false;
ipv6AcceptRAConfig = {
Token = mkOptionDefault "static:::${toHexStringLower index}";
Token = mkOptionDefault "static:::${UInt.toHexLower index}";
DHCPv6Client = mkOptionDefault false;
};
networkConfig = {