Initial commit
This commit is contained in:
@ -1,3 +1,3 @@
|
|||||||
# nix-server
|
# NixOS Server Config
|
||||||
|
|
||||||
Minimal NixOS server with Docker, SSH on port 222, and basic sysadmin tools.
|
Minimal NixOS server with Docker, SSH on port 222, and basic sysadmin tools.
|
||||||
|
|||||||
95
configuration.nix
Normal file
95
configuration.nix
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
# Minimal system packages
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
vim
|
||||||
|
nano
|
||||||
|
git
|
||||||
|
curl
|
||||||
|
htop
|
||||||
|
tmux
|
||||||
|
rsync
|
||||||
|
ncdu
|
||||||
|
iotop
|
||||||
|
nethogs
|
||||||
|
lsof
|
||||||
|
strace
|
||||||
|
jq
|
||||||
|
tree
|
||||||
|
unzip
|
||||||
|
zip
|
||||||
|
pciutils
|
||||||
|
usbutils
|
||||||
|
smartmontools
|
||||||
|
lm_sensors
|
||||||
|
nmap
|
||||||
|
tcpdump
|
||||||
|
nettools
|
||||||
|
bind.dnsutils
|
||||||
|
openssl
|
||||||
|
ethtool
|
||||||
|
sysstat
|
||||||
|
logrotate
|
||||||
|
cron
|
||||||
|
];
|
||||||
|
|
||||||
|
# Nix optimization and garbage collection
|
||||||
|
nix.settings = {
|
||||||
|
auto-optimise-store = true;
|
||||||
|
allowed-users = [ "@users" ];
|
||||||
|
};
|
||||||
|
nix.gc = {
|
||||||
|
automatic = true;
|
||||||
|
dates = "weekly";
|
||||||
|
options = "--delete-older-than 90d";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Docker configuration
|
||||||
|
virtualisation.docker.enable = true;
|
||||||
|
|
||||||
|
# Bootloader configuration
|
||||||
|
boot.loader = {
|
||||||
|
systemd-boot.enable = true;
|
||||||
|
efi.canTouchEfiVariables = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# SSH Server configuration
|
||||||
|
services.openssh = {
|
||||||
|
enable = true;
|
||||||
|
ports = [ 222 ];
|
||||||
|
settings = {
|
||||||
|
PasswordAuthentication = false;
|
||||||
|
PermitRootLogin = "prohibit-password";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# SSHGuard — monitors logs for brute-force attempts and blocks offending IPs
|
||||||
|
services.sshguard.enable = true;
|
||||||
|
|
||||||
|
# Security
|
||||||
|
security.sudo.wheelNeedsPassword = true;
|
||||||
|
|
||||||
|
# User configuration
|
||||||
|
users.users.root = {
|
||||||
|
openssh.authorizedKeys.keys = [
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMniNzAzuI527bfk/EipqFILFayUCwYXDoZ3R7+QgYq6 kawaiipunk@ZeroCool"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Firewall configuration — only expose HTTP, HTTPS, and SSH
|
||||||
|
networking.firewall = {
|
||||||
|
enable = true;
|
||||||
|
allowedTCPPorts = [ 80 443 222 ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# VM configuration (used when building with nixos-rebuild build-vm)
|
||||||
|
virtualisation.vmVariant = {
|
||||||
|
virtualisation = {
|
||||||
|
memorySize = 2048;
|
||||||
|
cores = 2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
system.stateVersion = "25.05";
|
||||||
|
}
|
||||||
24
flake.nix
Normal file
24
flake.nix
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
description = "Minimal NixOS Docker Swarm server";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, ... }@inputs: {
|
||||||
|
nixosConfigurations.server = nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
specialArgs = { inherit inputs; };
|
||||||
|
modules = [
|
||||||
|
./configuration.nix
|
||||||
|
{
|
||||||
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
nix.registry.nixpkgs.flake = nixpkgs;
|
||||||
|
nix.nixPath = [ "nixpkgs=flake:nixpkgs" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user