From c04849f9f150802f3d0957da531e1f52b871c961 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Sat, 27 Jan 2024 05:43:34 -0500 Subject: [PATCH] container proof of concept --- systems/hetzner/ex101.nix | 1 + systems/hetzner/nixos-container.nix | 30 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 systems/hetzner/nixos-container.nix diff --git a/systems/hetzner/ex101.nix b/systems/hetzner/ex101.nix index 7d573ff..1a831bf 100644 --- a/systems/hetzner/ex101.nix +++ b/systems/hetzner/ex101.nix @@ -2,6 +2,7 @@ imports = [ (modulesPath + "/installer/scan/not-detected.nix") flake.inputs.disko.nixosModules.disko + ./nixos-container.nix ]; system.stateVersion = "22.11"; services.openssh.enable = true; diff --git a/systems/hetzner/nixos-container.nix b/systems/hetzner/nixos-container.nix new file mode 100644 index 0000000..fdb8f5a --- /dev/null +++ b/systems/hetzner/nixos-container.nix @@ -0,0 +1,30 @@ +{ lib, config, ... }: + +let + localAddress = (builtins.head (builtins.head (lib.attrValues config.networking.interfaces)).ipv4.addresses).address; +in +{ + networking.nat = { + enable = true; + internalInterfaces = [ "ve-+" ]; + externalInterface = "eth0"; + }; + + # Proof-of-concept hello world container + # + # $ sudo nixos-container root-login hello + # > hello + containers.hello = { + inherit localAddress; + autoStart = true; + hostAddress = "192.168.100.10"; + config = { config, pkgs, ... }: { + environment.systemPackages = with pkgs; [ + hello + ]; + #services.resolved.enable = true; + #networking.useHostResolvConf = lib.mkForce false; + system.stateVersion = "23.11"; + }; + }; +}