2020-06-20 17:54:21 +08:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2021-08-07 12:24:00 +08:00
|
|
|
netifWan = "enp4s0";
|
2024-05-06 10:32:10 +08:00
|
|
|
netifWanBackup = "enp11s0";
|
2021-08-07 12:24:00 +08:00
|
|
|
netifLan = "enp5s0f1";
|
2021-08-09 13:32:18 +08:00
|
|
|
netifWifi = "wlp6s0";
|
2020-06-20 17:54:21 +08:00
|
|
|
netifSit = "henet0";
|
2024-10-08 16:09:56 +08:00
|
|
|
netifUSA = "trump0";
|
2024-08-29 18:53:33 +08:00
|
|
|
netifAlt = "alt0";
|
|
|
|
netifAltVlan = "vlan0";
|
2020-06-20 17:54:21 +08:00
|
|
|
hydraWwwOutputs = "/var/www/hydra-outputs";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports =
|
|
|
|
[
|
|
|
|
./hardware-configuration.nix
|
|
|
|
./backup-module.nix
|
2021-08-07 17:46:09 +08:00
|
|
|
./github-backup-module.nix
|
2022-02-07 14:31:37 +08:00
|
|
|
./afws-module.nix
|
2021-08-10 21:28:14 +08:00
|
|
|
./rt.nix
|
2022-06-18 13:58:51 +08:00
|
|
|
(builtins.fetchTarball {
|
2024-10-17 15:04:14 +08:00
|
|
|
url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/29916981e7b3b5782dc5085ad18490113f8ff63b/nixos-mailserver-nixos.tar.gz";
|
|
|
|
sha256 = "sha256:0clvw4622mqzk1aqw1qn6shl9pai097q62mq1ibzscnjayhp278b";
|
2022-06-18 13:58:51 +08:00
|
|
|
})
|
2020-06-20 17:54:21 +08:00
|
|
|
];
|
|
|
|
|
2021-08-07 12:24:00 +08:00
|
|
|
boot.loader.grub.enable = true;
|
|
|
|
boot.loader.grub.copyKernels = true;
|
|
|
|
boot.loader.grub.device = "nodev";
|
|
|
|
boot.loader.grub.efiSupport = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
2023-09-29 11:53:48 +08:00
|
|
|
hardware.cpu.amd.updateMicrocode = true;
|
2024-06-02 12:52:17 +08:00
|
|
|
boot.supportedFilesystems.zfs = true;
|
2021-08-07 12:24:00 +08:00
|
|
|
boot.kernelParams = ["zfs.l2arc_write_max=536870912"];
|
2023-12-12 17:23:05 +08:00
|
|
|
boot.binfmt.emulatedSystems = [ "armv7l-linux" "aarch64-linux" ];
|
2020-07-26 22:21:31 +08:00
|
|
|
|
|
|
|
services.zfs.autoScrub.enable = true;
|
2021-05-28 16:07:09 +08:00
|
|
|
services.zfs.autoScrub.interval = "monthly";
|
2020-07-26 22:29:33 +08:00
|
|
|
services.zfs.autoSnapshot.enable = true;
|
2021-08-07 12:24:00 +08:00
|
|
|
|
|
|
|
systemd.suppressedSystemUnits = [
|
|
|
|
"hibernate.target"
|
|
|
|
"suspend.target"
|
|
|
|
"suspend-then-hibernate.target"
|
|
|
|
"sleep.target"
|
|
|
|
"hybrid-sleep.target"
|
|
|
|
"systemd-hibernate.service"
|
|
|
|
"systemd-hybrid-sleep.service"
|
|
|
|
"systemd-suspend.service"
|
|
|
|
"systemd-suspend-then-hibernate.service"
|
|
|
|
];
|
2020-06-20 17:54:21 +08:00
|
|
|
|
2022-01-03 14:34:57 +08:00
|
|
|
services.fail2ban.enable = true;
|
2023-01-29 12:11:31 +08:00
|
|
|
services.fail2ban.ignoreIP = [ "94.190.212.123" "2001:470:18:390::2" ];
|
2022-01-03 14:34:57 +08:00
|
|
|
services.fail2ban.maxretry = 9;
|
|
|
|
services.fail2ban.bantime-increment.enable = true;
|
2023-12-16 13:03:19 +08:00
|
|
|
services.fail2ban.jails.sshd = {
|
|
|
|
settings = {
|
|
|
|
filter = "sshd";
|
|
|
|
action = "iptables-allports";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
services.fail2ban.jails.nginx-botsearch = {
|
|
|
|
settings = {
|
|
|
|
filter = "nginx-botsearch";
|
|
|
|
action = "iptables-allports";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
services.fail2ban.jails.nginx-limit-req = {
|
|
|
|
settings = {
|
|
|
|
filter = "nginx-limit-req";
|
|
|
|
action = "iptables-allports";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
services.fail2ban.jails.postfix = {
|
|
|
|
settings = {
|
|
|
|
filter = "postfix";
|
|
|
|
action = "iptables-allports";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
services.fail2ban.jails.dovecot = {
|
|
|
|
settings = {
|
|
|
|
filter = "dovecot";
|
|
|
|
action = "iptables-allports";
|
|
|
|
};
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
networking = {
|
|
|
|
hostName = "nixbld";
|
2021-08-07 12:24:00 +08:00
|
|
|
hostId = "e423f012";
|
2020-06-20 17:54:21 +08:00
|
|
|
firewall = {
|
2024-06-06 16:27:39 +08:00
|
|
|
allowedTCPPorts = [ 53 80 443 2222 7402 ];
|
2023-07-15 14:23:06 +08:00
|
|
|
allowedUDPPorts = [ 53 67 500 4500 ];
|
2020-06-20 17:54:21 +08:00
|
|
|
trustedInterfaces = [ netifLan ];
|
2024-09-30 14:40:09 +08:00
|
|
|
logRefusedConnections = false;
|
2024-10-15 21:27:43 +08:00
|
|
|
extraCommands = ''
|
|
|
|
iptables -A INPUT -s 5.78.86.156 -p gre -j ACCEPT
|
|
|
|
iptables -A INPUT -s 5.78.86.156 -p ah -j ACCEPT
|
|
|
|
'';
|
|
|
|
extraStopCommands = ''
|
|
|
|
iptables -D INPUT -s 5.78.86.156 -p gre -j ACCEPT
|
|
|
|
iptables -D INPUT -s 5.78.86.156 -p ah -j ACCEPT
|
|
|
|
'';
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
2024-05-06 10:32:10 +08:00
|
|
|
useDHCP = false;
|
|
|
|
interfaces."${netifWan}".useDHCP = true; # PCCW - always wants active DHCP lease or cuts you off
|
|
|
|
interfaces."${netifWanBackup}" = { # HKBN - no DHCP with static IP service
|
|
|
|
ipv4.addresses = [{
|
|
|
|
address = "202.77.7.238";
|
|
|
|
prefixLength = 30;
|
|
|
|
}];
|
|
|
|
ipv4.routes = [
|
|
|
|
{
|
|
|
|
address = "0.0.0.0";
|
|
|
|
prefixLength = 0;
|
|
|
|
via = "202.77.7.237";
|
|
|
|
options.table = "2";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
interfaces."${netifLan}" = {
|
|
|
|
ipv4.addresses = [{
|
|
|
|
address = "192.168.1.1";
|
|
|
|
prefixLength = 24;
|
|
|
|
}];
|
|
|
|
ipv6.addresses = [{
|
2023-01-29 12:11:31 +08:00
|
|
|
address = "2001:470:f891:1::";
|
2020-06-20 17:54:21 +08:00
|
|
|
prefixLength = 64;
|
|
|
|
}];
|
2023-07-13 13:56:10 +08:00
|
|
|
# https://unix.stackexchange.com/questions/423502/iproute2-inherit-or-copy-table
|
|
|
|
# we just copy what matters here. Ugly but easier.
|
|
|
|
ipv4.routes = [
|
|
|
|
{
|
|
|
|
address = "192.168.1.0";
|
|
|
|
prefixLength = 24;
|
|
|
|
options.table = "1";
|
|
|
|
}
|
2024-05-06 10:32:10 +08:00
|
|
|
{
|
|
|
|
address = "192.168.1.0";
|
|
|
|
prefixLength = 24;
|
|
|
|
options.table = "2";
|
|
|
|
}
|
2023-07-13 13:56:10 +08:00
|
|
|
];
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
interfaces."${netifWifi}" = {
|
|
|
|
ipv4.addresses = [{
|
|
|
|
address = "192.168.12.1";
|
|
|
|
prefixLength = 24;
|
|
|
|
}];
|
|
|
|
ipv6.addresses = [{
|
2023-01-29 12:11:31 +08:00
|
|
|
address = "2001:470:f891:2::";
|
2020-06-20 17:54:21 +08:00
|
|
|
prefixLength = 64;
|
|
|
|
}];
|
2024-05-06 10:57:11 +08:00
|
|
|
# same hack as above
|
|
|
|
ipv4.routes = [
|
|
|
|
{
|
|
|
|
address = "192.168.12.0";
|
|
|
|
prefixLength = 24;
|
|
|
|
options.table = "1";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
address = "192.168.12.0";
|
|
|
|
prefixLength = 24;
|
|
|
|
options.table = "2";
|
|
|
|
}
|
|
|
|
];
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
nat = {
|
|
|
|
enable = true;
|
|
|
|
externalInterface = netifWan;
|
|
|
|
internalInterfaces = [ netifLan netifWifi ];
|
|
|
|
forwardPorts = [
|
|
|
|
{ sourcePort = 2201; destination = "192.168.1.201:22"; proto = "tcp"; }
|
|
|
|
{ sourcePort = 2202; destination = "192.168.1.202:22"; proto = "tcp"; }
|
|
|
|
{ sourcePort = 2203; destination = "192.168.1.203:22"; proto = "tcp"; }
|
|
|
|
{ sourcePort = 2204; destination = "192.168.1.204:22"; proto = "tcp"; }
|
|
|
|
];
|
|
|
|
extraCommands = ''
|
2022-06-23 15:33:37 +08:00
|
|
|
iptables -w -N block-insecure-devices
|
2022-08-03 12:52:26 +08:00
|
|
|
iptables -w -A block-insecure-devices -m mac --mac-source 00:20:0c:6c:ee:ba -j DROP # keysight SA
|
|
|
|
iptables -w -A block-insecure-devices -m mac --mac-source 74:5b:c5:20:c1:5f -j DROP # siglent scope
|
2023-01-30 16:08:27 +08:00
|
|
|
iptables -w -A block-insecure-devices -m mac --mac-source 00:0a:35:00:01:23 -j DROP # function generator
|
|
|
|
iptables -w -A block-insecure-devices -m mac --mac-source 74:5b:c5:21:f1:ee -j DROP # siglent scope #2
|
|
|
|
iptables -w -A block-insecure-devices -m mac --mac-source 00:19:af:5b:dd:58 -j DROP # power supply
|
2023-07-12 17:41:05 +08:00
|
|
|
iptables -w -A block-insecure-devices -m mac --mac-source 28:58:be:dc:66:1f -j DROP # hikvision low-cost 780nm laser viewer
|
2023-07-13 09:35:32 +08:00
|
|
|
iptables -w -A block-insecure-devices -m mac --mac-source bc:99:11:a4:d2:ac -j DROP # zyxel cloud switch
|
2023-08-08 19:02:29 +08:00
|
|
|
iptables -w -A block-insecure-devices -m mac --mac-source d8:9c:67:ab:83:e7 -j DROP # HP printer, wifi
|
|
|
|
iptables -w -A block-insecure-devices -m mac --mac-source f4:39:09:f7:3c:d7 -j DROP # HP printer, ethernet
|
2022-06-23 15:33:37 +08:00
|
|
|
iptables -w -A FORWARD -j block-insecure-devices
|
2024-08-29 18:39:52 +08:00
|
|
|
|
|
|
|
iptables -w -N pccw-sucks
|
2024-08-29 18:55:52 +08:00
|
|
|
iptables -A pccw-sucks -o ${netifSit} -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1440
|
2024-08-29 18:53:33 +08:00
|
|
|
iptables -A pccw-sucks -o ${netifAlt} -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1380
|
2024-10-17 15:08:27 +08:00
|
|
|
iptables -A pccw-sucks -o ${netifUSA} -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1380
|
2024-08-29 18:39:52 +08:00
|
|
|
iptables -w -A FORWARD -j pccw-sucks
|
2020-06-20 17:54:21 +08:00
|
|
|
'';
|
|
|
|
extraStopCommands = ''
|
2022-06-23 15:33:37 +08:00
|
|
|
iptables -w -D FORWARD -j block-insecure-devices 2>/dev/null|| true
|
|
|
|
iptables -w -F block-insecure-devices 2>/dev/null|| true
|
|
|
|
iptables -w -X block-insecure-devices 2>/dev/null|| true
|
2024-08-29 18:39:52 +08:00
|
|
|
|
|
|
|
iptables -w -D FORWARD -j pccw-sucks 2>/dev/null|| true
|
|
|
|
iptables -w -F pccw-sucks 2>/dev/null|| true
|
|
|
|
iptables -w -X pccw-sucks 2>/dev/null|| true
|
2020-06-20 17:54:21 +08:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
sits."${netifSit}" = {
|
|
|
|
dev = netifWan;
|
|
|
|
remote = "216.218.221.6";
|
2023-01-29 12:11:31 +08:00
|
|
|
local = "94.190.212.123";
|
2020-06-20 17:54:21 +08:00
|
|
|
ttl = 255;
|
|
|
|
};
|
|
|
|
interfaces."${netifSit}".ipv6 = {
|
2023-01-29 12:11:31 +08:00
|
|
|
addresses = [{ address = "2001:470:18:390::2"; prefixLength = 64; }];
|
2020-06-20 17:54:21 +08:00
|
|
|
routes = [{ address = "::"; prefixLength = 0; }];
|
|
|
|
};
|
2024-10-08 16:09:56 +08:00
|
|
|
greTunnels."${netifUSA}" = {
|
|
|
|
dev = netifWan;
|
|
|
|
remote = "5.78.86.156";
|
|
|
|
local = "94.190.212.123";
|
|
|
|
ttl = 255;
|
|
|
|
type = "tun";
|
|
|
|
};
|
2024-08-29 18:53:33 +08:00
|
|
|
greTunnels."${netifAlt}" = {
|
2023-07-13 13:56:10 +08:00
|
|
|
dev = netifWan;
|
|
|
|
remote = "103.206.98.1";
|
|
|
|
local = "94.190.212.123";
|
|
|
|
ttl = 255;
|
|
|
|
type = "tun";
|
|
|
|
};
|
2024-10-08 16:09:56 +08:00
|
|
|
interfaces."${netifUSA}" = {
|
|
|
|
ipv4.addresses = [
|
|
|
|
{
|
|
|
|
address = "10.47.3.1";
|
|
|
|
prefixLength = 31;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
ipv4.routes = [
|
|
|
|
{
|
|
|
|
address = "0.0.0.0";
|
|
|
|
prefixLength = 0;
|
|
|
|
via = "10.47.3.0";
|
|
|
|
options.table = "3";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-08-29 18:53:33 +08:00
|
|
|
interfaces."${netifAlt}" = {
|
2023-07-13 13:56:10 +08:00
|
|
|
ipv4.addresses = [
|
|
|
|
{
|
|
|
|
address = "103.206.98.227";
|
|
|
|
prefixLength = 31;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
ipv4.routes = [
|
|
|
|
{
|
|
|
|
address = "0.0.0.0";
|
|
|
|
prefixLength = 0;
|
|
|
|
via = "103.206.98.226";
|
|
|
|
options.table = "1";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
vlans = {
|
2024-08-29 18:53:33 +08:00
|
|
|
"${netifAltVlan}" = {
|
2023-07-13 13:56:10 +08:00
|
|
|
id = 2;
|
|
|
|
interface = netifLan;
|
|
|
|
};
|
|
|
|
};
|
2024-08-29 18:53:33 +08:00
|
|
|
interfaces."${netifAltVlan}" = {
|
2023-07-13 13:56:10 +08:00
|
|
|
ipv4.addresses = [{
|
|
|
|
address = "103.206.98.200";
|
|
|
|
prefixLength = 29;
|
|
|
|
}];
|
2023-07-13 18:25:05 +08:00
|
|
|
ipv4.routes = [
|
|
|
|
{
|
|
|
|
address = "103.206.98.200";
|
|
|
|
prefixLength = 29;
|
|
|
|
options.table = "1";
|
|
|
|
}
|
|
|
|
];
|
2023-07-13 13:56:10 +08:00
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = "1";
|
|
|
|
boot.kernel.sysctl."net.ipv6.conf.default.forwarding" = "1";
|
2021-04-05 00:08:44 +08:00
|
|
|
boot.kernel.sysctl."net.ipv6.conf.${netifLan}.accept_dad" = "0";
|
|
|
|
boot.kernel.sysctl."net.ipv6.conf.${netifWifi}.accept_dad" = "0";
|
2020-06-20 17:54:21 +08:00
|
|
|
|
2023-07-13 13:56:10 +08:00
|
|
|
services.strongswan-swanctl.enable = true;
|
|
|
|
services.strongswan-swanctl.swanctl.connections.altnet = {
|
|
|
|
local_addrs = [ "94.190.212.123" ];
|
|
|
|
remote_addrs = [ "103.206.98.1" ];
|
|
|
|
local.main = {
|
|
|
|
auth = "pubkey";
|
|
|
|
id = "fqdn:m-labs.hk";
|
|
|
|
pubkeys = [ "/etc/swanctl/pubkey/m-labs.hk" ];
|
|
|
|
};
|
|
|
|
remote.main = {
|
|
|
|
auth = "pubkey";
|
|
|
|
id = "fqdn:igw0.hkg.as150788.net";
|
|
|
|
pubkeys = [ "/etc/swanctl/pubkey/igw0.hkg.as150788.net" ];
|
|
|
|
};
|
2024-08-29 18:53:33 +08:00
|
|
|
children."${netifAlt}" = {
|
2023-07-13 13:56:10 +08:00
|
|
|
mode = "transport";
|
|
|
|
ah_proposals = [ "sha256-curve25519" ];
|
|
|
|
remote_ts = [ "103.206.98.1[gre]" ];
|
|
|
|
local_ts = [ "94.190.212.123[gre]" ];
|
|
|
|
start_action = "start";
|
|
|
|
};
|
|
|
|
};
|
2024-10-08 16:09:56 +08:00
|
|
|
services.strongswan-swanctl.swanctl.connections.usa = {
|
|
|
|
local_addrs = [ "94.190.212.123" ];
|
|
|
|
remote_addrs = [ "5.78.86.156" ];
|
|
|
|
local.main = {
|
|
|
|
auth = "pubkey";
|
|
|
|
id = "fqdn:m-labs.hk";
|
|
|
|
pubkeys = [ "/etc/swanctl/pubkey/m-labs.hk" ];
|
|
|
|
};
|
|
|
|
remote.main = {
|
|
|
|
auth = "pubkey";
|
|
|
|
id = "fqdn:m-labs-intl.com";
|
|
|
|
pubkeys = [ "/etc/swanctl/pubkey/m-labs-intl.com" ];
|
|
|
|
};
|
|
|
|
children."${netifUSA}" = {
|
|
|
|
mode = "transport";
|
|
|
|
ah_proposals = [ "sha256-curve25519" ];
|
|
|
|
remote_ts = [ "5.78.86.156[gre]" ];
|
|
|
|
local_ts = [ "94.190.212.123[gre]" ];
|
|
|
|
start_action = "start";
|
|
|
|
};
|
|
|
|
};
|
2023-07-13 13:56:10 +08:00
|
|
|
|
2024-05-06 10:32:10 +08:00
|
|
|
systemd.services.network-custom-route-backup = {
|
|
|
|
wantedBy = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
|
|
|
ExecStart = "${pkgs.iproute2}/bin/ip rule add from 202.77.7.238/30 table 2";
|
|
|
|
ExecStop = "${pkgs.iproute2}/bin/ip rule del table 2";
|
|
|
|
};
|
|
|
|
};
|
2024-10-08 16:09:56 +08:00
|
|
|
systemd.services.network-custom-route-usa = {
|
|
|
|
wantedBy = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
|
|
|
ExecStart = "${pkgs.iproute2}/bin/ip rule add from 10.47.3.0/31 table 3";
|
|
|
|
ExecStop = "${pkgs.iproute2}/bin/ip rule del table 3";
|
|
|
|
};
|
|
|
|
};
|
2024-05-06 10:32:10 +08:00
|
|
|
systemd.services.network-custom-route-alt = {
|
2023-07-13 13:56:10 +08:00
|
|
|
wantedBy = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
2024-05-06 10:31:45 +08:00
|
|
|
ExecStart = "${pkgs.iproute2}/bin/ip rule add from 103.206.98.200/29 table 1";
|
2023-07-13 13:56:10 +08:00
|
|
|
ExecStop = "${pkgs.iproute2}/bin/ip rule del table 1";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-06-27 13:08:16 +08:00
|
|
|
# https://kb.isc.org/docs/dnssec-key-and-signing-policy
|
|
|
|
# chown named.named /etc/nixos/named
|
2022-06-26 16:57:17 +08:00
|
|
|
services.bind = {
|
2020-06-20 17:54:21 +08:00
|
|
|
enable = true;
|
2023-01-29 12:11:31 +08:00
|
|
|
listenOn = [ "94.190.212.123" ];
|
|
|
|
listenOnIpv6 = [ "2001:470:18:390::2" ];
|
2022-06-26 16:57:17 +08:00
|
|
|
forwarders = [];
|
|
|
|
extraOptions = "listen-on-v6 port 5354 { ::1; };";
|
|
|
|
cacheNetworks = [ "::1/128" ];
|
2022-12-05 10:00:35 +08:00
|
|
|
directory = "/etc/nixos/named";
|
2022-06-26 16:57:17 +08:00
|
|
|
zones = {
|
2022-06-28 14:44:14 +08:00
|
|
|
"m-labs.hk" = {
|
|
|
|
name = "m-labs.hk";
|
2022-06-26 16:57:17 +08:00
|
|
|
master = true;
|
2022-06-28 14:44:14 +08:00
|
|
|
file = "/etc/nixos/named/m-labs.hk";
|
2022-09-30 16:46:39 +08:00
|
|
|
extraConfig =
|
|
|
|
''
|
|
|
|
dnssec-policy "default";
|
|
|
|
inline-signing yes;
|
2023-01-27 14:48:14 +08:00
|
|
|
notify explicit;
|
2023-01-29 18:29:16 +08:00
|
|
|
also-notify {
|
|
|
|
213.239.220.50; # ns1.qnetp.net
|
|
|
|
216.218.130.2; # ns1.he.net
|
2024-04-12 09:40:17 +08:00
|
|
|
88.198.32.245; # new qnetp
|
2023-01-29 18:29:16 +08:00
|
|
|
};
|
2022-09-30 16:46:39 +08:00
|
|
|
'';
|
2022-06-28 14:44:14 +08:00
|
|
|
slaves = [
|
2023-01-29 18:29:16 +08:00
|
|
|
"213.239.220.50" "2a01:4f8:a0:7041::1" # ns1.qnetp.net
|
|
|
|
"216.218.133.2" "2001:470:600::2" # slave.dns.he.net
|
2024-04-12 09:40:17 +08:00
|
|
|
"88.198.32.245" # new qnetp
|
2022-06-28 14:44:14 +08:00
|
|
|
];
|
2021-06-07 09:56:05 +08:00
|
|
|
};
|
2023-03-23 15:22:16 +08:00
|
|
|
"m-labs.ph" = {
|
|
|
|
name = "m-labs.ph";
|
|
|
|
master = true;
|
|
|
|
file = "/etc/nixos/named/m-labs.ph";
|
|
|
|
extraConfig =
|
|
|
|
''
|
|
|
|
notify explicit;
|
|
|
|
also-notify {
|
|
|
|
216.218.130.2; # ns1.he.net
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
slaves = [
|
|
|
|
"216.218.133.2" "2001:470:600::2" # slave.dns.he.net
|
2023-07-13 13:56:10 +08:00
|
|
|
];
|
|
|
|
};
|
2023-09-05 22:04:27 +08:00
|
|
|
"193thz.com" = {
|
|
|
|
name = "193thz.com";
|
|
|
|
master = true;
|
|
|
|
file = "/etc/nixos/named/193thz.com";
|
|
|
|
extraConfig =
|
|
|
|
''
|
|
|
|
dnssec-policy "default";
|
|
|
|
inline-signing yes;
|
|
|
|
notify explicit;
|
|
|
|
also-notify {
|
|
|
|
216.218.130.2; # ns1.he.net
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
slaves = [
|
|
|
|
"216.218.133.2" "2001:470:600::2" # slave.dns.he.net
|
|
|
|
];
|
|
|
|
};
|
2023-12-13 18:29:51 +08:00
|
|
|
"malloctech.fr" = {
|
|
|
|
name = "malloctech.fr";
|
|
|
|
master = true;
|
|
|
|
file = "/etc/nixos/named/malloctech.fr";
|
|
|
|
extraConfig =
|
|
|
|
''
|
|
|
|
dnssec-policy "default";
|
|
|
|
inline-signing yes;
|
|
|
|
notify explicit;
|
|
|
|
also-notify {
|
|
|
|
216.218.130.2; # ns1.he.net
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
slaves = [
|
|
|
|
"216.218.133.2" "2001:470:600::2" # slave.dns.he.net
|
|
|
|
];
|
|
|
|
};
|
2024-06-06 17:29:07 +08:00
|
|
|
"m-labs-intl.com" = {
|
|
|
|
name = "m-labs-intl.com";
|
|
|
|
master = true;
|
|
|
|
file = "/etc/nixos/named/m-labs-intl.com";
|
|
|
|
extraConfig =
|
|
|
|
''
|
|
|
|
dnssec-policy "default";
|
|
|
|
inline-signing yes;
|
|
|
|
notify explicit;
|
|
|
|
also-notify {
|
|
|
|
216.218.130.2; # ns1.he.net
|
2024-08-15 19:52:42 +08:00
|
|
|
213.239.220.50; # ns1.qnetp.net
|
|
|
|
88.198.32.245; # new qnetp
|
2024-06-06 17:29:07 +08:00
|
|
|
};
|
|
|
|
'';
|
|
|
|
slaves = [
|
|
|
|
"216.218.133.2" "2001:470:600::2" # slave.dns.he.net
|
2024-08-15 19:52:42 +08:00
|
|
|
"213.239.220.50" "2a01:4f8:a0:7041::1" # ns1.qnetp.net
|
|
|
|
"88.198.32.245" # new qnetp
|
2024-06-06 17:29:07 +08:00
|
|
|
];
|
|
|
|
};
|
2023-07-13 13:56:10 +08:00
|
|
|
"200-29.98.206.103.in-addr.arpa" = {
|
|
|
|
name = "200-29.98.206.103.in-addr.arpa";
|
|
|
|
master = true;
|
|
|
|
file = "/etc/nixos/named/200-29.98.206.103.in-addr.arpa";
|
|
|
|
extraConfig =
|
|
|
|
''
|
|
|
|
dnssec-policy "default";
|
|
|
|
inline-signing yes;
|
|
|
|
notify explicit;
|
|
|
|
also-notify {
|
|
|
|
216.218.130.2; # ns1.he.net
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
slaves = [
|
|
|
|
"216.218.133.2" "2001:470:600::2" # slave.dns.he.net
|
2023-03-23 15:22:16 +08:00
|
|
|
];
|
|
|
|
};
|
2021-06-07 09:56:05 +08:00
|
|
|
};
|
2023-01-28 09:53:13 +08:00
|
|
|
extraConfig = ''
|
|
|
|
zone "mil." IN {
|
|
|
|
type forward;
|
|
|
|
forward only;
|
|
|
|
forwarders { 74.82.42.42; };
|
|
|
|
};
|
|
|
|
'';
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
services.hostapd = {
|
2023-12-16 13:03:19 +08:00
|
|
|
enable = true;
|
|
|
|
radios.${netifWifi} = {
|
|
|
|
band = "2g";
|
|
|
|
countryCode = "HK";
|
|
|
|
networks.${netifWifi} = {
|
|
|
|
ssid = "M-Labs";
|
|
|
|
authentication.saePasswords = [
|
|
|
|
{ password = (import /etc/nixos/secret/wifi_password.nix); }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
services.dnsmasq = {
|
|
|
|
enable = true;
|
2023-06-04 22:40:14 +08:00
|
|
|
settings = {
|
|
|
|
server = ["::1#5354"];
|
|
|
|
interface = [ netifLan netifWifi ];
|
|
|
|
bind-interfaces = true;
|
|
|
|
dhcp-range = [
|
|
|
|
"interface:${netifLan},192.168.1.81,192.168.1.254,24h"
|
|
|
|
"interface:${netifWifi},192.168.12.10,192.168.12.254,24h"
|
|
|
|
"interface:${netifLan},::,constructor:${netifLan},ra-names"
|
|
|
|
"interface:${netifWifi},::,constructor:${netifWifi},ra-only"
|
|
|
|
];
|
|
|
|
enable-ra = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
2023-06-04 22:40:14 +08:00
|
|
|
no-resolv = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
2023-06-04 22:40:14 +08:00
|
|
|
dhcp-host = [
|
|
|
|
# Static IPv4s to make Red Pitayas with factory firmware less annoying
|
|
|
|
"rp-f05cc9,192.168.1.190"
|
|
|
|
"rp-f0612e,192.168.1.191"
|
|
|
|
# Static IPv4s to make port redirections work
|
|
|
|
"rpi-1,192.168.1.201"
|
|
|
|
"rpi-2,192.168.1.202"
|
|
|
|
"rpi-3,192.168.1.203"
|
|
|
|
"rpi-4,192.168.1.204"
|
|
|
|
];
|
2021-03-05 18:42:54 +08:00
|
|
|
|
2023-06-04 22:40:14 +08:00
|
|
|
address = [
|
|
|
|
# Static IP addresses for non-DHCP boards
|
|
|
|
"/thermostat/192.168.1.26"
|
|
|
|
"/powercycler/192.168.1.31"
|
|
|
|
"/kc705/192.168.1.50"
|
|
|
|
"/zynq-experiments/192.168.1.51"
|
|
|
|
"/zc706/192.168.1.52"
|
|
|
|
"/zc706-2/192.168.1.53"
|
|
|
|
"/cora-z7/192.168.1.54"
|
|
|
|
"/rust-pitaya/192.168.1.55"
|
|
|
|
"/kasli/192.168.1.70"
|
|
|
|
"/kasli-customer/192.168.1.75"
|
|
|
|
"/stabilizer-customer/192.168.1.76"
|
|
|
|
];
|
2023-07-02 16:15:24 +08:00
|
|
|
|
2023-07-02 16:31:25 +08:00
|
|
|
dhcp-match = "set:ipxe,175"; # https://forum.ipxe.org/showthread.php?tid=6077
|
|
|
|
dhcp-boot = [
|
|
|
|
"tag:!ipxe,ipxe.efi"
|
2024-01-07 19:13:27 +08:00
|
|
|
"tag:ipxe,http://m-labs.hk/nuc-netboot/netboot.ipxe"
|
2023-07-02 16:31:25 +08:00
|
|
|
];
|
2023-07-02 16:15:24 +08:00
|
|
|
enable-tftp = netifLan;
|
|
|
|
tftp-root = "${pkgs.ipxe}";
|
2023-06-04 22:40:14 +08:00
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
# Select internationalisation properties.
|
|
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
|
|
|
console = {
|
|
|
|
font = "Lat2-Terminus16";
|
|
|
|
keyMap = "de";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Set your time zone.
|
|
|
|
time.timeZone = "Asia/Hong_Kong";
|
|
|
|
|
|
|
|
# List packages installed in system profile. To search, run:
|
|
|
|
# $ nix search wget
|
|
|
|
environment.systemPackages = with pkgs; [
|
2024-09-30 15:12:01 +08:00
|
|
|
lm_sensors
|
|
|
|
acpi
|
|
|
|
usbutils
|
|
|
|
pciutils
|
2021-08-09 13:32:37 +08:00
|
|
|
iw
|
|
|
|
nvme-cli
|
2024-09-30 15:12:01 +08:00
|
|
|
smartmontools
|
|
|
|
psmisc
|
|
|
|
|
|
|
|
wget
|
|
|
|
vim
|
|
|
|
git
|
|
|
|
file
|
|
|
|
imagemagick
|
|
|
|
jq
|
|
|
|
|
|
|
|
nixops_unstable_minimal
|
2021-09-18 16:35:25 +08:00
|
|
|
borgbackup
|
2022-06-27 18:16:38 +08:00
|
|
|
bind
|
2023-05-24 12:44:55 +08:00
|
|
|
waypipe
|
2022-02-07 14:31:37 +08:00
|
|
|
(callPackage ./afws { inherit pkgs; })
|
2023-02-10 18:26:12 +08:00
|
|
|
(callPackage ./labelprinter { inherit pkgs; })
|
2020-06-20 17:54:21 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
# Some programs need SUID wrappers, can be configured further or are
|
|
|
|
# started in user sessions.
|
|
|
|
# programs.mtr.enable = true;
|
|
|
|
# programs.gnupg.agent = { enable = true; enableSSHSupport = true; };
|
|
|
|
|
|
|
|
# List services that you want to enable:
|
|
|
|
|
|
|
|
services.apcupsd.enable = true;
|
|
|
|
services.apcupsd.configText = ''
|
|
|
|
UPSTYPE usb
|
|
|
|
NISIP 127.0.0.1
|
|
|
|
BATTERYLEVEL 10
|
|
|
|
MINUTES 5
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Enable the OpenSSH daemon.
|
|
|
|
services.openssh.enable = true;
|
2023-06-02 17:36:05 +08:00
|
|
|
services.openssh.settings.PasswordAuthentication = false;
|
|
|
|
services.openssh.settings.GatewayPorts = "clientspecified";
|
2024-05-23 22:20:56 +08:00
|
|
|
services.openssh.settings.X11Forwarding = true;
|
2024-06-02 14:10:10 +08:00
|
|
|
services.openssh.authorizedKeysInHomedir = false;
|
2020-06-20 17:54:21 +08:00
|
|
|
programs.mosh.enable = true;
|
2024-09-30 15:12:01 +08:00
|
|
|
programs.tmux.enable = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
programs.fish.enable = true;
|
2023-06-02 17:36:05 +08:00
|
|
|
programs.zsh.enable = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
# Enable CUPS to print documents.
|
|
|
|
services.avahi.enable = true;
|
2023-06-02 17:36:05 +08:00
|
|
|
services.avahi.allowInterfaces = [ netifLan ];
|
2020-06-20 17:54:21 +08:00
|
|
|
services.avahi.publish.enable = true;
|
|
|
|
services.avahi.publish.userServices = true;
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
services.printing.enable = true;
|
|
|
|
services.printing.drivers = [ pkgs.hplipWithPlugin ];
|
|
|
|
services.printing.browsing = true;
|
|
|
|
services.printing.listenAddresses = [ "*:631" ];
|
|
|
|
services.printing.defaultShared = true;
|
|
|
|
hardware.sane.enable = true;
|
|
|
|
hardware.sane.extraBackends = [ pkgs.hplipWithPlugin ];
|
2024-01-23 17:35:29 +08:00
|
|
|
services.saned.enable = true;
|
|
|
|
services.saned.extraConfig = "192.168.1.0/24";
|
2020-06-20 17:54:21 +08:00
|
|
|
|
2023-01-30 16:12:00 +08:00
|
|
|
services.udev.extraRules =
|
|
|
|
''
|
|
|
|
# label printer
|
|
|
|
SUBSYSTEM=="usb", ATTRS{idVendor}=="07cf", ATTRS{idProduct}=="4204", MODE="0660", GROUP="lp"
|
|
|
|
'';
|
|
|
|
|
2024-05-23 22:21:10 +08:00
|
|
|
sound.enable = true;
|
2024-06-02 13:50:24 +08:00
|
|
|
services.mpd.enable = true;
|
|
|
|
services.mpd.musicDirectory = "/tank/sb-public/FLAC";
|
|
|
|
services.mpd.network.listenAddress = "192.168.1.1";
|
|
|
|
services.mpd.extraConfig =
|
|
|
|
''
|
|
|
|
audio_output_format "192000:24:2"
|
|
|
|
audio_output {
|
|
|
|
type "alsa"
|
|
|
|
name "alsa"
|
|
|
|
device "hw:1,1"
|
|
|
|
}
|
|
|
|
'';
|
2024-05-23 22:21:10 +08:00
|
|
|
|
2022-01-03 13:46:57 +08:00
|
|
|
users.extraUsers.root = {
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBNdIiLvP2hmDUFyyE0oLOIXrjrMdWWpBV9/gPR5m4AiARx4JkufIDZzmptdYQ5FhJORJ4lluPqp7dAmahoSwg4lv9Di0iNQpHMJvNGZLHYKM1H1FWCCFIEDJ8bD4SVfrDg=="
|
2024-11-26 21:46:47 +08:00
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBDf6+TFaUtITiiU7b6DOiT4/C8fzCq70j9DGnNyo/+5bS7ffRezTS0AqqltHQs9/lbjUbtP+Iil7RUGF0o0X6v5y/Gt/GdV9QR+Nv1mJCF1KVOeMKm/vB0jjN+ncwHU+BA=="
|
2022-01-03 13:46:57 +08:00
|
|
|
];
|
|
|
|
shell = pkgs.fish;
|
|
|
|
};
|
2022-01-17 18:48:23 +08:00
|
|
|
# https://github.com/NixOS/nixpkgs/issues/155357
|
|
|
|
security.sudo.enable = true;
|
2022-01-03 13:46:57 +08:00
|
|
|
|
2024-10-02 18:40:48 +08:00
|
|
|
# M-Labs HK
|
2020-06-20 17:54:21 +08:00
|
|
|
users.extraUsers.sb = {
|
|
|
|
isNormalUser = true;
|
2024-05-23 22:21:10 +08:00
|
|
|
extraGroups = ["lp" "scanner" "afws" "audio"];
|
2020-06-20 17:54:21 +08:00
|
|
|
openssh.authorizedKeys.keys = [
|
2023-11-01 19:22:51 +08:00
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBF/YybP+fQ0J+bNqM5Vgx5vDmVqVWsgUdF1moUxghv7d73GZAFaM6IFBdrXTAa33AwnWwDPMrTgP1V6SXBkb3ciJo/lD1urJGbydbSI5Ksq9d59wvOeANvyWYrQw6+eqTQ=="
|
2024-11-26 21:46:47 +08:00
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBDf6+TFaUtITiiU7b6DOiT4/C8fzCq70j9DGnNyo/+5bS7ffRezTS0AqqltHQs9/lbjUbtP+Iil7RUGF0o0X6v5y/Gt/GdV9QR+Nv1mJCF1KVOeMKm/vB0jjN+ncwHU+BA=="
|
2020-06-20 17:54:21 +08:00
|
|
|
];
|
2020-10-27 14:57:07 +08:00
|
|
|
shell = pkgs.fish;
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
2022-05-06 16:55:00 +08:00
|
|
|
users.extraUsers.spaqin = {
|
|
|
|
isNormalUser = true;
|
2024-04-12 09:40:40 +08:00
|
|
|
extraGroups = ["lp" "afws"];
|
2022-05-06 16:55:00 +08:00
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBOtmlQmIK/cEUkcwA/y9jC4AohjoEmikerpxzPhZZtOcENidN/vFum58jIcSxBvjHnILOzhfCTeLvbvGbQOFE53a7FOyEHmIzXRKS86Mg5bPHUBJxRSq9MjulGZXES3HOQ=="
|
|
|
|
];
|
|
|
|
shell = pkgs.zsh;
|
|
|
|
};
|
2024-04-10 11:40:16 +08:00
|
|
|
users.extraUsers.therobs12 = {
|
2023-03-03 18:29:45 +08:00
|
|
|
isNormalUser = true;
|
2024-04-12 09:40:40 +08:00
|
|
|
extraGroups = ["lp" "afws"];
|
2023-03-03 18:29:45 +08:00
|
|
|
openssh.authorizedKeys.keys = [
|
2024-04-10 11:40:16 +08:00
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBK1tUg7TtceARRnGI80Ai5kNFolFfZ++LH9v1UoRCiJdxeQWPdNYO0Gj7+ejJvgZXwvN4yHGgcZHraEml4Mj/dKrEMFygfuYLDRmXtPFwX6TNMrWlxMhPzuNY+yCaxlqYg=="
|
2023-03-03 18:29:45 +08:00
|
|
|
];
|
|
|
|
};
|
2024-01-23 13:25:55 +08:00
|
|
|
users.extraUsers.morgan = {
|
|
|
|
isNormalUser = true;
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBDXMbJEPn0mM2Bgt6eMAd+c0J5oPSvquZG+BxKdUf0qbeQldRaoB26NHMZnLte/fS00U/cqStLWDiwtEvH5WlbbawsMBymm65zbWMByebXhBDjdr6a1kkOFcKJvAL9qVBQ=="
|
|
|
|
];
|
|
|
|
};
|
2024-10-02 18:40:48 +08:00
|
|
|
|
|
|
|
# M-Labs PH
|
2024-08-01 07:32:11 +08:00
|
|
|
users.extraUsers.flo = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = ["afws"];
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBF4ZYNBYqJPQCKBYjMatFj5eGMyzh/X2TSraJEG6XBdg3jnJ3WcsOd7sm+vx+o9Y1EJ2kvwW/Vy9c3OYVU2U45njox//sKtt8Eyzszws3EYJqHQ6KAwXtW9ao4aamRtK3Q=="
|
|
|
|
];
|
|
|
|
};
|
2024-10-02 18:40:48 +08:00
|
|
|
|
|
|
|
# QUARTIQ
|
|
|
|
users.extraUsers.rj = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = ["afws"];
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC27krR8G8Pb59YuYm7+X2mmNnVdk/t9myYgO8LH0zfb2MeeXX5+90nW9kMjKflJss/oLl8dkD85jbJ0fRbRkfJd20pGCqCUuYAbYKkowigFVEkbrbWSLkmf+clRjzJOuBuUA0uq0XKS17uMC3qhu+dDdBOAIKb3L83NfVE8p8Pjb4BPktQrdxefM43/x4jTMuc7tgxVmTOEge3+rmVPK2GnLkUBgBn8b6S+9ElPd63HXI5J5f61v21l5N9V0mhTu1pv6PiDRdFIlFDK9dLVZcZ2qlzpKmCnFrOoreBEgre44SpfFe5/MMItxvWiVsj/rij/rHZZiol1k7JiQCnEHeCCbjjvcBBka5HxZgcb3vBZVceTOawrmjbdbA2dq35sUptz/bEgdZ1UVCmVpWsdROAlEDBmSSbcVwxzcvhoKnkpbuP4Q0V3tVKSLW053ADFNB4frtwY5nAZfsVErFLLphjwb8nlyJoDRNapQrn5syEiW0ligX2AAskZTYIl2A5AYyWPrmX6HJOPqZGatMU3qQiRMxs+hFqhyyCmBgl0kcsgW09MBKtJWk1Fbii98MHqgRUN9R7AUiYy5p78Pnv9DC8DT8Ubl9zoP0g5d40P9NGK2LAhMxLXvtckJ4ERqbSEcNZJw+q4jBrOHnMTz+NLdAUiEtru+6T2OdhaHv+eiNlFQ== robert-jordens-rsa4096"
|
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCUdbne3NtIG+iy/jer76/OY+IksuS3BDLSXPnWrGejWnig9h+L6sUV0lEVI6dqp+W/b8jWqPB8nh5S0NZsCd3Ta3Go82k/SPPkh9lB2PpfquhCjLnmC/RNc3TgC4FuiS+NZHqXaTggYHubNwEK+8gynMqkMQXjOGU02U0CtUfsYdAm75AW60DySZCRNwOcU0Ndpn1UCpha7fL1k179Dd/OtArkYsIL24ohlfxFeOB3jGYQK6ATmzbvCRjwIKXcyECuajWwfnDg9FtDWrqHNzu5dJlvmxoWm8zCDgMj53uiA7TjujQN81MYrIJNeEwSr5jXQMqzA3mzlk4k3Z0qs3TP robert-jordens-64FEFBAF-4D0749B2-rsa2048"
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMUaB2G1jexxfkdlly3fdWslH54/s/bOuvk9AxqpjtAY robert-jordens-ed25519"
|
|
|
|
];
|
|
|
|
};
|
2024-10-02 18:41:45 +08:00
|
|
|
users.extraUsers.eduardotenholder = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = ["afws"];
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIu6yhjCoZ62eamYrAXtFefDhplTRUIdD4tncwlkyAEH"
|
|
|
|
];
|
|
|
|
};
|
2024-10-02 18:40:48 +08:00
|
|
|
|
|
|
|
# HKUST
|
2023-09-20 18:23:27 +08:00
|
|
|
users.extraUsers.derppening = {
|
|
|
|
isNormalUser = true;
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBOKwN4ui94QfouYYlkI1lc3WgtjURVYLTdAizJIBnY3dNRNblAiuvTD4pQ+LEI+eOTg4SnQz1NeqH4YOQhbT5+/nZojvGTb3UVN13ZYND+Gci3DdqB2mwIYop7kMXwHgLQ=="
|
|
|
|
];
|
|
|
|
};
|
2024-04-10 11:40:16 +08:00
|
|
|
|
2020-06-20 17:54:21 +08:00
|
|
|
users.extraUsers.nix = {
|
|
|
|
isNormalUser = true;
|
|
|
|
};
|
|
|
|
boot.kernel.sysctl."kernel.dmesg_restrict" = true;
|
|
|
|
services.udev.packages = [ pkgs.sane-backends ];
|
|
|
|
|
2024-04-13 16:47:30 +08:00
|
|
|
nix.settings.max-jobs = 10;
|
2021-08-07 12:24:00 +08:00
|
|
|
nix.nrBuildUsers = 64;
|
2020-06-20 17:54:21 +08:00
|
|
|
services.hydra = {
|
|
|
|
enable = true;
|
2024-04-13 16:47:30 +08:00
|
|
|
useSubstitutes = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
hydraURL = "https://nixbld.m-labs.hk";
|
|
|
|
notificationSender = "hydra@m-labs.hk";
|
|
|
|
minimumDiskFree = 15; # in GB
|
|
|
|
minimumDiskFreeEvaluator = 1;
|
|
|
|
extraConfig =
|
|
|
|
''
|
|
|
|
binary_cache_secret_key_file = /etc/nixos/secret/nixbld.m-labs.hk-1
|
|
|
|
max_output_size = 10000000000
|
|
|
|
|
|
|
|
<runcommand>
|
|
|
|
job = web:web:web
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/web
|
|
|
|
</runcommand>
|
2024-08-14 10:54:52 +08:00
|
|
|
<runcommand>
|
|
|
|
job = web:web:web-intl
|
2024-10-24 17:35:24 +08:00
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ${pkgs.rsync}/bin/rsync -r -c $(jq -r '.outputs[0].path' < $HYDRA_JSON)/ zolaupd@10.47.3.0:/var/www/m-labs-intl.com/html/
|
2024-08-14 10:54:52 +08:00
|
|
|
</runcommand>
|
2022-09-27 11:07:13 +08:00
|
|
|
<runcommand>
|
|
|
|
job = web:web:nmigen-docs
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/nmigen-docs
|
|
|
|
</runcommand>
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
<runcommand>
|
2022-02-12 11:07:08 +08:00
|
|
|
job = artiq:sipyco:sipyco-manual-html
|
2020-06-20 17:54:21 +08:00
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/sipyco-manual-html
|
|
|
|
</runcommand>
|
|
|
|
<runcommand>
|
2022-02-12 11:07:08 +08:00
|
|
|
job = artiq:sipyco:sipyco-manual-pdf
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/sipyco-manual-pdf
|
2020-06-20 17:54:21 +08:00
|
|
|
</runcommand>
|
|
|
|
|
|
|
|
<runcommand>
|
2022-02-12 10:19:15 +08:00
|
|
|
job = artiq:main-beta:artiq-manual-html
|
2020-06-20 17:54:21 +08:00
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-html-beta
|
|
|
|
</runcommand>
|
|
|
|
<runcommand>
|
2022-02-12 10:19:15 +08:00
|
|
|
job = artiq:main-beta:artiq-manual-pdf
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-pdf-beta
|
2020-06-20 17:54:21 +08:00
|
|
|
</runcommand>
|
|
|
|
<runcommand>
|
2022-02-12 18:50:08 +08:00
|
|
|
job = artiq:extra-beta:conda-channel
|
2020-06-20 17:54:21 +08:00
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-conda-channel-beta
|
|
|
|
</runcommand>
|
2024-06-05 11:23:24 +08:00
|
|
|
<runcommand>
|
|
|
|
job = artiq:extra-beta:msys2-repos
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-msys2-repos-beta
|
|
|
|
</runcommand>
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
<runcommand>
|
2022-07-08 19:00:38 +08:00
|
|
|
job = artiq:main:artiq-manual-html
|
2020-06-20 17:54:21 +08:00
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-html
|
|
|
|
</runcommand>
|
|
|
|
<runcommand>
|
2022-07-08 19:00:38 +08:00
|
|
|
job = artiq:main:artiq-manual-pdf
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-pdf
|
2020-06-20 17:54:21 +08:00
|
|
|
</runcommand>
|
|
|
|
<runcommand>
|
2022-07-08 19:00:38 +08:00
|
|
|
job = artiq:extra:conda-channel
|
2020-06-20 17:54:21 +08:00
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-conda-channel
|
|
|
|
</runcommand>
|
2024-06-05 11:23:24 +08:00
|
|
|
<runcommand>
|
|
|
|
job = artiq:extra:msys2-repos
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-msys2-repos
|
|
|
|
</runcommand>
|
2020-09-03 01:53:33 +08:00
|
|
|
|
2021-02-17 16:09:20 +08:00
|
|
|
<runcommand>
|
2024-06-05 11:23:24 +08:00
|
|
|
job = artiq:main-legacy:artiq-manual-html
|
2021-02-17 16:09:20 +08:00
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-html-legacy
|
|
|
|
</runcommand>
|
|
|
|
<runcommand>
|
2024-06-05 11:23:24 +08:00
|
|
|
job = artiq:main-legacy:artiq-manual-pdf
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-pdf-legacy
|
2021-02-17 16:09:20 +08:00
|
|
|
</runcommand>
|
|
|
|
<runcommand>
|
2024-06-05 11:23:24 +08:00
|
|
|
job = artiq:extra-legacy:conda-channel
|
2021-02-17 16:09:20 +08:00
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-conda-channel-legacy
|
|
|
|
</runcommand>
|
|
|
|
|
2021-08-10 19:08:25 +08:00
|
|
|
<runcommand>
|
|
|
|
job = artiq:*:conda-channel
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-conda-channel-archives/$(jq -r '.build' < $HYDRA_JSON)
|
|
|
|
</runcommand>
|
|
|
|
|
2022-04-05 11:14:17 +08:00
|
|
|
<runcommand>
|
2023-11-25 17:24:33 +08:00
|
|
|
job = artiq:main-nac3:msys2-repos
|
2022-11-03 19:09:35 +08:00
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-msys2-repos-nac3
|
2022-04-05 11:14:17 +08:00
|
|
|
</runcommand>
|
|
|
|
|
2021-02-17 16:09:20 +08:00
|
|
|
|
2020-09-03 01:53:33 +08:00
|
|
|
<githubstatus>
|
|
|
|
jobs = artiq:fast.*:extended-tests
|
|
|
|
inputs = artiqSrc
|
|
|
|
useShortContext = 1
|
|
|
|
authorization = token ${(import /etc/nixos/secret/github_tokens.nix).artiq}
|
|
|
|
</githubstatus>
|
2021-05-13 15:46:52 +08:00
|
|
|
<gitea_authorization>
|
|
|
|
sb=${(import /etc/nixos/secret/gitea_tokens.nix).artiq-zynq}
|
|
|
|
</gitea_authorization>
|
2020-06-20 17:54:21 +08:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
systemd.services.hydra-www-outputs-init = {
|
|
|
|
description = "Set up a hydra-owned directory for build outputs";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
requiredBy = [ "hydra-queue-runner.service" ];
|
|
|
|
before = [ "hydra-queue-runner.service" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
2021-08-10 19:08:25 +08:00
|
|
|
ExecStart = [
|
|
|
|
"${pkgs.coreutils}/bin/mkdir -p ${hydraWwwOutputs} ${hydraWwwOutputs}/artiq-conda-channel-archives"
|
|
|
|
"${pkgs.coreutils}/bin/chown hydra-queue-runner:hydra ${hydraWwwOutputs} ${hydraWwwOutputs}/artiq-conda-channel-archives"
|
|
|
|
];
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
};
|
2022-02-07 14:31:37 +08:00
|
|
|
services.afws.enable = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
nix.extraOptions = ''
|
|
|
|
secret-key-files = /etc/nixos/secret/nixbld.m-labs.hk-1
|
2022-12-03 16:29:32 +08:00
|
|
|
experimental-features = nix-command flakes
|
2020-06-20 17:54:21 +08:00
|
|
|
'';
|
2024-06-03 22:39:00 +08:00
|
|
|
nix.settings.allowed-uris = "github: gitlab: git+https://"; # https://github.com/NixOS/nix/issues/5039
|
2022-12-03 16:29:32 +08:00
|
|
|
nix.settings.extra-sandbox-paths = ["/opt"];
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
services.mlabs-backup.enable = true;
|
2021-08-07 17:46:09 +08:00
|
|
|
services.ghbackup.enable = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
services.gitea = {
|
|
|
|
enable = true;
|
|
|
|
appName = "M-Labs Git";
|
2024-08-17 18:18:56 +08:00
|
|
|
database = {
|
|
|
|
type = "postgres";
|
|
|
|
socket = "/run/postgresql";
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
mailerPasswordFile = "/etc/nixos/secret/mailerpassword";
|
2020-10-31 17:30:46 +08:00
|
|
|
settings = {
|
2023-06-02 17:36:05 +08:00
|
|
|
server = {
|
|
|
|
ROOT_URL = "https://git.m-labs.hk/";
|
|
|
|
HTTP_PORT = 3001;
|
2024-06-06 16:27:39 +08:00
|
|
|
DISABLE_SSH = false;
|
|
|
|
SSH_CREATE_AUTHORIZED_KEYS_FILE = false;
|
|
|
|
START_SSH_SERVER = true;
|
|
|
|
SSH_PORT = 2222;
|
2023-06-02 17:36:05 +08:00
|
|
|
};
|
|
|
|
|
2020-10-31 17:30:46 +08:00
|
|
|
indexer = {
|
|
|
|
REPO_INDEXER_ENABLED = true;
|
|
|
|
};
|
2020-08-31 17:39:28 +08:00
|
|
|
|
2020-10-31 17:30:46 +08:00
|
|
|
mailer = {
|
|
|
|
ENABLED = true;
|
2024-06-05 11:23:24 +08:00
|
|
|
SMTP_ADDR = "mail.m-labs.hk";
|
|
|
|
SMTP_PORT = "587";
|
2020-10-31 17:30:46 +08:00
|
|
|
FROM = "sysop@m-labs.hk";
|
|
|
|
USER = "sysop@m-labs.hk";
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
|
2020-10-31 17:30:46 +08:00
|
|
|
service = {
|
|
|
|
ENABLE_NOTIFY_MAIL = true;
|
2022-12-03 16:29:32 +08:00
|
|
|
DISABLE_REGISTRATION = true;
|
2020-10-31 17:30:46 +08:00
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
|
2020-10-31 17:30:46 +08:00
|
|
|
attachment = {
|
|
|
|
ALLOWED_TYPES = "*/*";
|
|
|
|
};
|
2022-12-03 16:29:32 +08:00
|
|
|
|
|
|
|
log.LEVEL = "Warn";
|
|
|
|
|
|
|
|
session.COOKIE_SECURE = true;
|
2020-10-31 17:30:46 +08:00
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"L+ '${config.services.gitea.stateDir}/custom/templates/home.tmpl' - - - - ${./gitea-home.tmpl}"
|
2021-01-23 17:20:05 +08:00
|
|
|
"L+ '${config.services.gitea.stateDir}/custom/templates/user/auth/signin.tmpl' - - - - ${./gitea-signin.tmpl}"
|
2020-06-20 17:54:21 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
services.mattermost = {
|
|
|
|
enable = true;
|
|
|
|
siteUrl = "https://chat.m-labs.hk/";
|
|
|
|
mutableConfig = true;
|
|
|
|
};
|
|
|
|
services.matterbridge = {
|
|
|
|
enable = true;
|
|
|
|
configPath = "/etc/nixos/secret/matterbridge.toml";
|
|
|
|
};
|
2024-08-11 12:09:30 +08:00
|
|
|
|
|
|
|
services.postgresql = {
|
2024-08-25 11:06:19 +08:00
|
|
|
package = pkgs.postgresql_15;
|
2024-08-11 12:19:15 +08:00
|
|
|
settings.listen_addresses = pkgs.lib.mkForce "";
|
2024-08-11 12:09:30 +08:00
|
|
|
identMap =
|
|
|
|
''
|
|
|
|
rt rt rt_user
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-06-20 17:54:21 +08:00
|
|
|
nixpkgs.config.packageOverrides = super: let self = super.pkgs; in {
|
2022-06-04 13:52:21 +08:00
|
|
|
nix = super.nix.overrideAttrs(oa: {
|
2023-12-16 13:03:19 +08:00
|
|
|
patches = oa.patches or [] ++ [ ./nix-networked-derivations.patch ];
|
2022-06-04 13:52:21 +08:00
|
|
|
});
|
2022-05-26 12:12:14 +08:00
|
|
|
hydra_unstable = super.hydra_unstable.overrideAttrs(oa: {
|
2020-06-27 02:20:03 +08:00
|
|
|
patches = oa.patches or [] ++ [
|
|
|
|
./hydra-conda.patch
|
2022-04-04 15:05:39 +08:00
|
|
|
./hydra-msys2.patch
|
2020-06-27 02:20:03 +08:00
|
|
|
./hydra-restrictdist.patch
|
|
|
|
];
|
2020-06-20 17:54:21 +08:00
|
|
|
hydraPath = oa.hydraPath + ":" + super.lib.makeBinPath [ super.jq ];
|
2022-05-26 12:12:14 +08:00
|
|
|
doCheck = false; # FIXME: ldap tests fail on hydra rebuild, seems unrelated to patches above.
|
2020-06-20 17:54:21 +08:00
|
|
|
});
|
|
|
|
matterbridge = super.matterbridge.overrideAttrs(oa: {
|
|
|
|
patches = oa.patches or [] ++ [ ./matterbridge-disable-github.patch ];
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
security.acme.acceptTerms = true;
|
2024-12-03 17:41:25 +08:00
|
|
|
security.acme.defaults.email = "sb@m-labs.hk";
|
2022-07-04 16:22:40 +08:00
|
|
|
|
2020-12-21 13:04:24 +08:00
|
|
|
# https://github.com/NixOS/nixpkgs/issues/106862
|
2022-06-26 16:57:17 +08:00
|
|
|
systemd.services."acme-fixperms".wants = [ "bind.service" "dnsmasq.service" ];
|
|
|
|
systemd.services."acme-fixperms".after = [ "bind.service" "dnsmasq.service" ];
|
2020-06-20 17:54:21 +08:00
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
recommendedGzipSettings = true;
|
2023-04-05 13:37:11 +08:00
|
|
|
recommendedTlsSettings = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
virtualHosts = let
|
|
|
|
mainWebsite = {
|
|
|
|
addSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
root = "${hydraWwwOutputs}/web";
|
|
|
|
extraConfig = ''
|
|
|
|
error_page 404 /404.html;
|
|
|
|
'';
|
|
|
|
locations."^~ /fonts/".extraConfig = ''
|
|
|
|
expires 60d;
|
|
|
|
'';
|
|
|
|
locations."^~ /js/".extraConfig = ''
|
|
|
|
expires 60d;
|
|
|
|
'';
|
|
|
|
locations."/MathJax/" = {
|
|
|
|
alias = "/var/www/MathJax/";
|
|
|
|
extraConfig = ''
|
|
|
|
expires 60d;
|
|
|
|
'';
|
|
|
|
};
|
2024-10-30 14:53:56 +08:00
|
|
|
locations."/nuc-netboot/".alias = "${import ./defenestrate { prioNixbld = true; } }/";
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
# legacy URLs, redirect to avoid breaking people's bookmarks
|
|
|
|
locations."/gateware.html".extraConfig = ''
|
|
|
|
return 301 /gateware/migen/;
|
|
|
|
'';
|
|
|
|
locations."/migen".extraConfig = ''
|
|
|
|
return 301 /gateware/migen/;
|
|
|
|
'';
|
|
|
|
locations."/artiq".extraConfig = ''
|
|
|
|
return 301 /experiment-control/artiq/;
|
|
|
|
'';
|
|
|
|
locations."/artiq/resources.html".extraConfig = ''
|
|
|
|
return 301 /experiment-control/resources/;
|
|
|
|
'';
|
|
|
|
|
|
|
|
# autogenerated manuals
|
|
|
|
locations."/artiq/sipyco-manual/" = {
|
2022-02-12 11:07:08 +08:00
|
|
|
alias = "${hydraWwwOutputs}/sipyco-manual-html/";
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
locations."=/artiq/sipyco-manual.pdf" = {
|
2022-02-12 11:07:08 +08:00
|
|
|
alias = "${hydraWwwOutputs}/sipyco-manual-pdf/SiPyCo.pdf";
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
locations."/artiq/manual-beta/" = {
|
2022-02-12 10:19:15 +08:00
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-html-beta/";
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
locations."=/artiq/manual-beta.pdf" = {
|
2022-02-12 10:19:15 +08:00
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-pdf-beta/ARTIQ.pdf";
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
locations."/artiq/manual/" = {
|
2022-07-08 19:00:38 +08:00
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-html/";
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
locations."=/artiq/manual.pdf" = {
|
2022-07-08 19:00:38 +08:00
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-pdf/ARTIQ.pdf";
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
2021-02-17 16:09:20 +08:00
|
|
|
locations."/artiq/manual-legacy/" = {
|
2024-06-05 11:23:24 +08:00
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-html-legacy/";
|
2021-02-17 16:09:20 +08:00
|
|
|
};
|
|
|
|
locations."=/artiq/manual-legacy.pdf" = {
|
2024-06-05 11:23:24 +08:00
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-pdf-legacy/ARTIQ.pdf";
|
2021-02-17 16:09:20 +08:00
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
|
|
# legacy content
|
|
|
|
locations."/migen/manual/" = {
|
|
|
|
alias = "/var/www/m-labs.hk.old/migen/manual/";
|
|
|
|
};
|
|
|
|
locations."/artiq/manual-release-4/" = {
|
|
|
|
alias = "/var/www/m-labs.hk.old/artiq/manual-release-4/";
|
|
|
|
};
|
|
|
|
locations."/artiq/manual-release-3/" = {
|
|
|
|
alias = "/var/www/m-labs.hk.old/artiq/manual-release-3/";
|
|
|
|
};
|
|
|
|
locations."/artiq/manual-release-2/" = {
|
|
|
|
alias = "/var/www/m-labs.hk.old/artiq/manual-release-2/";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
"m-labs.hk" = mainWebsite;
|
|
|
|
"www.m-labs.hk" = mainWebsite;
|
2023-03-23 15:22:16 +08:00
|
|
|
"m-labs.ph" = mainWebsite;
|
|
|
|
"www.m-labs.ph" = mainWebsite;
|
2020-06-20 17:54:21 +08:00
|
|
|
"nixbld.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
locations."/".proxyPass = "http://127.0.0.1:3000";
|
|
|
|
};
|
2022-11-03 19:09:35 +08:00
|
|
|
"msys2.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
locations."/artiq-beta/" = {
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-msys2-repos-beta/";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
'';
|
|
|
|
};
|
2024-06-05 11:23:24 +08:00
|
|
|
locations."/artiq/" = {
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-msys2-repos/";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
'';
|
|
|
|
};
|
2022-11-03 19:09:35 +08:00
|
|
|
locations."/artiq-nac3/" = {
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-msys2-repos-nac3/";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
"conda.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
locations."/artiq-beta/" = {
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-conda-channel-beta/";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
index bogus_index_file;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
locations."/artiq/" = {
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-conda-channel/";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
index bogus_index_file;
|
|
|
|
'';
|
|
|
|
};
|
2021-02-17 16:09:20 +08:00
|
|
|
locations."/artiq-legacy/" = {
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-conda-channel-legacy/";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
index bogus_index_file;
|
|
|
|
'';
|
|
|
|
};
|
2021-08-10 19:08:25 +08:00
|
|
|
locations."/artiq-archives/" = {
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-conda-channel-archives/";
|
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
index bogus_index_file;
|
|
|
|
'';
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
2023-04-05 13:37:35 +08:00
|
|
|
"afws.m-labs.hk" = {
|
2023-04-07 14:39:05 +08:00
|
|
|
enableACME = true;
|
2023-04-07 16:02:07 +08:00
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://localhost:3771";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
extraConfig =
|
|
|
|
''
|
|
|
|
proxy_read_timeout 2h;
|
|
|
|
'';
|
|
|
|
};
|
2023-04-05 13:37:35 +08:00
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
"git.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
locations."/".proxyPass = "http://127.0.0.1:3001";
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 300M;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
"chat.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
locations."/".proxyPass = "http://127.0.0.1:8065";
|
|
|
|
locations."~ /api/v[0-9]+/(users/)?websocket$".proxyPass = "http://127.0.0.1:8065";
|
|
|
|
locations."~ /api/v[0-9]+/(users/)?websocket$".proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
"hooks.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
locations."/mattermost-github".extraConfig = ''
|
|
|
|
include ${pkgs.nginx}/conf/uwsgi_params;
|
|
|
|
uwsgi_pass unix:${config.services.uwsgi.runDir}/uwsgi-mgi.sock;
|
|
|
|
'';
|
|
|
|
locations."/rfq".extraConfig = ''
|
|
|
|
include ${pkgs.nginx}/conf/uwsgi_params;
|
|
|
|
uwsgi_pass unix:${config.services.uwsgi.runDir}/uwsgi-rfq.sock;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
"forum.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
"perso.m-labs.hk" = {
|
|
|
|
addSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
root = "/var/www/perso";
|
2024-05-06 09:48:16 +08:00
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
'';
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
2021-08-10 21:28:14 +08:00
|
|
|
"rt.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2021-08-11 10:54:12 +08:00
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:4201";
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 100M;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
locations."/REST/1.0/NoAuth" = {
|
|
|
|
proxyPass = "http://127.0.0.1:4201";
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 100M;
|
|
|
|
allow 127.0.0.1;
|
|
|
|
deny all;
|
|
|
|
'';
|
|
|
|
};
|
2021-08-10 21:28:14 +08:00
|
|
|
};
|
2022-06-30 17:33:09 +08:00
|
|
|
"files.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
};
|
2022-09-01 11:39:47 +08:00
|
|
|
"docs.m-labs.hk" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
2022-12-03 16:29:32 +08:00
|
|
|
locations."/".proxyPass = "http://localhost:9825";
|
|
|
|
locations."/socket.io/".proxyPass = "http://localhost:9825";
|
2022-09-01 11:39:47 +08:00
|
|
|
locations."/socket.io/".proxyWebsockets = true;
|
|
|
|
};
|
2023-09-05 22:04:27 +08:00
|
|
|
"193thz.com" = {
|
|
|
|
addSSL = true;
|
|
|
|
enableACME = true;
|
2023-09-06 18:39:17 +08:00
|
|
|
root = "/var/www/193thz";
|
2023-09-05 22:04:27 +08:00
|
|
|
};
|
|
|
|
"www.193thz.com" = {
|
|
|
|
addSSL = true;
|
|
|
|
enableACME = true;
|
2023-09-06 18:39:17 +08:00
|
|
|
root = "/var/www/193thz";
|
2023-09-05 22:04:27 +08:00
|
|
|
};
|
2022-09-27 11:07:13 +08:00
|
|
|
"nmigen.net" = {
|
2020-06-20 17:54:21 +08:00
|
|
|
addSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2022-09-27 11:07:13 +08:00
|
|
|
root = "${hydraWwwOutputs}/nmigen-docs";
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
2022-09-27 11:07:13 +08:00
|
|
|
"www.nmigen.net" = {
|
2020-06-20 17:54:21 +08:00
|
|
|
addSSL = true;
|
2022-07-04 16:22:40 +08:00
|
|
|
enableACME = true;
|
2022-09-27 11:07:13 +08:00
|
|
|
root = "${hydraWwwOutputs}/nmigen-docs";
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
services.uwsgi = {
|
|
|
|
enable = true;
|
|
|
|
plugins = [ "python3" ];
|
|
|
|
instance = {
|
|
|
|
type = "emperor";
|
|
|
|
vassals = {
|
|
|
|
mattermostgithub = import ./mattermost-github-integration/uwsgi-config.nix { inherit config pkgs; };
|
|
|
|
rfq = import ./rfq/uwsgi-config.nix { inherit config pkgs; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-08-31 17:27:16 +08:00
|
|
|
|
2020-06-20 17:54:21 +08:00
|
|
|
services.mysql = {
|
|
|
|
enable = true;
|
2024-08-31 17:27:16 +08:00
|
|
|
package = pkgs.lib.mkForce pkgs.mariadb;
|
|
|
|
ensureDatabases = pkgs.lib.mkForce [];
|
|
|
|
ensureUsers = pkgs.lib.mkForce [];
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
2024-08-31 17:27:16 +08:00
|
|
|
services.flarum = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.callPackage ./flarum {};
|
|
|
|
domain = "forum.m-labs.hk";
|
2020-06-20 17:54:21 +08:00
|
|
|
};
|
|
|
|
|
2021-08-10 21:28:14 +08:00
|
|
|
services.rt = {
|
|
|
|
enable = true;
|
2021-08-12 13:39:35 +08:00
|
|
|
package = pkgs.rt.overrideAttrs(oa: {
|
|
|
|
patches = oa.patches or [] ++ [ ./rt-session.patch ];
|
|
|
|
});
|
2021-08-10 21:28:14 +08:00
|
|
|
organization = "M-Labs";
|
|
|
|
domain = "rt.m-labs.hk";
|
|
|
|
rtName = "Helpdesk";
|
|
|
|
ownerEmail = "sb" + "@m-labs.hk";
|
|
|
|
commentAddress = "helpdesk" + "@m-labs.hk";
|
|
|
|
correspondAddress = "helpdesk" + "@m-labs.hk";
|
2021-08-11 10:54:24 +08:00
|
|
|
sendmailPath = "${pkgs.msmtp}/bin/msmtp";
|
|
|
|
sendmailArguments = ["-t" "-C" "/etc/nixos/secret/rt_msmtp.conf"];
|
2021-08-10 21:28:14 +08:00
|
|
|
};
|
2021-08-11 11:57:05 +08:00
|
|
|
systemd.services.rt-fetchmail = {
|
|
|
|
description = "Fetchmail for RT";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2023-01-04 11:54:30 +08:00
|
|
|
after = [ "dovecot2.service" ];
|
2021-08-11 11:57:05 +08:00
|
|
|
serviceConfig = {
|
|
|
|
Restart = "on-failure";
|
|
|
|
User = "rt";
|
|
|
|
Group = "rt";
|
2024-10-24 15:49:41 +08:00
|
|
|
ExecStart = "${pkgs.bash}/bin/bash -c 'PATH=${pkgs.rt}/bin HOME=/tmp ${pkgs.fetchmail}/bin/fetchmail --pidfile /tmp/.fetchmail.pid -f /etc/nixos/secret/rt_fetchmailrc'";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
systemd.services.rt-fetchmail-intl = {
|
|
|
|
description = "Fetchmail for RT (intl)";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "dovecot2.service" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Restart = "on-failure";
|
|
|
|
User = "rt";
|
|
|
|
Group = "rt";
|
|
|
|
ExecStart = "${pkgs.bash}/bin/bash -c 'PATH=${pkgs.rt}/bin HOME=/tmp ${pkgs.fetchmail}/bin/fetchmail --pidfile /tmp/.fetchmail-intl.pid -f /etc/nixos/secret/rt_fetchmailrc_intl'";
|
2021-08-11 11:57:05 +08:00
|
|
|
};
|
|
|
|
};
|
2021-08-10 21:28:14 +08:00
|
|
|
|
2022-06-18 13:58:51 +08:00
|
|
|
mailserver = {
|
|
|
|
enable = true;
|
|
|
|
localDnsResolver = false; # conflicts with dnsmasq
|
2022-06-27 18:17:30 +08:00
|
|
|
fqdn = "mail.m-labs.hk";
|
2024-08-14 11:38:19 +08:00
|
|
|
domains = [ "m-labs.hk" "m-labs.ph" "m-labs-intl.com" "193thz.com" "malloctech.fr" ];
|
2022-12-25 11:07:02 +08:00
|
|
|
enablePop3 = true;
|
|
|
|
enablePop3Ssl = true;
|
2023-06-13 10:54:20 +08:00
|
|
|
certificateScheme = "acme-nginx";
|
2022-08-09 17:45:26 +08:00
|
|
|
} // (import /etc/nixos/secret/email_settings.nix);
|
2024-10-17 15:04:32 +08:00
|
|
|
services.postfix = {
|
|
|
|
mapFiles."sender_transport" = builtins.toFile "sender_transport" ''
|
|
|
|
@m-labs-intl.com intltunnel:
|
|
|
|
'';
|
|
|
|
config = {
|
|
|
|
sender_dependent_default_transport_maps = "hash:/var/lib/postfix/conf/sender_transport";
|
|
|
|
};
|
|
|
|
masterConfig."intltunnel" = {
|
|
|
|
type = "unix";
|
|
|
|
command = "smtp";
|
|
|
|
args = [
|
|
|
|
"-o" "inet_interfaces=10.47.3.1"
|
|
|
|
"-o" "smtp_helo_name=mail.m-labs-intl.com"
|
|
|
|
"-o" "inet_protocols=ipv4"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2022-08-09 17:45:26 +08:00
|
|
|
services.roundcube = {
|
|
|
|
enable = true;
|
|
|
|
hostName = "mail.m-labs.hk";
|
|
|
|
extraConfig = ''
|
|
|
|
$config['smtp_server'] = "tls://${config.mailserver.fqdn}";
|
|
|
|
$config['smtp_user'] = "%u";
|
|
|
|
$config['smtp_pass'] = "%p";
|
|
|
|
'';
|
2022-06-18 13:58:51 +08:00
|
|
|
};
|
|
|
|
|
2022-06-30 17:33:09 +08:00
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
2024-10-16 11:33:07 +08:00
|
|
|
package = pkgs.nextcloud30;
|
2024-10-15 16:22:33 +08:00
|
|
|
extraApps = { inherit (config.services.nextcloud.package.packages.apps) forms; };
|
2022-06-30 17:33:09 +08:00
|
|
|
hostName = "files.m-labs.hk";
|
|
|
|
https = true;
|
2023-05-30 21:34:36 +08:00
|
|
|
maxUploadSize = "2G";
|
2022-06-30 17:33:09 +08:00
|
|
|
config.adminpassFile = "/etc/nixos/secret/nextcloud_pass.txt";
|
2024-06-02 12:52:17 +08:00
|
|
|
settings.default_phone_region = "HK";
|
|
|
|
settings.log_type = "file";
|
2024-05-24 09:49:17 +08:00
|
|
|
phpOptions."opcache.interned_strings_buffer" = "12";
|
2022-06-30 17:33:09 +08:00
|
|
|
};
|
|
|
|
|
2022-09-01 11:39:47 +08:00
|
|
|
services.hedgedoc = {
|
|
|
|
enable = true;
|
2022-12-03 16:29:32 +08:00
|
|
|
settings = {
|
|
|
|
port = 9825;
|
|
|
|
domain = "docs.m-labs.hk";
|
|
|
|
protocolUseSSL = true;
|
|
|
|
allowEmailRegister = false;
|
|
|
|
allowAnonymous = false;
|
|
|
|
db = {
|
|
|
|
dialect = "sqlite";
|
|
|
|
storage = "/var/lib/hedgedoc/db.hedgedoc.sqlite";
|
|
|
|
};
|
2022-09-01 11:39:47 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-08-07 13:19:47 +08:00
|
|
|
system.stateVersion = "21.05";
|
2020-06-20 17:54:21 +08:00
|
|
|
}
|