forked from mirrors_public/oddlama_nix-config
refactor: add lib extensions to nixpkgs.lib as overlays
This commit is contained in:
parent
385d8178a2
commit
e1e7516e1a
19 changed files with 743 additions and 813 deletions
|
@ -12,32 +12,27 @@
|
|||
attrNames
|
||||
attrValues
|
||||
concatStringsSep
|
||||
disko
|
||||
escapeShellArg
|
||||
filterAttrs
|
||||
foldl'
|
||||
makeBinPath
|
||||
mapAttrsToList
|
||||
mdDoc
|
||||
mergeToplevelConfigs
|
||||
mkDefault
|
||||
mkEnableOption
|
||||
mkForce
|
||||
mkIf
|
||||
mkMerge
|
||||
mkOption
|
||||
net
|
||||
optional
|
||||
optionalAttrs
|
||||
recursiveUpdate
|
||||
types
|
||||
;
|
||||
|
||||
inherit
|
||||
(import ../../lib/misc.nix inputs)
|
||||
mergeToplevelConfigs
|
||||
;
|
||||
|
||||
net = import ../../lib/net.nix inputs;
|
||||
disko = import ../../lib/disko.nix inputs;
|
||||
|
||||
parentConfig = config;
|
||||
cfg = config.meta.microvms;
|
||||
nodeName = config.node.name;
|
||||
|
@ -236,7 +231,7 @@ in {
|
|||
|
||||
networking = {
|
||||
baseMac = mkOption {
|
||||
type = net.types.mac;
|
||||
type = types.net.mac;
|
||||
description = mdDoc ''
|
||||
This MAC address will be used as a base address to derive all MicroVM MAC addresses from.
|
||||
A good practise is to use the physical address of the macvtap interface.
|
||||
|
@ -250,13 +245,13 @@ in {
|
|||
|
||||
wireguard = {
|
||||
cidrv4 = mkOption {
|
||||
type = net.types.cidrv4;
|
||||
type = types.net.cidrv4;
|
||||
description = mdDoc "The ipv4 network address range to use for internal vm traffic.";
|
||||
default = "172.31.0.0/24";
|
||||
};
|
||||
|
||||
cidrv6 = mkOption {
|
||||
type = net.types.cidrv6;
|
||||
type = types.net.cidrv6;
|
||||
description = mdDoc "The ipv6 network address range to use for internal vm traffic.";
|
||||
default = "fd00:172:31::/120";
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
nodes,
|
||||
pkgs,
|
||||
|
@ -12,10 +11,12 @@
|
|||
assertMsg
|
||||
attrNames
|
||||
attrValues
|
||||
concatAttrs
|
||||
concatLists
|
||||
concatMap
|
||||
concatMapStrings
|
||||
concatStringsSep
|
||||
duplicates
|
||||
escapeShellArg
|
||||
filter
|
||||
filterAttrs
|
||||
|
@ -27,41 +28,28 @@
|
|||
mapAttrsToList
|
||||
mdDoc
|
||||
mergeAttrs
|
||||
mergeToplevelConfigs
|
||||
mkForce
|
||||
mkIf
|
||||
mkMerge
|
||||
mkOption
|
||||
nameValuePair
|
||||
net
|
||||
optionalAttrs
|
||||
optionals
|
||||
partition
|
||||
removeSuffix
|
||||
stringLength
|
||||
types
|
||||
wireguard
|
||||
;
|
||||
|
||||
inherit
|
||||
(import ../../lib/misc.nix inputs)
|
||||
concatAttrs
|
||||
duplicates
|
||||
mergeToplevelConfigs
|
||||
;
|
||||
|
||||
inherit
|
||||
(import ../../lib/types.nix inputs)
|
||||
lazyOf
|
||||
lazyValue
|
||||
;
|
||||
|
||||
net = import ../../lib/net.nix inputs;
|
||||
wgLibFor = import ../../lib/wireguard.nix inputs;
|
||||
|
||||
cfg = config.meta.wireguard;
|
||||
nodeName = config.node.name;
|
||||
|
||||
configForNetwork = wgName: wgCfg: let
|
||||
inherit
|
||||
(wgLibFor wgName)
|
||||
(wireguard wgName)
|
||||
externalPeerName
|
||||
externalPeerNamesRaw
|
||||
networkCidrs
|
||||
|
@ -307,7 +295,7 @@ in {
|
|||
};
|
||||
|
||||
externalPeers = mkOption {
|
||||
type = types.attrsOf (types.listOf (net.types.ip-in config.addresses));
|
||||
type = types.attrsOf (types.listOf (types.net.ip-in config.addresses));
|
||||
default = {};
|
||||
example = {my-android-phone = ["10.0.0.97"];};
|
||||
description = mdDoc ''
|
||||
|
@ -321,7 +309,7 @@ in {
|
|||
};
|
||||
|
||||
reservedAddresses = mkOption {
|
||||
type = types.listOf net.types.cidr;
|
||||
type = types.listOf types.net.cidr;
|
||||
default = [];
|
||||
example = ["10.0.0.1/24" "fd00:cafe::/64"];
|
||||
description = mdDoc ''
|
||||
|
@ -377,8 +365,8 @@ in {
|
|||
};
|
||||
|
||||
ipv4 = mkOption {
|
||||
type = lazyOf net.types.ipv4;
|
||||
default = lazyValue (wgLibFor name).assignedIpv4Addresses.${nodeName};
|
||||
type = types.lazyOf types.net.ipv4;
|
||||
default = types.lazyValue (wireguard name).assignedIpv4Addresses.${nodeName};
|
||||
description = mdDoc ''
|
||||
The ipv4 address for this machine. If you do not set this explicitly,
|
||||
a semi-stable ipv4 address will be derived automatically based on the
|
||||
|
@ -389,8 +377,8 @@ in {
|
|||
};
|
||||
|
||||
ipv6 = mkOption {
|
||||
type = lazyOf net.types.ipv6;
|
||||
default = lazyValue (wgLibFor name).assignedIpv6Addresses.${nodeName};
|
||||
type = types.lazyOf types.net.ipv6;
|
||||
default = types.lazyValue (wireguard name).assignedIpv6Addresses.${nodeName};
|
||||
description = mdDoc ''
|
||||
The ipv6 address for this machine. If you do not set this explicitly,
|
||||
a semi-stable ipv6 address will be derived automatically based on the
|
||||
|
@ -401,7 +389,7 @@ in {
|
|||
};
|
||||
|
||||
addresses = mkOption {
|
||||
type = types.listOf (lazyOf net.types.ip);
|
||||
type = types.listOf (types.lazyOf types.net.ip);
|
||||
default = [
|
||||
(head options.ipv4.definitions)
|
||||
(head options.ipv6.definitions)
|
||||
|
@ -420,7 +408,7 @@ in {
|
|||
# to use the network without routing additional stuff.
|
||||
# - allow specifying the route metric.
|
||||
routedAddresses = mkOption {
|
||||
type = types.listOf net.types.cidr;
|
||||
type = types.listOf types.net.cidr;
|
||||
default = [];
|
||||
example = ["0.0.0.0/0"];
|
||||
description = mdDoc ''
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Provides an option to easily rename interfaces by their mac addresses.
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
|
@ -10,17 +9,13 @@
|
|||
(lib)
|
||||
attrValues
|
||||
concatStringsSep
|
||||
duplicates
|
||||
mapAttrsToList
|
||||
mkIf
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
|
||||
inherit
|
||||
(import ../../lib/misc.nix inputs)
|
||||
duplicates
|
||||
;
|
||||
|
||||
cfg = config.networking.renameInterfacesByMac;
|
||||
|
||||
interfaceNamesUdevRules = pkgs.writeTextFile {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue