Skip to content

Instantly share code, notes, and snippets.

@kaznak
Last active December 14, 2023 08:01
Show Gist options
  • Save kaznak/734c6a3c56703c8690bab43d59e36016 to your computer and use it in GitHub Desktop.
Save kaznak/734c6a3c56703c8690bab43d59e36016 to your computer and use it in GitHub Desktop.
NixOS configuration for AWS EC2 instance
{ modulesPath, pkgs, lib, ... }: {
imports = [
"${modulesPath}/virtualisation/amazon-image.nix"
];
ec2.hvm = true;
################################################
system.autoUpgrade = {
enable = true;
allowReboot = true;
};
nix.gc = {
automatic = true;
dates = "19:30";
};
################################################
security.sudo.wheelNeedsPassword = false;
environment.systemPackages = with pkgs; [
git vim file screen
docker-compose
];
################################################
# networking.hostName = "aws";
services.fail2ban.enable = true;
services.openssh = lib.mkForce {
enable = true;
permitRootLogin = "no";
passwordAuthentication = false;
forwardX11 = true;
};
virtualisation.docker = {
enable = true;
autoPrune.enable = true;
};
################################################
users.users = import ./users.nix;
}
{ # options of users.users
USER_NAME = {
isNormalUser = true;
extraGroups = [ "wheel" "docker" ];
openssh.authorizedKeys.keys = [
"<SSH_PUBKEY>" ];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment