nixos-config/aplysia.nix

206 lines
4.6 KiB
Nix
Raw Normal View History

2017-08-05 07:17:30 +00:00
{ config, pkgs, ... }:
let
trnsmssnIface = "wg-trnsmssn";
in
2017-08-05 07:17:30 +00:00
{
imports =
[
./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:13:59 +00:00
users.extraUsers.gebner.extraGroups = [
"transmission"
"nilotica"
];
users.extraUsers.nilotica = {
extraGroups = [
"nilotica"
];
};
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";
};
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
'';
shares = {
export = {
"guest ok" = "no";
"read only" = "no";
2017-08-05 08:27:17 +00:00
path = "/mnt/aplysia";
};
};
};
containers.trnsmssn =
let
homeDir = "/mnt/aplysia/torrents";
in rec {
config = {
services.transmission = {
2019-10-15 19:56:40 +00:00
enable = true;
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
rpc-whitelist-enabled = false;
};
};
networking.firewall = {
enable = true;
2019-10-15 22:20:57 +00:00
interfaces.${trnsmssnIface}.allowedTCPPorts = [
config.services.transmission.settings.peer-port
];
2019-10-15 22:20:57 +00:00
interfaces.eth0.allowedTCPPorts = [
9091
];
};
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; }
];
ipv6.routes = [ { address = "::"; prefixLength = 0; } ];
};
environment.systemPackages = with pkgs; [ wireguard ];
};
privateNetwork = true;
interfaces = [ trnsmssnIface ];
2019-10-15 22:20:57 +00:00
hostAddress = "192.168.100.10";
localAddress = "192.168.100.11";
autoStart = true;
bindMounts.${homeDir} = {
hostPath = homeDir;
isReadOnly = false;
2017-08-05 08:43:25 +00:00
};
};
networking.wireguard = {
enable = true;
interfaces.${trnsmssnIface} = {
privateKeyFile = "/etc/wgkeys/mullvad";
peers = [
{
allowedIPs = ["0.0.0.0/0" "::/0"];
publicKey = "pKcMMeC4jMUxSU5pH1orvp4//GrY8is+y9JRfVP3+BY=";
endpoint = "se6-wireguard.mullvad.net:51820";
}
];
allowedIPsAsRoutes = false;
};
};
systemd.services."container@trnsmssn" = {
requires = [ "wireguard-${trnsmssnIface}.service" ];
after = [ "wireguard-${trnsmssnIface}.service" ];
};
users.users = [
{ name = "transmission";
group = "transmission";
uid = config.ids.uids.transmission;
}
];
users.groups = [
{ name = "transmission";
gid = config.ids.gids.transmission;
}
];
2017-08-05 08:27:17 +00:00
networking.firewall = {
2017-08-05 08:43:25 +00:00
allowedTCPPorts = [
445 139 # samba
];
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}
'';
2017-08-05 07:17:30 +00:00
}