Skip to content

Instantly share code, notes, and snippets.

@dvekeman
Last active July 17, 2021 23:06
Show Gist options
  • Save dvekeman/91f245925a2002186f734ebba38e27c3 to your computer and use it in GitHub Desktop.
Save dvekeman/91f245925a2002186f734ebba38e27c3 to your computer and use it in GitHub Desktop.
NixOS container configuration
{config, pkgs, ... }:
{
environment.systemPackages = [
pkgs.openssl
pkgs.emacs
pkgs.haskellPackages.cabal2nix
pkgs.haskellPackages.hakyll
pkgs.nginx
];
}
{ config, pkgs, ...}:
{
imports = [
./amazon-base-config.nix
./base-pkgs.nix
./noip.nix
./container-web1.nix
./container-db1-mysql.nix
];
ec2.hvm = true;
networking.nat.enable = true;
networking.nat.internalInterfaces = ["ve-+"];
networking.nat.externalInterface = "eth0";
}
{ config, pkgs, ... }:
{
containers.db1mysql = {
privateNetwork = true;
hostAddress = "192.168.51.151";
localAddress = "192.168.151.151";
config = { config, pkgs, ... }: {
networking.firewall = {
enable = true;
allowedTCPPorts = [ 3306 ];
};
environment.systemPackages = with pkgs; [
vim
git
htop
emacs
wget
mysql
];
services.mysql = {
enable = true;
port = 3306;
package = pkgs.mysql;
user = "mysql";
dataDir = "/var/db/mysql";
extraOptions = ''
bind-address = 0.0.0.0
'';
};
};
};
}
{ config, pkgs, ... }:
{
containers.web1 = {
privateNetwork = true;
hostAddress = "192.168.1.101";
localAddress = "192.168.101.101";
config = { config, pkgs, ... }: {
networking.firewall = {
enable = true;
allowedTCPPorts = [ 80 443 ];
};
environment.systemPackages = with pkgs; [
vim
git
htop
emacs
wget
];
services.httpd = {
enable = true;
enableSSL = false;
adminAddr = "web1@example.org";
documentRoot = "/webroot";
# we override the php version for all uses of pkgs.php with this,
# nix-env -qa --xml | grep php
# lists available versions of php
extraModules = [
{ name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; }
];
};
};
};
}
{config, pkgs, ... }:
{
systemd.services.noip = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
Type = "forking";
User = "root";
ExecStart = ''/root/.nix-profile/bin/noip2 -d -c /etc/noip/noip'';
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment