2020-07-02 20:19:08 +02:00
|
|
|
{ depot, lib, ... }:
|
|
|
|
|
|
|
|
let
|
2020-07-02 21:27:02 +02:00
|
|
|
inherit (builtins) listToAttrs;
|
|
|
|
inherit (lib) range;
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
nixpkgs = import depot.third_party.nixpkgsSrc {};
|
|
|
|
|
2020-07-02 21:27:02 +02:00
|
|
|
# All Buildkite hooks are actually besadii, but it's being invoked
|
|
|
|
# with different names.
|
|
|
|
buildkiteHooks = depot.third_party.runCommandNoCC "buildkite-hooks" {} ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
ln -s ${depot.ops.besadii}/bin/besadii $out/bin/post-command
|
|
|
|
'';
|
2020-07-03 06:26:33 +02:00
|
|
|
in {
|
2020-07-02 20:19:08 +02:00
|
|
|
inherit depot;
|
|
|
|
imports = [
|
|
|
|
"${depot.depotPath}/ops/nixos/depot.nix"
|
2020-07-11 13:51:04 +02:00
|
|
|
"${depot.depotPath}/ops/nixos/smtprelay.nix"
|
2020-07-05 18:52:51 +02:00
|
|
|
"${depot.depotPath}/ops/nixos/tvl-slapd/default.nix"
|
2020-07-05 21:46:17 +02:00
|
|
|
"${depot.depotPath}/ops/nixos/tvl-sso/default.nix"
|
2020-07-11 13:51:04 +02:00
|
|
|
"${depot.depotPath}/ops/nixos/www/login.tvl.fyi.nix"
|
2020-07-02 20:19:08 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
hardware = {
|
|
|
|
enableRedistributableFirmware = true;
|
|
|
|
cpu.amd.updateMicrocode = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
boot = {
|
|
|
|
tmpOnTmpfs = true;
|
|
|
|
kernelModules = [ "kvm-amd" ];
|
|
|
|
supportedFilesystems = [ "zfs" ];
|
|
|
|
|
|
|
|
initrd = {
|
|
|
|
availableKernelModules = [
|
|
|
|
"igb" "xhci_pci" "nvme" "ahci" "usbhid" "usb_storage" "sr_mod"
|
|
|
|
];
|
|
|
|
|
|
|
|
# Enable SSH in the initrd so that we can enter disk encryption
|
|
|
|
# passwords remotely.
|
|
|
|
network = {
|
|
|
|
enable = true;
|
|
|
|
ssh = {
|
|
|
|
enable = true;
|
|
|
|
port = 2222;
|
|
|
|
authorizedKeys = [
|
|
|
|
depot.users.tazjin.keys.frog
|
|
|
|
];
|
|
|
|
|
|
|
|
hostKeys = [
|
|
|
|
/etc/secrets/initrd_host_ed25519_key
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# this will launch the zfs password prompt on login and kill the
|
|
|
|
# other prompt
|
|
|
|
postCommands = ''
|
|
|
|
echo "zfs load-key -a && killall zfs" >> /root/.profile
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
loader.grub = {
|
|
|
|
enable = true;
|
|
|
|
version = 2;
|
|
|
|
efiSupport = true;
|
|
|
|
efiInstallAsRemovable = true;
|
|
|
|
device = "/dev/disk/by-id/nvme-SAMSUNG_MZQLB1T9HAJR-00007_S439NA0N201620";
|
|
|
|
};
|
|
|
|
|
|
|
|
zfs.requestEncryptionCredentials = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
fileSystems = {
|
|
|
|
"/" = {
|
|
|
|
device = "zroot/root";
|
|
|
|
fsType = "zfs";
|
|
|
|
};
|
|
|
|
|
|
|
|
"/boot" = {
|
|
|
|
device = "/dev/disk/by-uuid/073E-7FBD";
|
|
|
|
fsType = "vfat";
|
|
|
|
};
|
|
|
|
|
|
|
|
"/nix" = {
|
|
|
|
device = "zroot/nix";
|
|
|
|
fsType = "zfs";
|
|
|
|
};
|
|
|
|
|
|
|
|
"/home" = {
|
|
|
|
device = "zroot/home";
|
|
|
|
fsType = "zfs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
# Glass is boring, but Luke doesn't like Wapping - the Prospect of
|
|
|
|
# Whitby, however, is quite a pleasant establishment.
|
|
|
|
hostName = "whitby";
|
|
|
|
hostId = "b38ca543";
|
|
|
|
useDHCP = false;
|
2020-07-02 21:27:23 +02:00
|
|
|
|
|
|
|
defaultGateway6 = {
|
|
|
|
address = "fe80::1";
|
|
|
|
interface = "enp196s0";
|
|
|
|
};
|
2020-07-02 20:19:08 +02:00
|
|
|
|
|
|
|
firewall.allowedTCPPorts = [ 22 80 443 ];
|
|
|
|
|
|
|
|
interfaces.enp196s0.useDHCP = true;
|
|
|
|
interfaces.enp196s0.ipv6.addresses = [
|
|
|
|
{
|
|
|
|
address = "2a01:04f8:0242:5b21::feed:edef:beef";
|
|
|
|
prefixLength = 64;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
time.timeZone = "UTC";
|
|
|
|
|
|
|
|
nix = {
|
|
|
|
maxJobs = lib.mkDefault 64;
|
2020-07-02 21:07:58 +02:00
|
|
|
extraOptions = ''
|
|
|
|
secret-key-files = /etc/secrets/nix-cache-privkey
|
|
|
|
'';
|
2020-07-02 23:31:15 +02:00
|
|
|
|
|
|
|
trustedUsers = [
|
|
|
|
"grfn"
|
2020-07-04 22:11:30 +02:00
|
|
|
"lukegb"
|
2020-07-02 23:31:15 +02:00
|
|
|
];
|
2020-07-03 16:22:21 +02:00
|
|
|
|
|
|
|
sshServe = {
|
|
|
|
enable = true;
|
|
|
|
keys = with depot.users;
|
|
|
|
tazjin.keys.all
|
|
|
|
++ lukegb.keys.all
|
|
|
|
++ [ glittershark.keys.whitby ];
|
|
|
|
};
|
2020-07-02 20:19:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
programs.mtr.enable = true;
|
|
|
|
services.openssh.enable = true;
|
|
|
|
|
2020-07-02 21:27:02 +02:00
|
|
|
# Run a handful of Buildkite agents to support parallel builds.
|
|
|
|
services.buildkite-agents = listToAttrs (map (n: rec {
|
|
|
|
name = "whitby-${toString n}";
|
|
|
|
value = {
|
|
|
|
inherit name;
|
|
|
|
enable = true;
|
|
|
|
tokenPath = "/etc/secrets/buildkite-agent-token";
|
|
|
|
hooks.post-command = "${buildkiteHooks}/bin/post-command";
|
|
|
|
};
|
|
|
|
}) (range 1 8));
|
|
|
|
|
2020-07-11 13:51:04 +02:00
|
|
|
# Start a local SMTP relay to Gmail (used by gerrit)
|
|
|
|
services.depot.smtprelay = {
|
|
|
|
enable = true;
|
|
|
|
args = {
|
|
|
|
listen = ":2525";
|
|
|
|
remote_host = "smtp.gmail.com:587";
|
|
|
|
remote_auth = "plain";
|
|
|
|
remote_user = "tvlbot@tazj.in";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
environment.systemPackages = with nixpkgs; [
|
|
|
|
bb
|
|
|
|
curl
|
|
|
|
emacs-nox
|
|
|
|
git
|
|
|
|
htop
|
|
|
|
nano
|
|
|
|
vim
|
|
|
|
zfs
|
|
|
|
zfstools
|
|
|
|
];
|
|
|
|
|
2020-07-02 23:53:59 +02:00
|
|
|
security.sudo.extraRules = [
|
|
|
|
{
|
|
|
|
groups = ["wheel"];
|
|
|
|
commands = [{ command = "ALL"; options = ["NOPASSWD"]; }];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
users = {
|
|
|
|
users.root.openssh.authorizedKeys.keys = [
|
|
|
|
depot.users.tazjin.keys.frog
|
|
|
|
];
|
|
|
|
|
|
|
|
users.tazjin = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" "wheel" ];
|
2020-07-03 16:22:21 +02:00
|
|
|
openssh.authorizedKeys.keys = depot.users.tazjin.keys.all;
|
2020-07-02 20:19:08 +02:00
|
|
|
};
|
|
|
|
|
2020-07-02 21:05:39 +02:00
|
|
|
users.lukegb = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" "wheel" ];
|
|
|
|
openssh.authorizedKeys.keys = depot.users.lukegb.keys.all;
|
|
|
|
};
|
|
|
|
|
2020-07-02 21:07:22 +02:00
|
|
|
users.grfn = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "git" "wheel" ];
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
depot.users.glittershark.keys.whitby
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
# Set up a user & group for git shenanigans
|
|
|
|
groups.git = {};
|
|
|
|
users.git = {
|
|
|
|
group = "git";
|
|
|
|
isNormalUser = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-07-07 00:18:43 +02:00
|
|
|
security.acme = {
|
|
|
|
acceptTerms = true;
|
|
|
|
email = "mail@tazj.in";
|
|
|
|
};
|
|
|
|
|
2020-07-02 20:19:08 +02:00
|
|
|
system.stateVersion = "20.03";
|
|
|
|
}
|