nixos-config/home-server.nix

144 lines
3.9 KiB
Nix
Raw Normal View History

2021-10-23 03:06:06 +02:00
{ config, lib, pkgs, ... }:
2020-09-27 14:27:25 +02:00
2021-10-23 03:06:06 +02:00
let
# mkdir /etc/secrets/initrd -p
# chmod 700 -R /etc/secrets/
# ssh-keygen -t ed25519 -N "" -f /etc/secrets/initrd/ssh_host_ed25519_key
hostKeys = [{
path = "/etc/secrets/initrd/ssh_host_ed25519_key";
type = "ed25519";
}];
in with builtins; {
2020-09-27 14:27:25 +02:00
imports = [
./hardware/base.nix
./hardware/gpu-intel.nix
./desktop/x11.nix
./system/server.nix
./modules/emailNotify.nix
./services/mail.nix
./services/restic/home-server.nix
./services/samba/home-server.nix
2021-12-11 19:42:30 +01:00
# ./services/kodi.nix
2020-10-06 17:41:56 +02:00
./services/jellyfin.nix
2021-02-15 21:06:51 +01:00
./services/etebase.nix
./services/mosquitto.nix
2020-10-03 16:32:06 +02:00
./services/home-assistant.nix
2020-12-02 10:33:12 +01:00
./services/owntracks.nix
2022-08-06 16:07:29 +02:00
./services/immich.nix
2021-12-11 19:40:53 +01:00
./services/miniflux.nix
2021-12-22 13:03:14 +01:00
./services/paperless.nix
2021-12-22 17:36:29 +01:00
./services/nextcloud.nix
2022-05-29 17:26:10 +02:00
./services/calibre-web.nix
2020-09-27 14:27:25 +02:00
];
age.secrets.cloudflare.file = ./secrets/cloudflare.age;
age.secrets.hostKey.file = ./secrets/home-server/hostKey.age;
2020-09-27 14:27:25 +02:00
nixpkgs.config.allowUnfree = true;
2022-05-11 19:55:45 +02:00
# improve memory performance
zramSwap.enable = true;
zramSwap.algorithm = "zstd";
2022-05-14 18:10:48 +02:00
zramSwap.memoryPercent = 150;
2022-05-11 19:55:45 +02:00
2020-10-03 16:23:36 +02:00
networking.domain = "home.felschr.com";
2020-10-06 17:41:56 +02:00
networking.firewall.allowedTCPPorts = [ 80 443 ];
2021-10-23 03:20:38 +02:00
networking.firewall.allowedUDPPorts = [ 80 443 ];
2020-10-03 16:23:36 +02:00
2022-01-01 02:06:35 +01:00
security.acme.acceptTerms = true;
security.acme.defaults.email = "dev@felschr.com";
2020-10-03 16:23:36 +02:00
services.ddclient = {
2020-10-03 16:23:36 +02:00
enable = true;
package = pkgs.ddclient.overrideAttrs (old: rec {
version = "develop-2022-06-01";
src = pkgs.fetchFromGitHub {
owner = "ddclient";
repo = "ddclient";
rev = "5382a982cbf4ad8e0c7b7ff682d21554a8785285";
sha256 = "sha256-LYQ65f1rLa1P/YNhrW7lbyhmViPO7odj7FcDGTS4bOo=";
};
preConfigure = ''
touch Makefile.PL
'';
installPhase = "";
postInstall = old.postInstall or "" + ''
mv $out/bin/ddclient $out/bin/.ddclient
makeWrapper $out/bin/.ddclient $out/bin/ddclient \
--prefix PERL5LIB : $PERL5LIB \
--argv0 ddclient
'';
nativeBuildInputs = with pkgs;
old.nativeBuildInputs or [ ] ++ [ autoreconfHook makeWrapper ];
});
protocol = "cloudflare";
ssl = true;
use = "disabled";
zone = "felschr.com";
username = "felschr@pm.me";
passwordFile = config.age.secrets.cloudflare.path;
domains = [
"home.felschr.com"
2021-12-22 17:36:29 +01:00
"cloud.felschr.com"
2022-02-07 23:52:38 +01:00
"office.felschr.com"
"media.felschr.com"
2022-08-06 16:07:29 +02:00
"photos.felschr.com"
2022-05-29 17:26:10 +02:00
"books.felschr.com"
2021-12-11 19:40:53 +01:00
"news.felschr.com"
2021-10-23 03:20:38 +02:00
"mqtt.felschr.com"
"owntracks.felschr.com"
2021-02-15 21:06:51 +01:00
"etebase.felschr.com"
2021-12-22 13:03:14 +01:00
"paperless.felschr.com"
];
extraConfig = with pkgs; ''
usev6=cmdv6, cmdv6=${
pkgs.writeScript "get-ipv6" ''
${iproute2}/bin/ip --brief addr show enp2s0 mngtmpaddr \
| ${gawk}/bin/awk '{print $(NF)}' \
| sed 's/\/.*//'
''
}
usev4=disabled
'';
2020-10-03 16:23:36 +02:00
};
2020-10-03 16:32:06 +02:00
services.nginx = {
enable = true;
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedProxySettings = true;
};
2020-09-27 14:27:25 +02:00
programs.zsh.enable = true;
services.openssh = {
enable = true;
kbdInteractiveAuthentication = false;
passwordAuthentication = false;
permitRootLogin = "no";
2021-10-23 03:06:06 +02:00
inherit hostKeys;
};
# ssh root@hostname "echo "$(read -s pass; echo \'"$pass"\')" > /crypt-ramfs/passphrase"
boot.initrd.availableKernelModules = [ "igb" ];
2021-10-23 03:06:06 +02:00
boot.initrd.network = {
enable = true;
2021-10-23 03:06:06 +02:00
ssh = {
enable = true;
hostKeys = map (f: f.path) hostKeys;
2021-10-23 03:06:06 +02:00
authorizedKeys = config.users.users.felschr.openssh.authorizedKeys.keys;
};
};
2020-09-27 14:27:25 +02:00
systemd.emailNotify.enable = true;
systemd.emailNotify.mailTo = "admin@felschr.com";
systemd.emailNotify.mailFrom =
"${config.networking.hostName} <felschr@web.de>";
2020-09-27 14:27:25 +02:00
# only change this when specified in release notes
2022-08-12 12:30:01 +02:00
system.stateVersion = "22.05";
2020-09-27 14:27:25 +02:00
}