simplify enable opts, and fix security.nix
This commit is contained in:
parent
06b42a1aa6
commit
5d5cd7979c
10 changed files with 34 additions and 40 deletions
|
@ -6,7 +6,9 @@ let
|
||||||
inherit (lib.my) mapModulesRec';
|
inherit (lib.my) mapModulesRec';
|
||||||
in {
|
in {
|
||||||
imports =
|
imports =
|
||||||
[ inputs.home-manager.nixosModules.home-manager ]
|
[
|
||||||
|
inputs.home-manager.nixosModules.home-manager
|
||||||
|
]
|
||||||
++ (mapModulesRec' (toString ./modules) import);
|
++ (mapModulesRec' (toString ./modules) import);
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
|
@ -27,11 +29,10 @@ in {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
unrar unzip
|
unrar unzip
|
||||||
curl wget
|
curl wget
|
||||||
# nix does not work without git.
|
# nixos-rebuild w/ flakes does not work without git
|
||||||
# do not remove this.
|
# do not remove this
|
||||||
# nix is awesome
|
# nix is awesome
|
||||||
git
|
git
|
||||||
neofetch
|
|
||||||
];
|
];
|
||||||
|
|
||||||
time.timeZone = mkDefault "America/Los_Angeles";
|
time.timeZone = mkDefault "America/Los_Angeles";
|
||||||
|
|
|
@ -14,24 +14,38 @@ in {
|
||||||
tmp.cleanOnBoot = lib.mkDefault (!config.boot.tmp.useTmpfs);
|
tmp.cleanOnBoot = lib.mkDefault (!config.boot.tmp.useTmpfs);
|
||||||
|
|
||||||
kernel.sysctl = {
|
kernel.sysctl = {
|
||||||
|
# magic sysrq key, allows low-level commands through keyboard input
|
||||||
"kernel.sysrq" = 0;
|
"kernel.sysrq" = 0;
|
||||||
|
|
||||||
"net.ipv4.conf.all.accept_source_code" = 0;
|
## TCP hardening
|
||||||
"net.ipv6.conf.all.accept_source_code" = 0;
|
# prevent bogus ICMP errors from filling up logs
|
||||||
"net.ipv4.conf.default.send_redirects" = 0;
|
"net.ipv4.icmp_ignore_bogus_error_responses" = 1;
|
||||||
|
# do not accept IP source packets (we are 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.all.send_redirects" = 0;
|
||||||
"net.ipv4.conf.default.accept_redirects" = 0;
|
"net.ipv4.conf.default.send_redirects" = 0;
|
||||||
|
# refuse ICMP redirects (MITM mitigations)
|
||||||
"net.ipv4.conf.all.accept_redirects" = 0;
|
"net.ipv4.conf.all.accept_redirects" = 0;
|
||||||
"net.ipv6.conf.default.accept_redirects" = 0;
|
"net.ipv4.conf.default.accept_redirects" = 0;
|
||||||
"net.ipv6.conf.all.accept_redirects" = 0;
|
|
||||||
"net.ipv4.conf.default.secure_redirects" = 0;
|
|
||||||
"net.ipv4.conf.all.secure_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;
|
"net.ipv4.tcp_syncookies" = 1;
|
||||||
|
# incomplete protection against TIME-WAIT assassination
|
||||||
"net.ipv4.tcp_rfc1337" = 1;
|
"net.ipv4.tcp_rfc1337" = 1;
|
||||||
|
|
||||||
|
## TCP optimization
|
||||||
|
# TCP fastopen
|
||||||
"net.ipv4.tcp_fastopen" = 3;
|
"net.ipv4.tcp_fastopen" = 3;
|
||||||
|
# bufferbloat mitigations + improvement in throughput and latency
|
||||||
"net.ipv4.tcp_conjestion_control" = "bbr";
|
"net.ipv4.tcp_conjestion_control" = "bbr";
|
||||||
"net.core.default_qdisc" = "cake";
|
"net.core.default_qdisc" = "cake";
|
||||||
};
|
};
|
||||||
|
kernelModules = [ "tcp_bbr" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
security = {
|
security = {
|
||||||
|
|
|
@ -11,10 +11,7 @@ let
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.modules.services.forgejo = {
|
options.modules.services.forgejo = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "enable forgejo, a lightweight git server";
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
domain = mkOption {
|
domain = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "git.reidlab.online";
|
default = "git.reidlab.online";
|
||||||
|
|
|
@ -5,10 +5,7 @@ let
|
||||||
cfg = config.modules.services.metrics;
|
cfg = config.modules.services.metrics;
|
||||||
in {
|
in {
|
||||||
options.modules.services.metrics = {
|
options.modules.services.metrics = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "enable grafana with loki, prometheus, and promtail";
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
domain = mkOption {
|
domain = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "grafana.reidlab.online";
|
default = "grafana.reidlab.online";
|
||||||
|
|
|
@ -5,10 +5,7 @@ let
|
||||||
cfg = config.modules.services.mosh;
|
cfg = config.modules.services.mosh;
|
||||||
in {
|
in {
|
||||||
options.modules.services.mosh = {
|
options.modules.services.mosh = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "enable mosh, the mobile SSH shell";
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
|
@ -5,10 +5,7 @@ let
|
||||||
cfg = config.modules.services.nginx-config;
|
cfg = config.modules.services.nginx-config;
|
||||||
in {
|
in {
|
||||||
options.modules.services.nginx-config = {
|
options.modules.services.nginx-config = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "enable nginx, a high performance web server along with default configurations";
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
|
|
@ -5,10 +5,7 @@ let
|
||||||
cfg = config.modules.services.postgres;
|
cfg = config.modules.services.postgres;
|
||||||
in {
|
in {
|
||||||
options.modules.services.postgres = {
|
options.modules.services.postgres = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "enable postgres, the database industry standard";
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
|
@ -5,10 +5,7 @@ let
|
||||||
cfg = config.modules.services.redis;
|
cfg = config.modules.services.redis;
|
||||||
in {
|
in {
|
||||||
options.modules.services.redis = {
|
options.modules.services.redis = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "enable redis, a speedy cache database";
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
|
@ -5,11 +5,7 @@ let
|
||||||
cfg = config.modules.services.ssh;
|
cfg = config.modules.services.ssh;
|
||||||
in {
|
in {
|
||||||
options.modules.services.ssh = {
|
options.modules.services.ssh = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "enable openssh, a server for remote shell access";
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Provide system SSH support though OpenSSH.";
|
|
||||||
};
|
|
||||||
|
|
||||||
requirePassword = mkOption {
|
requirePassword = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
|
|
@ -21,3 +21,4 @@ before committing, please run `nix flake check` and make sure everything is ok
|
||||||
- remove the lua static stuff from nginx + the cf ip
|
- remove the lua static stuff from nginx + the cf ip
|
||||||
- per-host architecture selection, atm it is hardcoded to `aarch64`
|
- per-host architecture selection, atm it is hardcoded to `aarch64`
|
||||||
- some weird perl error abt locales when building??? it only happened after the big lib update. help me
|
- some weird perl error abt locales when building??? it only happened after the big lib update. help me
|
||||||
|
- leverage nixos-hardware
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue