From 7cd2b2ca203c27866e32727d947a5be7c92a8cfc Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 16 Sep 2026 16:18:25 -0400 Subject: [PATCH] macvlan --- flake.lock | 8 ++--- hosts/hl-minipc2.nix | 31 +++++++++++++++++-- .../containers/container-services/options.nix | 11 ++++++- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index fdbc83e..641c37e 100644 --- a/flake.lock +++ b/flake.lock @@ -831,11 +831,11 @@ "nixpkgs": "nixpkgs_7" }, "locked": { - "lastModified": 1789499413, - "narHash": "sha256-RyMbCILS77BUTZqT1/ST3cVUsflfnp/7rm6S25MG4jA=", + "lastModified": 1789573245, + "narHash": "sha256-Uw1DJF/XubQrnzjPftoE6yBGIYKQ1UjMYpG6k2ye6VA=", "ref": "refs/heads/main", - "rev": "41ea93a28fc3b2a80231330c5f6d57f5f988af6b", - "revCount": 7, + "rev": "e5f150b17e3ac19b3082246734741885fb141a2d", + "revCount": 18, "type": "git", "url": "ssh://gitea@minipc1.lab.internal:22/ari/hermenix.git" }, diff --git a/hosts/hl-minipc2.nix b/hosts/hl-minipc2.nix index 10d7187..63ff156 100644 --- a/hosts/hl-minipc2.nix +++ b/hosts/hl-minipc2.nix @@ -1,4 +1,23 @@ { pkgs, config, ... }: +let + macvlanNetwork = { + lan = { + driver = "macvlan"; + driver_opts = { + parent = "enp2s0"; + }; + ipam = { + config = [ + { + subnet = "10.0.0.0/16"; + gateway = "10.0.0.1"; + ip_range = "10.0.101.240/28"; + } + ]; + }; + }; + }; +in { skyg.user.enable = true; skyg.nixos.common.ssh-server.enable = true; @@ -54,10 +73,16 @@ autoUpdate.enable = true; services.drawdb = { image = "ghcr.io/drawdb-io/drawdb:latest"; - ports = [ - "3000:80" - ]; + environment = { + PORT = "80"; + }; + networks = { + lan = { + ipv4_address = "10.0.101.2"; + }; + }; }; + networks = macvlanNetwork; }; # Portainer Service diff --git a/modules/nixos/common/containers/container-services/options.nix b/modules/nixos/common/containers/container-services/options.nix index 3a8b5b7..e01b96d 100644 --- a/modules/nixos/common/containers/container-services/options.nix +++ b/modules/nixos/common/containers/container-services/options.nix @@ -139,11 +139,20 @@ }; networks = lib.mkOption { - type = lib.types.listOf lib.types.str; + type = lib.types.either (lib.types.listOf lib.types.str) (lib.types.attrsOf lib.types.anything); default = [ ]; + example = { + lan = { ipv4_address = "10.0.101.1"; }; + }; description = '' Networks to join. Empty list = attach to the group's auto-created bridge network (named after the group). + + Accepts either a plain list of network names, or an attrset + mapping network name -> per-network attrs (e.g. + ipv4_address, aliases) for compose's mapping form of the + networks: key -- needed to assign a static IP on a + macvlan/custom network. ''; };