mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-11 15:20:39 +02:00
feat: use predictable container network creation
This commit is contained in:
parent
336f648275
commit
aa5ce08891
1 changed files with 13 additions and 2 deletions
|
@ -9,13 +9,16 @@ guestName: guestCfg: {
|
||||||
}: let
|
}: let
|
||||||
inherit
|
inherit
|
||||||
(lib)
|
(lib)
|
||||||
mapAttrs'
|
|
||||||
flip
|
flip
|
||||||
|
mapAttrs'
|
||||||
nameValuePair
|
nameValuePair
|
||||||
|
substring
|
||||||
;
|
;
|
||||||
|
|
||||||
|
initialLinkName = "mv-${(substring 0 13 (builtins.hashString "sha256" guestName))}";
|
||||||
in {
|
in {
|
||||||
autoStart = guestCfg.autostart;
|
autoStart = guestCfg.autostart;
|
||||||
macvlans = ["${guestCfg.container.macvlan}:${guestCfg.networking.mainLinkName}"];
|
macvlans = ["${guestCfg.container.macvlan}:${initialLinkName}"];
|
||||||
ephemeral = true;
|
ephemeral = true;
|
||||||
privateNetwork = true;
|
privateNetwork = true;
|
||||||
bindMounts = flip mapAttrs' guestCfg.zfs (
|
bindMounts = flip mapAttrs' guestCfg.zfs (
|
||||||
|
@ -57,6 +60,14 @@ in {
|
||||||
device = zfsCfg.guestMountpoint;
|
device = zfsCfg.guestMountpoint;
|
||||||
options = ["bind"];
|
options = ["bind"];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
# Rename the network interface to our liking
|
||||||
|
systemd.network.links = {
|
||||||
|
"01-${guestCfg.networking.mainLinkName}" = {
|
||||||
|
matchConfig.OriginalName = initialLinkName;
|
||||||
|
linkConfig.Name = guestCfg.networking.mainLinkName;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
(import ./common-guest-config.nix guestName guestCfg)
|
(import ./common-guest-config.nix guestName guestCfg)
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue