Skip to content

Instantly share code, notes, and snippets.

@zarelit
Created March 5, 2018 20:26
Show Gist options
  • Save zarelit/bcccf1af1094bf200f218d7f2ae5dbde to your computer and use it in GitHub Desktop.
Save zarelit/bcccf1af1094bf200f218d7f2ae5dbde to your computer and use it in GitHub Desktop.
nixos declarative containers in bridge
{ config, pkgs, lib, ... }:
{
# Other host options
## Containers
# Containers are bridged with the physical LAN adapter
networking.bridges.br0.interfaces = ["eth0"];
# Example with gogs (VM name: projects)
containers.projects = {
autoStart = true;
config =
{ config, pkgs, ... }:
{
# Other guest options
services.gogs = {
enable = true;
};
networking.firewall = {
allowedTCPPorts = [ 3000 ]; # GOGS listen by default on port 3000
# kludge to make GOGS working on port 80 without messing with users
# extraCommands = "iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000";
};
};
privateNetwork = true;
hostBridge = "br0";
localAddress = "192.168.1.25/24"; # Containers in bridge mode cannot have networking.useDHCP = true;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment