# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
options = {
machine_name = pkgs.lib.mkOption { type = pkgs.lib.types.str; };
wireguard_ip_and_mask = pkgs.lib.mkOption { type = pkgs.lib.types.str; };
};
config = {
nix = { package = pkgs.nixFlakes; extraOptions = ''experimental-features = nix-command flakes''; };
nixpkgs.config.allowUnfree = true;
boot.loader.systemd-boot.enable = true;
# Set your time zone.
time.timeZone = "America/Chicago";
users.users.bender = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
};
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
networking.useDHCP = false;
networking.interfaces.ens18.useDHCP = true;
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
services.journald.extraConfig = ''
SystemMaxUse = 1G
'';
age.secrets."${config.machine_name}/wireguard/private.key".file = "../../secrets/${config.machine_name}/wireguard/private.key";
networking.wireguard.interfaces = if config.machine_name != "wireguard" then {
wg0 = {
ips = ["${config.wireguard_ip_and_mask}"];
listenPort = 51820;
privateKeyFile = config.age.secrets."${config.machine_name}/wireguard/private.key".path;
peers = [
{
publicKey = "OdVMF/vEnyFYAOYU8Rfl+0ubW14TVfZUU5HGUV8sGzY=";
allowedIPs = ["10.100.0.0/16"];
endpoint = "internal.arvinderd.com:51820";
persistentKeepalive = 25;
}
];
};
} else {};
networking.nameservers = if config.machine_name != "wireguard" then ["10.100.0.1" "1.1.1.1" "8.8.8.8"] else [];
networking.firewall.allowedTCPPorts = [
22 #ssh
];
};
}