2019-02-16 00:33:08 +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, ... }:
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
imports =
|
|
|
|
|
[ # Include the results of the hardware scan.
|
|
|
|
|
./hardware-configuration.nix
|
2019-05-01 04:38:58 +08:00
|
|
|
|
./homu/nixos-module.nix
|
2019-02-16 00:33:08 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
# Use the systemd-boot EFI boot loader.
|
|
|
|
|
boot.loader.systemd-boot.enable = true;
|
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
|
|
|
|
|
|
networking.hostName = "nixbld"; # Define your hostname.
|
|
|
|
|
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
|
|
|
|
|
|
|
|
|
|
# Select internationalisation properties.
|
|
|
|
|
i18n = {
|
|
|
|
|
consoleFont = "Lat2-Terminus16";
|
|
|
|
|
consoleKeyMap = "de";
|
|
|
|
|
defaultLocale = "en_US.UTF-8";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# 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; [
|
2019-03-27 22:41:28 +08:00
|
|
|
|
wget vim git file lm_sensors acpi pciutils psmisc xc3sprog telnet whois zip unzip yosys symbiyosys yices z3 boolector cvc4
|
2019-04-18 19:48:42 +08:00
|
|
|
|
irssi tmux adoptopenjdk-openj9-bin-11 tigervnc xorg.xauth icewm xterm xorg.xsetroot usbutils virtmanager imagemagick jq
|
2019-02-16 00:33:08 +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; };
|
2019-04-21 10:44:08 +08:00
|
|
|
|
programs.wireshark.enable = true;
|
2019-02-16 00:33:08 +08:00
|
|
|
|
|
|
|
|
|
# List services that you want to enable:
|
|
|
|
|
|
|
|
|
|
# Enable the OpenSSH daemon.
|
|
|
|
|
services.openssh.enable = true;
|
2019-04-14 18:32:58 +08:00
|
|
|
|
services.openssh.forwardX11 = true;
|
2019-04-18 19:48:58 +08:00
|
|
|
|
programs.mosh.enable = true;
|
2019-02-16 00:33:08 +08:00
|
|
|
|
|
|
|
|
|
# Open ports in the firewall.
|
2019-03-28 00:15:40 +08:00
|
|
|
|
networking.firewall.allowedTCPPorts = [ 631 5901 80 443 ];
|
2019-02-16 00:33:08 +08:00
|
|
|
|
networking.firewall.allowedUDPPorts = [ 631 ];
|
|
|
|
|
# Or disable the firewall altogether.
|
|
|
|
|
# networking.firewall.enable = false;
|
|
|
|
|
|
|
|
|
|
# Enable CUPS to print documents.
|
|
|
|
|
services.avahi.enable = true;
|
|
|
|
|
services.avahi.publish.enable = true;
|
|
|
|
|
services.avahi.publish.userServices = 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 ];
|
|
|
|
|
|
|
|
|
|
users.extraGroups.plugdev = { };
|
|
|
|
|
users.extraUsers.sb = {
|
|
|
|
|
isNormalUser = true;
|
2019-04-21 10:44:08 +08:00
|
|
|
|
extraGroups = ["wheel" "plugdev" "dialout" "lp" "scanner" "wireshark"];
|
2019-05-02 16:09:44 +08:00
|
|
|
|
uid = 2000;
|
2019-02-16 00:33:08 +08:00
|
|
|
|
};
|
2019-04-18 19:49:02 +08:00
|
|
|
|
users.extraUsers.rj = {
|
|
|
|
|
isNormalUser = true;
|
2019-04-21 10:44:08 +08:00
|
|
|
|
extraGroups = ["wheel" "plugdev" "dialout" "wireshark"];
|
2019-05-02 16:09:44 +08:00
|
|
|
|
uid = 2002;
|
2019-04-18 19:49:02 +08:00
|
|
|
|
};
|
2019-04-21 10:44:14 +08:00
|
|
|
|
users.extraUsers.astro = {
|
|
|
|
|
isNormalUser = true;
|
|
|
|
|
extraGroups = ["plugdev" "dialout" "wireshark"];
|
2019-05-02 16:09:44 +08:00
|
|
|
|
uid = 2003;
|
2019-04-21 10:44:14 +08:00
|
|
|
|
};
|
2019-05-02 13:18:31 +08:00
|
|
|
|
users.extraUsers.whitequark = {
|
|
|
|
|
isNormalUser = true;
|
|
|
|
|
extraGroups = ["plugdev" "dialout"];
|
2019-05-02 16:09:44 +08:00
|
|
|
|
uid = 2004;
|
2019-05-02 13:18:31 +08:00
|
|
|
|
};
|
2019-04-08 23:45:30 +08:00
|
|
|
|
users.extraUsers.nix = {
|
|
|
|
|
isNormalUser = true;
|
2019-05-02 16:09:44 +08:00
|
|
|
|
uid = 2001;
|
2019-04-08 23:45:30 +08:00
|
|
|
|
};
|
2019-02-16 00:33:08 +08:00
|
|
|
|
security.sudo.wheelNeedsPassword = false;
|
2019-05-02 13:06:07 +08:00
|
|
|
|
security.hideProcessInformation = true;
|
|
|
|
|
boot.kernel.sysctl."kernel.dmesg_restrict" = true;
|
2019-02-16 00:33:08 +08:00
|
|
|
|
services.udev.packages = [ pkgs.openocd ];
|
|
|
|
|
services.udev.extraRules = ''
|
|
|
|
|
ACTION=="add", SUBSYSTEM=="tty", \
|
|
|
|
|
ENV{ID_SERIAL}=="FTDI_Quad_RS232-HS", \
|
|
|
|
|
ENV{ID_PATH}=="pci-0000:00:14.0-usb-0:5:1.1", \
|
|
|
|
|
SYMLINK+="ttyUSB_sayma-1_0"
|
|
|
|
|
ACTION=="add", SUBSYSTEM=="tty", \
|
|
|
|
|
ENV{ID_SERIAL}=="FTDI_Quad_RS232-HS", \
|
|
|
|
|
ENV{ID_PATH}=="pci-0000:00:14.0-usb-0:5:1.2", \
|
|
|
|
|
SYMLINK+="ttyUSB_sayma-1_1"
|
|
|
|
|
|
|
|
|
|
ACTION=="add", SUBSYSTEM=="tty", \
|
|
|
|
|
ENV{ID_SERIAL}=="FTDI_Quad_RS232-HS", \
|
|
|
|
|
ENV{ID_PATH}=="pci-0000:00:14.0-usb-0:1:1.2", \
|
|
|
|
|
SYMLINK+="ttyUSB_kasli-n1"
|
|
|
|
|
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
|
|
2019-04-08 23:45:30 +08:00
|
|
|
|
nix.distributedBuilds = true;
|
2019-04-08 22:35:38 +08:00
|
|
|
|
nix.buildMachines = [
|
|
|
|
|
{
|
|
|
|
|
hostName = "localhost";
|
|
|
|
|
maxJobs = 4;
|
|
|
|
|
system = "x86_64-linux";
|
|
|
|
|
supportedFeatures = ["big-parallel"];
|
|
|
|
|
}
|
2019-04-08 23:45:30 +08:00
|
|
|
|
{
|
|
|
|
|
hostName = "rpi-1";
|
|
|
|
|
sshUser = "nix";
|
2019-04-14 18:35:01 +08:00
|
|
|
|
sshKey = "/etc/nixos/secret/nix_id_rsa";
|
2019-04-08 23:45:30 +08:00
|
|
|
|
maxJobs = 1;
|
|
|
|
|
system = "aarch64-linux";
|
|
|
|
|
}
|
2019-04-08 22:35:38 +08:00
|
|
|
|
];
|
2019-02-16 00:33:08 +08:00
|
|
|
|
services.hydra = {
|
|
|
|
|
enable = true;
|
2019-04-14 18:32:01 +08:00
|
|
|
|
package = pkgs.hydra.overrideAttrs(oa: { patches = oa.patches ++ [ ./hydra-conda.patch ./hydra-retry.patch ]; } );
|
2019-02-17 12:33:27 +08:00
|
|
|
|
useSubstitutes = true;
|
2019-02-16 00:33:08 +08:00
|
|
|
|
hydraURL = "https://nixbld.m-labs.hk";
|
|
|
|
|
notificationSender = "hydra@m-labs.hk";
|
2019-02-23 00:30:08 +08:00
|
|
|
|
minimumDiskFree = 10; # in GB
|
2019-02-16 00:33:08 +08:00
|
|
|
|
minimumDiskFreeEvaluator = 1;
|
2019-02-17 23:19:36 +08:00
|
|
|
|
extraConfig =
|
|
|
|
|
''
|
2019-02-16 00:33:08 +08:00
|
|
|
|
binary_cache_secret_key_file = /etc/nixos/secret/nixbld.m-labs.hk-1
|
2019-02-23 00:30:08 +08:00
|
|
|
|
max_output_size = 5500000000
|
2019-02-17 23:19:36 +08:00
|
|
|
|
'';
|
2019-02-16 00:33:08 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nix.extraOptions = ''
|
|
|
|
|
secret-key-files = /etc/nixos/secret/nixbld.m-labs.hk-1
|
|
|
|
|
'';
|
|
|
|
|
nix.sandboxPaths = ["/opt"];
|
|
|
|
|
|
2019-03-14 17:53:56 +08:00
|
|
|
|
virtualisation.libvirtd.enable = true;
|
|
|
|
|
|
2019-03-31 23:51:06 +08:00
|
|
|
|
services.gitea = {
|
2019-03-27 22:42:12 +08:00
|
|
|
|
enable = true;
|
2019-03-31 23:51:06 +08:00
|
|
|
|
httpPort = 3001;
|
|
|
|
|
rootUrl = "https://git.m-labs.hk/";
|
2019-04-01 10:55:59 +08:00
|
|
|
|
appName = "M-Labs Git";
|
|
|
|
|
cookieSecure = true;
|
2019-04-02 00:49:37 +08:00
|
|
|
|
disableRegistration = true;
|
2019-03-27 22:42:12 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-04-01 00:12:46 +08:00
|
|
|
|
services.mattermost = {
|
|
|
|
|
enable = true;
|
|
|
|
|
siteUrl = "https://chat.m-labs.hk/";
|
2019-04-02 00:50:26 +08:00
|
|
|
|
mutableConfig = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.matterbridge = {
|
|
|
|
|
enable = true;
|
|
|
|
|
configPath = "/etc/nixos/secret/matterbridge.toml";
|
2019-04-01 00:12:46 +08:00
|
|
|
|
};
|
2019-04-26 21:23:33 +08:00
|
|
|
|
|
|
|
|
|
nixpkgs.config.packageOverrides = super: let self = super.pkgs; in {
|
|
|
|
|
matterbridge = super.matterbridge.overrideAttrs(oa: { patches = [ ./matterbridge-disable-github.patch ]; });
|
|
|
|
|
};
|
2019-04-01 00:12:46 +08:00
|
|
|
|
|
2019-04-01 19:47:47 +08:00
|
|
|
|
security.acme.certs = {
|
|
|
|
|
"nixbld.m-labs.hk" = {
|
|
|
|
|
webroot = "/var/lib/acme/acme-challenge";
|
|
|
|
|
extraDomains = {
|
2019-04-21 10:43:48 +08:00
|
|
|
|
"m-labs.hk" = null;
|
|
|
|
|
"www.m-labs.hk" = null;
|
2019-04-01 19:47:47 +08:00
|
|
|
|
"lab.m-labs.hk" = null;
|
|
|
|
|
"git.m-labs.hk" = null;
|
|
|
|
|
"chat.m-labs.hk" = null;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2019-03-27 22:42:12 +08:00
|
|
|
|
services.nginx = {
|
|
|
|
|
enable = true;
|
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
|
virtualHosts = {
|
2019-04-21 10:43:48 +08:00
|
|
|
|
"m-labs.hk" = {
|
|
|
|
|
addSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
root = "/var/www/m-labs.hk";
|
|
|
|
|
};
|
|
|
|
|
"www.m-labs.hk" = {
|
|
|
|
|
addSSL = true;
|
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
|
|
|
|
root = "/var/www/m-labs.hk";
|
|
|
|
|
};
|
2019-03-28 00:15:40 +08:00
|
|
|
|
"lab.m-labs.hk" = {
|
|
|
|
|
addSSL = true;
|
2019-04-01 19:47:47 +08:00
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
2019-05-02 13:54:21 +08:00
|
|
|
|
locations."/homu/".proxyPass = "http://127.0.0.1:54856/";
|
2019-03-28 00:15:40 +08:00
|
|
|
|
};
|
|
|
|
|
"nixbld.m-labs.hk" = {
|
|
|
|
|
forceSSL = true;
|
2019-04-01 19:47:47 +08:00
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
2019-03-28 00:15:40 +08:00
|
|
|
|
locations."/".proxyPass = "http://127.0.0.1:3000";
|
|
|
|
|
};
|
2019-03-31 23:51:06 +08:00
|
|
|
|
"git.m-labs.hk" = {
|
2019-03-28 00:15:40 +08:00
|
|
|
|
forceSSL = true;
|
2019-04-01 19:47:47 +08:00
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
2019-03-31 23:51:06 +08:00
|
|
|
|
locations."/".proxyPass = "http://127.0.0.1:3001";
|
2019-03-27 22:42:12 +08:00
|
|
|
|
};
|
2019-04-01 00:12:46 +08:00
|
|
|
|
"chat.m-labs.hk" = {
|
|
|
|
|
forceSSL = true;
|
2019-04-01 19:47:47 +08:00
|
|
|
|
useACMEHost = "nixbld.m-labs.hk";
|
2019-04-01 00:12:46 +08:00
|
|
|
|
locations."/".proxyPass = "http://127.0.0.1:8065";
|
2019-04-02 00:50:02 +08:00
|
|
|
|
locations."~ /api/v[0-9]+/(users/)?websocket$".proxyPass = "http://127.0.0.1:8065";
|
|
|
|
|
locations."~ /api/v[0-9]+/(users/)?websocket$".proxyWebsockets = true;
|
2019-04-01 00:12:46 +08:00
|
|
|
|
};
|
2019-04-26 06:16:33 +08:00
|
|
|
|
"hooks.m-labs.hk" = {
|
|
|
|
|
extraConfig = ''
|
|
|
|
|
location / {
|
|
|
|
|
include ${pkgs.nginx}/conf/uwsgi_params;
|
|
|
|
|
uwsgi_pass unix:${config.services.uwsgi.runDir}/uwsgi.sock;
|
|
|
|
|
}
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
services.uwsgi = {
|
|
|
|
|
enable = true;
|
|
|
|
|
plugins = [ "python3" ];
|
|
|
|
|
instance = {
|
|
|
|
|
type = "emperor";
|
|
|
|
|
vassals = {
|
|
|
|
|
mattermostgithub = import ./mattermost-github-integration/uwsgi-config.nix { inherit config pkgs; };
|
|
|
|
|
};
|
2019-03-27 22:42:12 +08:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-02 13:54:21 +08:00
|
|
|
|
services.homu = {
|
|
|
|
|
enable = true;
|
|
|
|
|
config = "/etc/nixos/secret/homu.toml";
|
|
|
|
|
};
|
2019-05-01 04:38:58 +08:00
|
|
|
|
|
2019-02-16 00:33:08 +08:00
|
|
|
|
# This value determines the NixOS release with which your system is to be
|
|
|
|
|
# compatible, in order to avoid breaking some software such as database
|
|
|
|
|
# servers. You should change this only after NixOS release notes say you
|
|
|
|
|
# should.
|
|
|
|
|
system.stateVersion = "18.09"; # Did you read the comment?
|
|
|
|
|
}
|