This commit is contained in:
xunuwu 2024-02-07 19:05:44 +01:00
commit 498f3050d5
Signed by: xun
SSH key fingerprint: SHA256:Uot/1WoAjWAeqLOHA5vYy4phhVydsH7jCPmBjaPZfgI
145 changed files with 2964 additions and 0 deletions

34
system/core/boot.nix Normal file
View file

@ -0,0 +1,34 @@
{
pkgs,
config,
...
}: {
boot = {
initrd = {
systemd.enable = true;
supportedFilesystems = ["ext4"];
};
## use latest kernel
kernelPackages = pkgs.linuxPackages_latest;
consoleLogLevel = 3;
kernelParams = [
"quiet"
"systemd.show_status=auto"
"rd.udev.log_level=3"
];
loader = {
# systemd-boot on UEFI
efi.canTouchEfiVariables = true;
systemd-boot.enable = true;
};
plymouth.enable = true;
};
environment.systemPackages = [
config.boot.kernelPackages.cpupower
];
}

25
system/core/default.nix Normal file
View file

@ -0,0 +1,25 @@
{lib, ...}: {
imports = [
./security.nix
./users.nix
./tools.nix
./ssh.nix
../nix
../programs/zsh.nix
];
documentation.dev.enable = true;
i18n = {
defaultLocale = "en_US.UTF-8";
supportedLocales = [
"en_US.UTF-8/UTF-8"
];
};
services.xserver.layout = "eu";
# don't touch this
system.stateVersion = lib.mkDefault "23.11";
time.timeZone = lib.mkDefault "Europe/Stockholm";
}

59
system/core/security.nix Normal file
View file

@ -0,0 +1,59 @@
# security tweaks borrowed from @hlissner
{
boot.kernel.sysctl = {
# The Magic SysRq key is a key combo that allows users connected to the
# system console of a Linux kernel to perform some low-level commands.
# Disable it, since we don't need it, and is a potential security concern.
"kernel.sysrq" = 0;
## TCP hardening
# Prevent bogus ICMP errors from filling up logs.
"net.ipv4.icmp_ignore_bogus_error_responses" = 1;
# Reverse path filtering causes the kernel to do source validation of
# packets received from all interfaces. This can mitigate IP spoofing.
"net.ipv4.conf.default.rp_filter" = 1;
"net.ipv4.conf.all.rp_filter" = 1;
# Do not accept IP source route packets (we're not a router)
"net.ipv4.conf.all.accept_source_route" = 0;
"net.ipv6.conf.all.accept_source_route" = 0;
# Don't send ICMP redirects (again, we're not a router)
"net.ipv4.conf.all.send_redirects" = 0;
"net.ipv4.conf.default.send_redirects" = 0;
# Refuse ICMP redirects (MITM mitigations)
"net.ipv4.conf.all.accept_redirects" = 0;
"net.ipv4.conf.default.accept_redirects" = 0;
"net.ipv4.conf.all.secure_redirects" = 0;
"net.ipv4.conf.default.secure_redirects" = 0;
"net.ipv6.conf.all.accept_redirects" = 0;
"net.ipv6.conf.default.accept_redirects" = 0;
# Protects against SYN flood attacks
"net.ipv4.tcp_syncookies" = 1;
# Incomplete protection again TIME-WAIT assassination
"net.ipv4.tcp_rfc1337" = 1;
## TCP optimization
# TCP Fast Open is a TCP extension that reduces network latency by packing
# data in the senders initial TCP SYN. Setting 3 = enable TCP Fast Open for
# both incoming and outgoing connections:
"net.ipv4.tcp_fastopen" = 3;
# Bufferbloat mitigations + slight improvement in throughput & latency
"net.ipv4.tcp_congestion_control" = "bbr";
"net.core.default_qdisc" = "cake";
};
boot.kernelModules = ["tcp_bbr"];
# Change me later!
#users.users.root.initialPassword = "nixos";
security = {
# allow wayland lockers to unlock the screen
pam.services.swaylock.text = "auth include login";
# userland niceness
rtkit.enable = true;
# don't ask for password for wheel group
sudo.wheelNeedsPassword = false;
};
}

22
system/core/ssh.nix Normal file
View file

@ -0,0 +1,22 @@
{lib, ...}: {
services.openssh = {
enable = lib.mkDefault true;
settings = {
# Use only public keys
PasswordAuthentication = lib.mkForce false;
KbdInteractiveAuthentication = lib.mkForce false;
# root login is never welcome, except for remote builders
PermitRootLogin = lib.mkForce "prohibit-password";
};
startWhenNeeded = lib.mkDefault true;
openFirewall = lib.mkDefault false;
hostKeys = [
{
path = "/etc/ssh/ssh_host_ed25519_key";
type = "ed25519";
}
];
};
}

5
system/core/tools.nix Normal file
View file

@ -0,0 +1,5 @@
{pkgs, ...}: {
environment.systemPackages = with pkgs; [
htop
];
}

11
system/core/users.nix Normal file
View file

@ -0,0 +1,11 @@
{pkgs, ...}: {
users.users.xun = {
isNormalUser = true;
initialPassword = "nixos";
shell = pkgs.zsh;
extraGroups = [
"video"
"wheel"
];
};
}