selfprivacy-nixos-config/configuration.nix

129 lines
3.3 KiB
Nix
Raw Normal View History

2023-11-18 04:28:04 +00:00
{ config, pkgs, lib, system, ... }:
2021-11-15 10:02:05 +00:00
{
imports = [
./variables-module.nix
./files.nix
./volumes.nix
2021-11-15 10:02:05 +00:00
./users.nix
./vpn/ocserv.nix
./social/pleroma.nix
./letsencrypt/acme.nix
./letsencrypt/resolve.nix
./backup/restic.nix
./passmgr/bitwarden.nix
./webserver/nginx.nix
./webserver/memcached.nix
./resources/limits.nix
./videomeet/jitsi.nix
./git/gitea.nix
];
services.redis.servers.sp-api = {
enable = true;
save = [
[
30
1
]
[
10
10
]
];
port = 0;
settings = {
notify-keyspace-events = "KEA";
};
};
services.do-agent.enable = if config.selfprivacy.server.provider == "DIGITALOCEAN" then true else false;
2021-11-15 10:02:05 +00:00
boot.cleanTmpDir = true;
networking = {
hostName = config.selfprivacy.hostname;
usePredictableInterfaceNames = false;
2021-11-15 10:02:05 +00:00
firewall = {
2022-02-15 12:09:45 +00:00
allowedTCPPorts = lib.mkForce [ 22 25 80 143 443 465 587 993 4443 8443 ];
allowedUDPPorts = lib.mkForce [ 8443 10000 ];
extraCommands = ''
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface vpn00 -j ACCEPT
'';
2021-11-15 10:02:05 +00:00
};
nameservers = [ "1.1.1.1" "1.0.0.1" ];
};
time.timeZone = config.selfprivacy.timezone;
2021-11-15 10:02:05 +00:00
i18n.defaultLocale = "en_GB.UTF-8";
users.users.root.openssh.authorizedKeys.keys = config.selfprivacy.ssh.rootKeys;
2021-11-15 10:02:05 +00:00
services.openssh = {
enable = config.selfprivacy.ssh.enable;
passwordAuthentication = config.selfprivacy.ssh.passwordAuthentication;
2021-11-15 10:02:05 +00:00
permitRootLogin = "yes";
openFirewall = false;
};
programs.ssh = {
pubkeyAcceptedKeyTypes = [ "ssh-ed25519" "ssh-rsa" ];
hostKeyAlgorithms = [ "ssh-ed25519" "ssh-rsa" ];
2021-11-15 10:02:05 +00:00
};
environment.systemPackages = with pkgs; [
git
jq
2021-11-15 10:02:05 +00:00
];
2023-11-18 01:53:08 +00:00
# consider environment.defaultPackages = lib.mkForce [];
2021-11-15 10:02:05 +00:00
environment.variables = {
DOMAIN = config.selfprivacy.domain;
2021-11-15 10:02:05 +00:00
};
system.autoUpgrade = {
enable = config.selfprivacy.autoUpgrade.enable;
allowReboot = config.selfprivacy.autoUpgrade.allowReboot;
channel = "https://channel.selfprivacy.org/nixos-selfpricacy";
};
system.stateVersion = config.selfprivacy.stateVersion;
2021-11-15 10:02:05 +00:00
nix = {
2023-11-18 01:53:08 +00:00
# TODO uncomment when NixOS version is at least 23.05
# nix.channel.enable = false;
# daemonCPUSchedPolicy = "idle";
# daemonIOSchedClass = "idle";
# daemonIOSchedPriority = 7;
# this is superseded by nix.settings.auto-optimise-store.
# optimise.automatic = true;
2021-11-15 10:02:05 +00:00
gc = {
automatic = true;
options = "--delete-older-than 7d";
};
};
2023-11-18 01:53:08 +00:00
nix.settings = {
sandbox = true;
experimental-features = [ "nix-command" "flakes" "repl-flake" ];
# auto-optimise-store = true;
# evaluation restrictions:
# restrict-eval = true;
# allowed-uris = [];
allow-dirty = false;
};
nix.package =
if lib.versionAtLeast pkgs.nix.version "2.15.2"
then pkgs.nix.out
else pkgs.nixUnstable.out;
2023-11-18 04:28:04 +00:00
nixpkgs.hostPlatform = system;
services.journald.extraConfig = "SystemMaxUse=500M";
2021-11-15 10:02:05 +00:00
boot.kernel.sysctl = {
2023-11-18 01:53:08 +00:00
"net.ipv4.ip_forward" = 1; # TODO why is it here by default?
2021-11-15 10:02:05 +00:00
};
swapDevices = [
{
device = "/swapfile";
priority = 0;
size = 2048;
}
];
security = {
sudo = {
enable = true;
};
};
}