2020-06-20 17:54:21 +08:00
|
|
|
|
# Edit this configuration file to define what should be installed on
|
|
|
|
|
# your system. Help is available in the configuration.nix(5) man page
|
|
|
|
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
|
|
|
|
|
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
let
|
2021-08-07 12:24:00 +08:00
|
|
|
|
netifWan = "enp4s0";
|
|
|
|
|
netifLan = "enp5s0f1";
|
2021-08-09 13:32:18 +08:00
|
|
|
|
netifWifi = "wlp6s0";
|
2020-06-20 17:54:21 +08:00
|
|
|
|
netifSit = "henet0";
|
|
|
|
|
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
|
2021-08-10 21:28:14 +08:00
|
|
|
|
./rt.nix
|
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;
|
|
|
|
|
boot.loader.grub.memtest86.enable = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
2020-07-26 22:21:31 +08:00
|
|
|
|
boot.supportedFilesystems = ["zfs"];
|
2021-08-07 12:24:00 +08:00
|
|
|
|
boot.kernelParams = ["zfs.l2arc_write_max=536870912"];
|
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
|
|
|
|
|
|
|
|
|
security.apparmor.enable = true;
|
|
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
|
hostName = "nixbld";
|
2021-08-07 12:24:00 +08:00
|
|
|
|
hostId = "e423f012";
|
2020-06-20 17:54:21 +08:00
|
|
|
|
firewall = {
|
|
|
|
|
allowedTCPPorts = [ 80 443 ];
|
|
|
|
|
allowedUDPPorts = [ 53 67 ];
|
|
|
|
|
trustedInterfaces = [ netifLan ];
|
|
|
|
|
};
|
2021-08-07 12:24:00 +08:00
|
|
|
|
interfaces."${netifWan}".useDHCP = true;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
interfaces."${netifLan}" = {
|
|
|
|
|
ipv4.addresses = [{
|
|
|
|
|
address = "192.168.1.1";
|
|
|
|
|
prefixLength = 24;
|
|
|
|
|
}];
|
|
|
|
|
ipv6.addresses = [{
|
|
|
|
|
address = "2001:470:f821:1::";
|
|
|
|
|
prefixLength = 64;
|
|
|
|
|
}];
|
2021-03-04 15:54:41 +08:00
|
|
|
|
ipv4.routes = [{
|
|
|
|
|
address = "192.168.13.0";
|
|
|
|
|
prefixLength = 24;
|
2021-03-05 18:42:54 +08:00
|
|
|
|
via = "192.168.1.30";
|
2021-03-04 15:54:41 +08:00
|
|
|
|
}];
|
|
|
|
|
ipv6.routes = [{
|
|
|
|
|
address = "2001:470:f821:3::";
|
|
|
|
|
prefixLength = 64;
|
|
|
|
|
via = "2001:470:f821:1:dea6:32ff:fe95:2fcf";
|
|
|
|
|
}];
|
2020-06-20 17:54:21 +08:00
|
|
|
|
};
|
|
|
|
|
interfaces."${netifWifi}" = {
|
|
|
|
|
ipv4.addresses = [{
|
|
|
|
|
address = "192.168.12.1";
|
|
|
|
|
prefixLength = 24;
|
|
|
|
|
}];
|
|
|
|
|
ipv6.addresses = [{
|
|
|
|
|
address = "2001:470:f821:2::";
|
|
|
|
|
prefixLength = 64;
|
|
|
|
|
}];
|
|
|
|
|
};
|
|
|
|
|
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 = ''
|
|
|
|
|
iptables -w -N block-lan-from-wifi
|
|
|
|
|
iptables -w -A block-lan-from-wifi -i ${netifLan} -o ${netifWifi} -j DROP
|
|
|
|
|
iptables -w -A block-lan-from-wifi -i ${netifWifi} -o ${netifLan} -j DROP
|
|
|
|
|
iptables -w -A FORWARD -j block-lan-from-wifi
|
|
|
|
|
'';
|
|
|
|
|
extraStopCommands = ''
|
|
|
|
|
iptables -w -D FORWARD -j block-lan-from-wifi 2>/dev/null|| true
|
|
|
|
|
iptables -w -F block-lan-from-wifi 2>/dev/null|| true
|
|
|
|
|
iptables -w -X block-lan-from-wifi 2>/dev/null|| true
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
sits."${netifSit}" = {
|
|
|
|
|
dev = netifWan;
|
|
|
|
|
remote = "216.218.221.6";
|
|
|
|
|
local = "42.200.147.171";
|
|
|
|
|
ttl = 255;
|
|
|
|
|
};
|
|
|
|
|
interfaces."${netifSit}".ipv6 = {
|
|
|
|
|
addresses = [{ address = "2001:470:18:629::2"; prefixLength = 64; }];
|
|
|
|
|
routes = [{ address = "::"; prefixLength = 0; }];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
services.unbound = {
|
|
|
|
|
enable = true;
|
2021-06-07 09:56:05 +08:00
|
|
|
|
settings = {
|
|
|
|
|
server = {
|
|
|
|
|
port = 5353;
|
|
|
|
|
};
|
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.hostapd = {
|
|
|
|
|
enable = true;
|
|
|
|
|
interface = netifWifi;
|
|
|
|
|
hwMode = "g";
|
|
|
|
|
ssid = "M-Labs";
|
|
|
|
|
wpaPassphrase = (import /etc/nixos/secret/wifi_password.nix);
|
|
|
|
|
extraConfig = ''
|
|
|
|
|
ieee80211d=1
|
|
|
|
|
country_code=HK
|
|
|
|
|
ieee80211n=1
|
|
|
|
|
wmm_enabled=1
|
|
|
|
|
auth_algs=1
|
|
|
|
|
wpa_key_mgmt=WPA-PSK
|
|
|
|
|
rsn_pairwise=CCMP
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
services.dnsmasq = {
|
|
|
|
|
enable = true;
|
|
|
|
|
servers = ["::1#5353"];
|
|
|
|
|
extraConfig = ''
|
|
|
|
|
interface=${netifLan}
|
|
|
|
|
interface=${netifWifi}
|
|
|
|
|
bind-interfaces
|
|
|
|
|
dhcp-range=interface:${netifLan},192.168.1.81,192.168.1.254,24h
|
|
|
|
|
dhcp-range=interface:${netifWifi},192.168.12.10,192.168.12.254,24h
|
|
|
|
|
enable-ra
|
|
|
|
|
dhcp-range=interface:${netifLan},::,constructor:${netifLan},ra-names
|
|
|
|
|
dhcp-range=interface:${netifWifi},::,constructor:${netifWifi},ra-only
|
|
|
|
|
|
|
|
|
|
no-resolv
|
|
|
|
|
|
2020-10-14 12:53:51 +08:00
|
|
|
|
# Static IPv4s to make Red Pitayas with factory firmware less annoying
|
2020-06-20 17:54:21 +08:00
|
|
|
|
dhcp-host=rp-f05cc9,192.168.1.190
|
|
|
|
|
dhcp-host=rp-f0612e,192.168.1.191
|
|
|
|
|
# Static IPv4s to make port redirections work
|
|
|
|
|
dhcp-host=rpi-1,192.168.1.201
|
|
|
|
|
dhcp-host=rpi-2,192.168.1.202
|
|
|
|
|
dhcp-host=rpi-3,192.168.1.203
|
|
|
|
|
dhcp-host=rpi-4,192.168.1.204
|
|
|
|
|
|
2020-06-24 11:06:35 +08:00
|
|
|
|
# Static IP addresses for non-DHCP boards
|
2021-03-05 18:42:54 +08:00
|
|
|
|
address=/rpi-ext/192.168.1.30
|
|
|
|
|
address=/rpi-ext/2001:470:f821:1:dea6:32ff:fe95:2fcf
|
|
|
|
|
|
2020-06-20 17:54:21 +08:00
|
|
|
|
address=/thermostat/192.168.1.26
|
2020-06-24 11:06:35 +08:00
|
|
|
|
address=/powercycler/192.168.1.31
|
2020-06-20 17:54:21 +08:00
|
|
|
|
address=/kc705/192.168.1.50
|
2020-06-24 11:06:35 +08:00
|
|
|
|
address=/zynq-experiments/192.168.1.51
|
|
|
|
|
address=/zc706/192.168.1.52
|
|
|
|
|
address=/zc706-2/192.168.1.53
|
2020-10-14 12:53:51 +08:00
|
|
|
|
address=/cora-z7/192.168.1.54
|
|
|
|
|
address=/rust-pitaya/192.168.1.55
|
2020-06-20 17:54:21 +08:00
|
|
|
|
address=/sayma/192.168.1.60
|
|
|
|
|
address=/metlino/192.168.1.65
|
|
|
|
|
address=/kasli/192.168.1.70
|
|
|
|
|
address=/kasli-customer/192.168.1.75
|
|
|
|
|
address=/stabilizer-customer/192.168.1.76
|
2021-03-05 18:42:54 +08:00
|
|
|
|
|
2020-06-20 17:54:21 +08:00
|
|
|
|
# uTCA MCH from NAT
|
|
|
|
|
address=/tschernobyl/192.168.1.80
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# 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; [
|
|
|
|
|
wget vim git file lm_sensors acpi pciutils psmisc telnet nixops
|
|
|
|
|
irssi tmux usbutils imagemagick jq zip unzip
|
2021-08-09 13:32:37 +08:00
|
|
|
|
iw
|
|
|
|
|
nvme-cli
|
2021-09-18 16:35:25 +08:00
|
|
|
|
borgbackup
|
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;
|
|
|
|
|
services.openssh.forwardX11 = true;
|
|
|
|
|
services.openssh.passwordAuthentication = false;
|
|
|
|
|
programs.mosh.enable = true;
|
|
|
|
|
|
|
|
|
|
programs.fish.enable = true;
|
|
|
|
|
|
|
|
|
|
# Enable CUPS to print documents.
|
|
|
|
|
services.avahi.enable = true;
|
|
|
|
|
services.avahi.interfaces = [ netifLan ];
|
|
|
|
|
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 ];
|
|
|
|
|
|
2020-10-27 14:57:07 +08:00
|
|
|
|
users.extraGroups.hkadmin = { };
|
2020-06-20 17:54:21 +08:00
|
|
|
|
users.extraUsers.sb = {
|
|
|
|
|
isNormalUser = true;
|
2020-10-27 14:57:07 +08:00
|
|
|
|
extraGroups = ["wheel" "hkadmin" "lp" "scanner"];
|
2020-06-20 17:54:21 +08:00
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyPk5WyFoWSvF4ozehxcVBoZ+UHgrI7VW/OoQfFFwIQe0qvetUZBMZwR2FwkLPAMZV8zz1v4EfncudEkVghy4P+/YVLlDjqDq9zwZnh8Nd/ifu84wmcNWHT2UcqnhjniCdshL8a44memzABnxfLLv+sXhP2x32cJAamo5y6fukr2qLp2jbXzR+3sv3klE0ruUXis/BR1lLqNJEYP8jB6fLn2sLKinnZPfn6DwVOk10mGeQsdME/eGl3phpjhODH9JW5V2V5nJBbC0rBnq+78dyArKVqjPSmIcSy72DEIpTctnMEN1W34BGrnsDd5Xd/DKxKxHKTMCHtZRwLC2X0NWN"
|
|
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCMALVC8RDTHec+PC8y1s3tcpUAODgq6DEzQdHDf/cyvDMfmCaPiMxfIdmkns5lMa03hymIfSmLUF0jFFDc7biRp7uf9AAXNsrTmplHii0l0McuOOZGlSdZM4eL817P7UwJqFMxJyFXDjkubhQiX6kp25Kfuj/zLnupRCaiDvE7ho/xay6Jrv0XLz935TPDwkc7W1asLIvsZLheB+sRz9SMOb9gtrvk5WXZl5JTOFOLu+JaRwQLHL/xdcHJTOod7tqHYfpoC5JHrEwKzbhTOwxZBQBfTQjQktKENQtBxXHTe71rUEWfEZQGg60/BC4BrRmh4qJjlJu3v4VIhC7SSHn1"
|
|
|
|
|
];
|
2020-10-27 14:57:07 +08:00
|
|
|
|
shell = pkgs.fish;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
};
|
|
|
|
|
users.extraUsers.rj = {
|
|
|
|
|
isNormalUser = true;
|
2020-10-27 14:57:07 +08:00
|
|
|
|
extraGroups = ["wheel"];
|
2020-06-20 17:54:21 +08:00
|
|
|
|
};
|
2021-11-16 14:21:56 +08:00
|
|
|
|
users.extraUsers.backupdl = {
|
|
|
|
|
isNormalUser = true;
|
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyPk5WyFoWSvF4ozehxcVBoZ+UHgrI7VW/OoQfFFwIQe0qvetUZBMZwR2FwkLPAMZV8zz1v4EfncudEkVghy4P+/YVLlDjqDq9zwZnh8Nd/ifu84wmcNWHT2UcqnhjniCdshL8a44memzABnxfLLv+sXhP2x32cJAamo5y6fukr2qLp2jbXzR+3sv3klE0ruUXis/BR1lLqNJEYP8jB6fLn2sLKinnZPfn6DwVOk10mGeQsdME/eGl3phpjhODH9JW5V2V5nJBbC0rBnq+78dyArKVqjPSmIcSy72DEIpTctnMEN1W34BGrnsDd5Xd/DKxKxHKTMCHtZRwLC2X0NWN"
|
|
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCMALVC8RDTHec+PC8y1s3tcpUAODgq6DEzQdHDf/cyvDMfmCaPiMxfIdmkns5lMa03hymIfSmLUF0jFFDc7biRp7uf9AAXNsrTmplHii0l0McuOOZGlSdZM4eL817P7UwJqFMxJyFXDjkubhQiX6kp25Kfuj/zLnupRCaiDvE7ho/xay6Jrv0XLz935TPDwkc7W1asLIvsZLheB+sRz9SMOb9gtrvk5WXZl5JTOFOLu+JaRwQLHL/xdcHJTOod7tqHYfpoC5JHrEwKzbhTOwxZBQBfTQjQktKENQtBxXHTe71rUEWfEZQGg60/BC4BrRmh4qJjlJu3v4VIhC7SSHn1"
|
|
|
|
|
];
|
|
|
|
|
};
|
2020-10-27 14:57:07 +08:00
|
|
|
|
users.extraUsers.harry = {
|
2020-06-20 17:54:21 +08:00
|
|
|
|
isNormalUser = true;
|
2020-10-27 14:57:07 +08:00
|
|
|
|
extraGroups = ["hkadmin" "lp" "scanner"];
|
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBDcPNCgtdz8erFPRrAwCr4JrkeYXJUUvoRBgP0X2HlzJgDe1Inuo6sC6CGcO3IXbf4MwVA9XEp8BYPHARVeEHhufg/0wnIABLx2GcK99yxOLDUe4h/3YwtqvOcqHEsDx7w=="
|
|
|
|
|
];
|
2020-06-20 17:54:21 +08:00
|
|
|
|
};
|
2021-11-11 12:12:46 +08:00
|
|
|
|
users.extraUsers.occheung = {
|
|
|
|
|
isNormalUser = true;
|
|
|
|
|
extraGroups = ["lp" "scanner"];
|
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
|
"ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBPEvmWmxpFpMgp5fpjKud8ev0cyf/+X5fEpQt/YD/+u4mbvZYPE300DLqQ0h/qjgvaGMz1ndf4idYnRdy+plJEC/+hmlRW5NlcpAr3S/LYAisacgKToFVl+MlBo+emS9Ig=="
|
|
|
|
|
];
|
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
|
users.extraUsers.nix = {
|
|
|
|
|
isNormalUser = true;
|
|
|
|
|
};
|
|
|
|
|
security.sudo.wheelNeedsPassword = false;
|
|
|
|
|
boot.kernel.sysctl."kernel.dmesg_restrict" = true;
|
|
|
|
|
services.udev.packages = [ pkgs.sane-backends ];
|
|
|
|
|
|
|
|
|
|
nix.distributedBuilds = true;
|
2021-08-07 12:24:00 +08:00
|
|
|
|
nix.nrBuildUsers = 64;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
nix.buildMachines = [
|
|
|
|
|
{
|
|
|
|
|
hostName = "localhost";
|
2021-08-07 12:24:00 +08:00
|
|
|
|
maxJobs = 10;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
system = "x86_64-linux";
|
|
|
|
|
supportedFeatures = ["big-parallel"];
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
hostName = "rpi-3";
|
|
|
|
|
sshUser = "nix";
|
|
|
|
|
sshKey = "/etc/nixos/secret/nix_id_rsa";
|
|
|
|
|
maxJobs = 1;
|
|
|
|
|
system = "aarch64-linux";
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
services.hydra = {
|
|
|
|
|
enable = true;
|
|
|
|
|
package = pkgs.hydra-unstable;
|
|
|
|
|
useSubstitutes = true;
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full:sipyco-manual-html
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/sipyco-manual-html
|
|
|
|
|
</runcommand>
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full:sipyco-manual-latexpdf
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/sipyco-manual-latexpdf
|
|
|
|
|
</runcommand>
|
|
|
|
|
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full-beta:artiq-manual-html
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-html-beta
|
|
|
|
|
</runcommand>
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full-beta:artiq-manual-latexpdf
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-latexpdf-beta
|
|
|
|
|
</runcommand>
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full-beta:conda-channel
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-conda-channel-beta
|
|
|
|
|
</runcommand>
|
|
|
|
|
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full:artiq-manual-html
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-html
|
|
|
|
|
</runcommand>
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full:artiq-manual-latexpdf
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-latexpdf
|
|
|
|
|
</runcommand>
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full:conda-channel
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-conda-channel
|
|
|
|
|
</runcommand>
|
2020-09-03 01:53:33 +08:00
|
|
|
|
|
2021-02-17 16:09:20 +08:00
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full-legacy:artiq-manual-html
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-html-legacy
|
|
|
|
|
</runcommand>
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full-legacy:artiq-manual-latexpdf
|
|
|
|
|
command = [ $(jq '.buildStatus' < $HYDRA_JSON) = 0 ] && ln -sfn $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-latexpdf-legacy
|
|
|
|
|
</runcommand>
|
|
|
|
|
<runcommand>
|
|
|
|
|
job = artiq:full-legacy:conda-channel
|
|
|
|
|
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>
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nix.extraOptions = ''
|
|
|
|
|
secret-key-files = /etc/nixos/secret/nixbld.m-labs.hk-1
|
|
|
|
|
'';
|
|
|
|
|
nix.sandboxPaths = ["/opt"];
|
|
|
|
|
|
|
|
|
|
services.munin-node.enable = true;
|
|
|
|
|
services.munin-cron = {
|
|
|
|
|
enable = true;
|
|
|
|
|
hosts = ''
|
|
|
|
|
[${config.networking.hostName}]
|
|
|
|
|
address localhost
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
httpPort = 3001;
|
|
|
|
|
rootUrl = "https://git.m-labs.hk/";
|
|
|
|
|
appName = "M-Labs Git";
|
|
|
|
|
cookieSecure = true;
|
|
|
|
|
disableRegistration = true;
|
|
|
|
|
mailerPasswordFile = "/etc/nixos/secret/mailerpassword";
|
2020-10-31 17:30:46 +08:00
|
|
|
|
settings = {
|
|
|
|
|
indexer = {
|
|
|
|
|
REPO_INDEXER_ENABLED = true;
|
|
|
|
|
};
|
2020-08-31 17:39:28 +08:00
|
|
|
|
|
2020-10-31 17:30:46 +08:00
|
|
|
|
mailer = {
|
|
|
|
|
ENABLED = true;
|
|
|
|
|
HOST = "ssl.serverraum.org:587";
|
|
|
|
|
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;
|
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
|
|
2020-10-31 17:30:46 +08:00
|
|
|
|
attachment = {
|
|
|
|
|
ALLOWED_TYPES = "*/*";
|
|
|
|
|
};
|
|
|
|
|
};
|
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;
|
|
|
|
|
};
|
2021-06-07 09:56:05 +08:00
|
|
|
|
services.postgresql.package = pkgs.postgresql_11;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
services.matterbridge = {
|
|
|
|
|
enable = true;
|
|
|
|
|
configPath = "/etc/nixos/secret/matterbridge.toml";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nixpkgs.config.packageOverrides = super: let self = super.pkgs; in {
|
2020-07-04 16:02:30 +08:00
|
|
|
|
nix = super.nix.overrideAttrs(oa: {
|
|
|
|
|
patches = oa.patches or [] ++ [ ./nix-networked-derivations.diff ];
|
|
|
|
|
});
|
|
|
|
|
nixFlakes = super.nixFlakes.overrideAttrs(oa: {
|
2020-10-06 06:45:56 +08:00
|
|
|
|
patches = oa.patches or [] ++ [ ./nix-3-networked-derivations.patch ];
|
2020-07-04 16:02:30 +08:00
|
|
|
|
});
|
2020-06-20 17:54:21 +08:00
|
|
|
|
hydra-unstable = super.hydra-unstable.overrideAttrs(oa: {
|
2020-06-27 02:20:03 +08:00
|
|
|
|
patches = oa.patches or [] ++ [
|
|
|
|
|
./hydra-conda.patch
|
|
|
|
|
./hydra-restrictdist.patch
|
2021-09-01 19:59:23 +08:00
|
|
|
|
./hydra-hack-allowed-uris.patch # work around https://github.com/NixOS/nix/issues/5039
|
2020-06-27 02:20:03 +08:00
|
|
|
|
];
|
2020-06-20 17:54:21 +08:00
|
|
|
|
hydraPath = oa.hydraPath + ":" + super.lib.makeBinPath [ super.jq ];
|
|
|
|
|
});
|
|
|
|
|
matterbridge = super.matterbridge.overrideAttrs(oa: {
|
|
|
|
|
patches = oa.patches or [] ++ [ ./matterbridge-disable-github.patch ];
|
|
|
|
|
});
|
2021-01-11 16:19:30 +08:00
|
|
|
|
gitea = super.gitea.overrideAttrs(oa: {
|
|
|
|
|
preBuild = let tagsString = "pam sqlite sqlite_unlock_notify"; in ''
|
|
|
|
|
export buildFlagsArray=(
|
|
|
|
|
-tags="${tagsString}"
|
|
|
|
|
-ldflags='-X "main.Version=${oa.version}" -X "main.Tags=${tagsString}"'
|
|
|
|
|
)
|
|
|
|
|
'';
|
|
|
|
|
});
|
2020-06-20 17:54:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
security.acme.acceptTerms = true;
|
|
|
|
|
security.acme.email = "sb" + "@m-labs.hk";
|
|
|
|
|
security.acme.certs = {
|
|
|
|
|
"nixbld.m-labs.hk" = {
|
2020-11-06 14:58:35 +08:00
|
|
|
|
group = "nginx";
|
2020-06-20 17:54:21 +08:00
|
|
|
|
webroot = "/var/lib/acme/acme-challenge";
|
2020-10-31 17:30:46 +08:00
|
|
|
|
extraDomainNames = [
|
|
|
|
|
"m-labs.hk"
|
|
|
|
|
"www.m-labs.hk"
|
|
|
|
|
"conda.m-labs.hk"
|
|
|
|
|
"lab.m-labs.hk"
|
|
|
|
|
"git.m-labs.hk"
|
|
|
|
|
"chat.m-labs.hk"
|
|
|
|
|
"hooks.m-labs.hk"
|
|
|
|
|
"forum.m-labs.hk"
|
|
|
|
|
"perso.m-labs.hk"
|
|
|
|
|
"call.m-labs.hk"
|
2021-08-11 12:02:33 +08:00
|
|
|
|
"rt.m-labs.hk"
|
2020-10-31 17:30:46 +08:00
|
|
|
|
"nmigen.org"
|
|
|
|
|
"www.nmigen.org"
|
|
|
|
|
];
|
2020-06-20 17:54:21 +08:00
|
|
|
|
};
|
|
|
|
|
};
|
2020-12-21 13:04:24 +08:00
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/106862
|
|
|
|
|
systemd.services."acme-fixperms".wants = [ "unbound.service" "dnsmasq.service" ];
|
|
|
|
|
systemd.services."acme-fixperms".after = [ "unbound.service" "dnsmasq.service" ];
|
2020-06-20 17:54:21 +08:00
|
|
|
|
services.nginx = {
|
|
|
|
|
enable = true;
|
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
|
virtualHosts = let
|
|
|
|
|
mainWebsite = {
|
|
|
|
|
addSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
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;
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# 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/" = {
|
|
|
|
|
alias = "${hydraWwwOutputs}/sipyco-manual-html/share/doc/sipyco-manual/html/";
|
|
|
|
|
};
|
|
|
|
|
locations."=/artiq/sipyco-manual.pdf" = {
|
|
|
|
|
alias = "${hydraWwwOutputs}/sipyco-manual-latexpdf/share/doc/sipyco-manual/SiPyCo.pdf";
|
|
|
|
|
};
|
|
|
|
|
locations."/artiq/manual-beta/" = {
|
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-html-beta/share/doc/artiq-manual/html/";
|
|
|
|
|
};
|
|
|
|
|
locations."=/artiq/manual-beta.pdf" = {
|
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-latexpdf-beta/share/doc/artiq-manual/ARTIQ.pdf";
|
|
|
|
|
};
|
|
|
|
|
locations."/artiq/manual/" = {
|
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-html/share/doc/artiq-manual/html/";
|
|
|
|
|
};
|
|
|
|
|
locations."=/artiq/manual.pdf" = {
|
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-latexpdf/share/doc/artiq-manual/ARTIQ.pdf";
|
|
|
|
|
};
|
2021-02-17 16:09:20 +08:00
|
|
|
|
locations."/artiq/manual-legacy/" = {
|
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-html-legacy/share/doc/artiq-manual/html/";
|
|
|
|
|
};
|
|
|
|
|
locations."=/artiq/manual-legacy.pdf" = {
|
|
|
|
|
alias = "${hydraWwwOutputs}/artiq-manual-latexpdf-legacy/share/doc/artiq-manual/ARTIQ.pdf";
|
|
|
|
|
};
|
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;
|
|
|
|
|
"lab.m-labs.hk" = {
|
|
|
|
|
addSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
locations."/munin/".alias = "/var/www/munin/";
|
|
|
|
|
locations."/munin".extraConfig = ''
|
|
|
|
|
auth_basic "Munin";
|
|
|
|
|
auth_basic_user_file /etc/nixos/secret/muninpasswd;
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
"nixbld.m-labs.hk" = {
|
|
|
|
|
forceSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
locations."/".proxyPass = "http://127.0.0.1:3000";
|
|
|
|
|
};
|
|
|
|
|
"conda.m-labs.hk" = {
|
|
|
|
|
forceSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
"git.m-labs.hk" = {
|
|
|
|
|
forceSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
locations."/".proxyPass = "http://127.0.0.1:3001";
|
|
|
|
|
extraConfig = ''
|
|
|
|
|
client_max_body_size 300M;
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
"chat.m-labs.hk" = {
|
|
|
|
|
forceSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
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;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
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;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
2021-05-06 10:09:24 +08:00
|
|
|
|
root = "/var/www/flarum/public";
|
2020-06-20 17:54:21 +08:00
|
|
|
|
locations."~ \.php$".extraConfig = ''
|
|
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.flarum.socket};
|
|
|
|
|
fastcgi_index index.php;
|
|
|
|
|
'';
|
|
|
|
|
extraConfig = ''
|
|
|
|
|
index index.php;
|
2021-05-06 10:09:24 +08:00
|
|
|
|
include /var/www/flarum/.nginx.conf;
|
2020-06-20 17:54:21 +08:00
|
|
|
|
'';
|
|
|
|
|
};
|
2020-08-03 15:19:56 +08:00
|
|
|
|
"call.m-labs.hk" = {
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
2020-10-31 17:30:46 +08:00
|
|
|
|
enableACME = false;
|
2020-08-03 15:19:56 +08:00
|
|
|
|
forceSSL = true;
|
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
|
"perso.m-labs.hk" = {
|
|
|
|
|
addSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
root = "/var/www/perso";
|
|
|
|
|
};
|
2021-08-10 21:28:14 +08:00
|
|
|
|
"rt.m-labs.hk" = {
|
|
|
|
|
forceSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
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
|
|
|
|
};
|
2020-06-20 17:54:21 +08:00
|
|
|
|
"nmigen.org" = {
|
|
|
|
|
addSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
locations."/".extraConfig = ''
|
|
|
|
|
return 307 https://m-labs.hk/gateware/nmigen/;
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
"www.nmigen.org" = {
|
|
|
|
|
addSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
locations."/".extraConfig = ''
|
|
|
|
|
return 307 https://m-labs.hk/gateware/nmigen/;
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
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; };
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
services.mysql = {
|
|
|
|
|
enable = true;
|
|
|
|
|
package = pkgs.mariadb;
|
|
|
|
|
};
|
|
|
|
|
services.phpfpm.pools.flarum = {
|
2021-05-06 10:09:24 +08:00
|
|
|
|
user = "nobody";
|
2020-06-20 17:54:21 +08:00
|
|
|
|
settings = {
|
|
|
|
|
"listen.owner" = "nginx";
|
|
|
|
|
"listen.group" = "nginx";
|
|
|
|
|
"listen.mode" = "0600";
|
|
|
|
|
"pm" = "dynamic";
|
|
|
|
|
"pm.max_children" = 5;
|
|
|
|
|
"pm.start_servers" = 2;
|
|
|
|
|
"pm.min_spare_servers" = 1;
|
|
|
|
|
"pm.max_spare_servers" = 3;
|
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-03 15:19:56 +08:00
|
|
|
|
services.jitsi-meet = {
|
|
|
|
|
enable = true;
|
|
|
|
|
hostName = "call.m-labs.hk";
|
|
|
|
|
};
|
2020-08-03 15:32:06 +08:00
|
|
|
|
services.jitsi-videobridge.openFirewall = true;
|
2020-08-03 15:19:56 +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" ];
|
|
|
|
|
after = [ "network.target" ];
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
Restart = "on-failure";
|
|
|
|
|
User = "rt";
|
|
|
|
|
Group = "rt";
|
|
|
|
|
ExecStart = "${pkgs.bash}/bin/bash -c 'PATH=${pkgs.rt}/bin HOME=/tmp ${pkgs.fetchmail}/bin/fetchmail -f /etc/nixos/secret/rt_fetchmailrc'";
|
|
|
|
|
};
|
|
|
|
|
};
|
2021-08-10 21:28:14 +08:00
|
|
|
|
|
2021-08-07 13:19:47 +08:00
|
|
|
|
system.stateVersion = "21.05";
|
2020-06-20 17:54:21 +08:00
|
|
|
|
}
|