2017-08-05 07:17:30 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
2019-10-15 19:45:01 +00:00
|
|
|
let
|
|
|
|
trnsmssnIface = "wg-trnsmssn";
|
|
|
|
in
|
2017-08-05 07:17:30 +00:00
|
|
|
{
|
|
|
|
imports =
|
|
|
|
[
|
2021-05-22 16:17:29 +00:00
|
|
|
/etc/nixos/hardware-configuration.nix
|
2017-08-05 07:17:30 +00:00
|
|
|
./common-headless.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
boot.supportedFilesystems = ["zfs"];
|
2017-08-05 08:27:17 +00:00
|
|
|
boot.loader.grub = {
|
|
|
|
enable = true;
|
|
|
|
version = 2;
|
|
|
|
zfsSupport = true;
|
|
|
|
mirroredBoots = [
|
|
|
|
{ devices = [ "/dev/sda" ]; path = "/boota"; }
|
|
|
|
{ devices = [ "/dev/sdb" ]; path = "/bootb"; }
|
|
|
|
{ devices = [ "/dev/sdc" ]; path = "/bootc"; }
|
|
|
|
{ devices = [ "/dev/sdd" ]; path = "/bootd"; }
|
|
|
|
{ devices = [ "/dev/sde" ]; path = "/boote"; }
|
|
|
|
{ devices = [ "/dev/sdf" ]; path = "/bootf"; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
hostName = "aplysia";
|
|
|
|
hostId = "34a820f1";
|
|
|
|
};
|
2017-08-05 07:17:30 +00:00
|
|
|
|
2019-11-03 15:21:04 +00:00
|
|
|
users = {
|
|
|
|
users = {
|
|
|
|
gebner.extraGroups = [
|
|
|
|
"transmission"
|
|
|
|
"nilotica"
|
|
|
|
];
|
2019-11-03 15:13:59 +00:00
|
|
|
|
2019-11-03 15:21:04 +00:00
|
|
|
nilotica = {
|
|
|
|
group = "nilotica";
|
|
|
|
};
|
2019-11-03 15:23:42 +00:00
|
|
|
|
|
|
|
transmission = {
|
|
|
|
group = "transmission";
|
|
|
|
uid = config.ids.uids.transmission;
|
|
|
|
};
|
2019-11-03 15:21:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
groups = {
|
|
|
|
nilotica = {};
|
2019-11-03 15:23:42 +00:00
|
|
|
|
|
|
|
transmission = {
|
|
|
|
gid = config.ids.gids.transmission;
|
|
|
|
};
|
2019-11-03 15:21:04 +00:00
|
|
|
};
|
2019-11-03 15:13:59 +00:00
|
|
|
};
|
2017-08-05 07:18:11 +00:00
|
|
|
|
2017-08-05 07:17:30 +00:00
|
|
|
boot.kernelPackages = pkgs.lib.mkOverride 10 pkgs.linuxPackages;
|
|
|
|
|
|
|
|
system.stateVersion = "17.03";
|
|
|
|
|
2017-08-05 08:27:17 +00:00
|
|
|
fileSystems."/mnt/aplysia" = pkgs.lib.mkOverride 10 {
|
|
|
|
device = "aplysia/export";
|
|
|
|
fsType = "zfs";
|
|
|
|
};
|
|
|
|
|
2018-11-12 18:04:38 +00:00
|
|
|
fileSystems."/boota".options = [ "nofail" ];
|
|
|
|
fileSystems."/bootb".options = [ "nofail" ];
|
|
|
|
fileSystems."/bootc".options = [ "nofail" ];
|
|
|
|
fileSystems."/bootd".options = [ "nofail" ];
|
|
|
|
fileSystems."/boote".options = [ "nofail" ];
|
|
|
|
fileSystems."/bootf".options = [ "nofail" ];
|
|
|
|
|
2017-08-05 08:27:17 +00:00
|
|
|
services.samba = {
|
|
|
|
enable = true;
|
|
|
|
extraConfig = ''
|
|
|
|
passdb backend = tdbsam
|
|
|
|
unix password sync = no
|
2020-10-03 10:32:43 +00:00
|
|
|
min protocol = NT1
|
2017-08-05 08:27:17 +00:00
|
|
|
'';
|
|
|
|
shares = {
|
|
|
|
export = {
|
|
|
|
"guest ok" = "no";
|
2017-08-05 15:48:15 +00:00
|
|
|
"read only" = "no";
|
2017-08-05 08:27:17 +00:00
|
|
|
path = "/mnt/aplysia";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-10-15 19:45:01 +00:00
|
|
|
containers.trnsmssn =
|
|
|
|
let
|
|
|
|
homeDir = "/mnt/aplysia/torrents";
|
|
|
|
in rec {
|
|
|
|
config = {
|
|
|
|
services.transmission = {
|
2019-10-15 19:56:40 +00:00
|
|
|
enable = true;
|
2019-10-15 19:45:01 +00:00
|
|
|
settings = {
|
|
|
|
download-dir = homeDir;
|
|
|
|
incomplete-dir = homeDir;
|
|
|
|
|
|
|
|
speed-limit-down = 5000;
|
|
|
|
speed-limit-down-enabled = true;
|
|
|
|
speed-limit-up = 800;
|
|
|
|
speed-limit-up-enabled = true;
|
|
|
|
|
2019-10-15 19:56:40 +00:00
|
|
|
peer-port = 7455;
|
2019-10-15 22:20:57 +00:00
|
|
|
|
2020-10-03 10:47:03 +00:00
|
|
|
rpc-bind-address = localAddress;
|
2019-10-15 22:20:57 +00:00
|
|
|
rpc-whitelist-enabled = false;
|
2019-10-15 19:45:01 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall = {
|
|
|
|
enable = true;
|
2019-10-15 22:20:57 +00:00
|
|
|
interfaces.${trnsmssnIface}.allowedTCPPorts = [
|
2019-10-15 19:45:01 +00:00
|
|
|
config.services.transmission.settings.peer-port
|
|
|
|
];
|
2019-10-15 22:20:57 +00:00
|
|
|
interfaces.eth0.allowedTCPPorts = [
|
|
|
|
9091
|
|
|
|
];
|
2019-10-15 19:45:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
networking.nameservers = [ "193.138.218.74" ];
|
|
|
|
|
|
|
|
networking.interfaces.${trnsmssnIface} = {
|
|
|
|
ipv4.addresses = [ { address = "10.64.157.93"; prefixLength = 32; } ];
|
|
|
|
ipv6.addresses = [ { address = "fc00:bbbb:bbbb:bb01::1:9d5c"; prefixLength = 128; } ];
|
2019-10-15 22:20:57 +00:00
|
|
|
ipv4.routes = [
|
|
|
|
{ address = "0.0.0.0"; prefixLength = 1; }
|
|
|
|
{ address = "128.0.0.0"; prefixLength = 1; }
|
|
|
|
];
|
2019-10-15 19:45:01 +00:00
|
|
|
ipv6.routes = [ { address = "::"; prefixLength = 0; } ];
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [ wireguard ];
|
|
|
|
};
|
|
|
|
|
|
|
|
privateNetwork = true;
|
|
|
|
interfaces = [ trnsmssnIface ];
|
2017-08-05 15:48:15 +00:00
|
|
|
|
2019-10-15 22:20:57 +00:00
|
|
|
hostAddress = "192.168.100.10";
|
|
|
|
localAddress = "192.168.100.11";
|
|
|
|
|
2019-10-15 19:45:01 +00:00
|
|
|
autoStart = true;
|
2018-11-12 18:04:38 +00:00
|
|
|
|
2019-10-15 19:45:01 +00:00
|
|
|
bindMounts.${homeDir} = {
|
|
|
|
hostPath = homeDir;
|
|
|
|
isReadOnly = false;
|
2017-08-05 08:43:25 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-10-15 19:45:01 +00:00
|
|
|
networking.wireguard = {
|
|
|
|
enable = true;
|
|
|
|
interfaces.${trnsmssnIface} = {
|
|
|
|
privateKeyFile = "/etc/wgkeys/mullvad";
|
|
|
|
peers = [
|
|
|
|
{
|
|
|
|
allowedIPs = ["0.0.0.0/0" "::/0"];
|
2021-03-12 12:33:40 +00:00
|
|
|
publicKey = "5y66WShsFXqM5K7/4CPEGCWfk7PQyNhVBT2ILjbGm2I=";
|
|
|
|
endpoint = "se15-wireguard.mullvad.net:51820";
|
2019-10-15 19:45:01 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
allowedIPsAsRoutes = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
systemd.services."container@trnsmssn" = {
|
|
|
|
requires = [ "wireguard-${trnsmssnIface}.service" ];
|
|
|
|
after = [ "wireguard-${trnsmssnIface}.service" ];
|
|
|
|
};
|
|
|
|
|
2017-08-05 08:27:17 +00:00
|
|
|
networking.firewall = {
|
2017-08-05 08:43:25 +00:00
|
|
|
allowedTCPPorts = [
|
|
|
|
445 139 # samba
|
2020-01-02 22:45:29 +00:00
|
|
|
config.services.rsyncd.port
|
2017-08-05 08:43:25 +00:00
|
|
|
];
|
|
|
|
allowedUDPPorts = [
|
|
|
|
137 138 # samba
|
|
|
|
];
|
2017-08-05 08:27:17 +00:00
|
|
|
};
|
|
|
|
|
2019-10-15 22:20:57 +00:00
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedTlsSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
|
|
|
|
virtualHosts."transmission-proxy" = {
|
|
|
|
serverName = "localhost";
|
|
|
|
listen = [
|
|
|
|
{ addr = "localhost"; port = 9091; }
|
|
|
|
];
|
|
|
|
locations."/transmission/" = {
|
|
|
|
proxyPass = "http://192.168.100.11:9091";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-08-05 08:43:25 +00:00
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
transmission
|
|
|
|
samba
|
|
|
|
];
|
|
|
|
|
2017-08-05 15:46:35 +00:00
|
|
|
# hdd spindown
|
|
|
|
powerManagement.powerUpCommands = ''
|
|
|
|
${pkgs.hdparm}/bin/hdparm -B127 -S100 /dev/sd{a,b,c,d,e,f}
|
|
|
|
'';
|
|
|
|
|
2020-01-02 22:45:29 +00:00
|
|
|
services.rsyncd = {
|
|
|
|
enable = true;
|
|
|
|
modules = {
|
|
|
|
lr_mobile = {
|
|
|
|
path = "/mnt/aplysia/fotos/lr_mobile";
|
|
|
|
"read only" = "yes";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-12-01 11:29:57 +00:00
|
|
|
systemd.services.backup-fotos = rec {
|
|
|
|
wants = [ "network.target" "mnt-aplysia.mount" ];
|
|
|
|
after = wants;
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = "gebner";
|
|
|
|
Group = "users";
|
|
|
|
Type = "oneshot";
|
|
|
|
};
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
${pkgs.rclone}/bin/rclone sync -v --update --use-server-modtime \
|
|
|
|
/mnt/aplysia/fotos/lightroom/ \
|
|
|
|
glacier:gebner-fotos-raw-backup/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
systemd.timers.backup-fotos = {
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "Mon,Fri 03:00";
|
|
|
|
Persistent = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-08-05 07:17:30 +00:00
|
|
|
}
|