nix/nixos/containers/default.nix

75 lines
1.8 KiB
Nix
Raw Normal View History

2024-04-08 11:23:23 +09:00
{ ip, stateVersion, hostname, ... }: {
2024-03-21 20:27:53 +09:00
imports = [
2024-03-21 18:51:41 +09:00
./${hostname}
2024-04-07 08:42:00 +09:00
# Modules
2024-03-21 18:51:41 +09:00
../common/modules/nixos.nix
2024-04-07 08:42:00 +09:00
../common/modules/networking.nix
2024-03-30 15:27:21 +09:00
# Services
../common/services/promtail.nix
../common/services/telegraf.nix
../common/services/openssh.nix
2024-04-07 21:05:15 +09:00
../common/services/gnupg-agent.nix
2024-03-21 18:51:41 +09:00
];
2024-03-30 15:27:21 +09:00
2024-04-07 08:42:00 +09:00
networking.interfaces.eth0.ipv4.addresses = [{
address = "192.168.2.${ip}";
prefixLength = 24;
}];
2024-04-29 12:32:15 +09:00
programs.fish.enable = true;
time.timeZone = "Asia/Tokyo";
2024-04-07 08:42:00 +09:00
# We can access the internet through this interface.
networking.defaultGateway = {
address = "192.168.2.1";
interface = "eth0";
};
2024-03-30 15:27:21 +09:00
boot.isContainer = true;
system.stateVersion = stateVersion;
2024-04-05 22:51:54 +09:00
networking.hostName = "${hostname}";
2024-03-30 15:27:21 +09:00
2024-03-25 11:53:39 +09:00
# Set up the secrets file:
2024-04-07 08:42:00 +09:00
sops.secrets."tailscale_key" = {
2024-03-25 12:41:07 +09:00
owner = "root";
sopsFile = ../../secrets/containers/${hostname}.yaml;
restartUnits = [
"tailscaled.service"
"tailscaled-autoconnect.service"
];
};
2024-03-26 09:00:46 +09:00
2024-04-05 22:51:54 +09:00
services.tailscale = {
enable = true;
2024-05-08 19:21:23 +09:00
authKeyFile = "/run/secrets/tailscale_key";
2024-04-07 08:42:00 +09:00
interfaceName = "tailscale0";
extraUpFlags = [
"--login-server=https://headscale.sysctl.io"
"--accept-dns"
"--accept-routes"
];
2024-04-05 22:51:54 +09:00
};
2024-05-08 19:21:23 +09:00
2024-04-07 08:42:00 +09:00
networking.firewall.interfaces.tailscale0.allowedTCPPorts = [ 22 ];
networking.firewall.checkReversePath = "loose";
networking.extraHosts = ''
100.64.0.14 influx.sysctl.io
100.64.0.14 loki.sysctl.io
2024-06-27 17:28:29 +09:00
'';
2024-04-07 21:05:15 +09:00
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
2024-03-21 18:51:41 +09:00
}