2020-06-07 14:03:12 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2020-05-08 22:26:21 +00:00
|
|
|
{ depot, lib, pkgs, rebuilder, config, ... }:
|
2020-04-30 04:49:19 +00:00
|
|
|
let
|
|
|
|
inherit (depot.ops) secrets;
|
|
|
|
nvidia-offload-profile = ''
|
|
|
|
export __NV_PRIME_RENDER_OFFLOAD=1
|
|
|
|
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
|
|
|
|
export __GLX_VENDOR_LIBRARY_NAME=nvidia
|
|
|
|
export __VK_LAYER_NV_optimus=NVIDIA_only
|
|
|
|
'';
|
|
|
|
nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload"
|
|
|
|
(nvidia-offload-profile + ''
|
|
|
|
exec -a "$0" "$@"
|
|
|
|
'');
|
2020-05-03 17:44:11 +00:00
|
|
|
in {
|
2020-05-08 22:26:21 +00:00
|
|
|
imports = [
|
|
|
|
../lib/zfs.nix
|
2020-10-17 11:17:18 +00:00
|
|
|
../lib/graphical-client.nix
|
2020-07-19 17:20:21 +00:00
|
|
|
../lib/whitby-distributed.nix
|
2020-05-08 22:26:21 +00:00
|
|
|
];
|
|
|
|
|
2020-04-30 04:49:19 +00:00
|
|
|
boot.initrd.availableKernelModules = [
|
|
|
|
"xhci_pci"
|
|
|
|
"ahci"
|
|
|
|
"nvme"
|
|
|
|
"usbhid"
|
|
|
|
"usb_storage"
|
|
|
|
"sd_mod"
|
|
|
|
"rtsx_pci_sdmmc"
|
|
|
|
];
|
2020-05-08 22:26:21 +00:00
|
|
|
boot.kernelModules = [ "kvm-intel" ];
|
2020-05-11 20:15:49 +00:00
|
|
|
boot.supportedFilesystems = [ "ntfs" ];
|
2020-11-04 17:09:53 +00:00
|
|
|
boot.kernel.sysctl = {
|
|
|
|
"abi.vsyscall32" = "0";
|
|
|
|
};
|
2020-04-30 04:49:19 +00:00
|
|
|
|
|
|
|
fileSystems = let
|
|
|
|
zfs = device: {
|
|
|
|
device = device;
|
|
|
|
fsType = "zfs";
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
"/" = zfs "zpool/local/root";
|
|
|
|
"/nix" = zfs "zpool/local/nix";
|
|
|
|
"/tmp" = zfs "zpool/local/tmp";
|
|
|
|
|
|
|
|
"/var" = zfs "zpool/safe/var";
|
|
|
|
"/home" = zfs "zpool/safe/home";
|
|
|
|
"/persist" = zfs "zpool/safe/persist";
|
|
|
|
|
|
|
|
"/boot" = {
|
|
|
|
device = "/dev/disk/by-label/NIXBOOT";
|
|
|
|
fsType = "vfat";
|
|
|
|
};
|
2020-05-11 20:15:49 +00:00
|
|
|
"/data" = {
|
|
|
|
device = "/dev/disk/by-label/BULKDATA";
|
|
|
|
fsType = "ntfs";
|
2020-06-13 17:29:10 +00:00
|
|
|
options = [ "rw" "uid=1000" "gid=100" "dmask=022" "fmask=024" "windows_names" ];
|
2020-05-11 20:15:49 +00:00
|
|
|
};
|
2020-07-19 16:49:56 +00:00
|
|
|
"/home/lukegb/mnt" = { device = "192.168.1.40:/"; fsType = "nfs"; };
|
2020-04-30 04:49:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nix.maxJobs = lib.mkDefault 12;
|
|
|
|
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
|
|
|
|
hardware.enableRedistributableFirmware = true;
|
|
|
|
|
|
|
|
# Use the systemd-boot EFI boot loader.
|
|
|
|
boot.loader.systemd-boot.enable = true;
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
|
2020-05-08 22:26:21 +00:00
|
|
|
# ZFS!
|
|
|
|
services.zfs.rollbackOnBoot.enable = true;
|
2020-04-30 04:49:19 +00:00
|
|
|
|
|
|
|
# Enable HyperV guesting
|
|
|
|
virtualisation.hypervGuest.enable = true;
|
|
|
|
|
2020-10-04 00:03:28 +00:00
|
|
|
# Enable Podman
|
|
|
|
virtualisation.podman = {
|
|
|
|
enable = true;
|
|
|
|
dockerCompat = true;
|
|
|
|
};
|
|
|
|
|
2020-11-03 16:03:22 +00:00
|
|
|
# Enable libvirtd.
|
|
|
|
virtualisation.libvirtd = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
|
2020-04-30 04:49:19 +00:00
|
|
|
networking.hostName = "porcorosso";
|
|
|
|
networking.hostId = "1ee729a4";
|
|
|
|
|
|
|
|
# Boot faster.
|
|
|
|
systemd.services.systemd-udev-settle.enable = false;
|
|
|
|
systemd.services.NetworkManager-wait-online.enable = false;
|
|
|
|
|
|
|
|
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
|
|
|
|
# Per-interface useDHCP will be mandatory in the future, so this generated config
|
|
|
|
# replicates the default behaviour.
|
|
|
|
# Use NetworkManager instead.
|
|
|
|
networking.useDHCP = false;
|
|
|
|
networking.interfaces.eno1.useDHCP = false;
|
|
|
|
networking.networkmanager.enable = true;
|
2020-11-01 18:25:01 +00:00
|
|
|
my.ip.tailscale = "100.125.26.108";
|
2020-04-30 04:49:19 +00:00
|
|
|
|
|
|
|
# Set your time zone.
|
|
|
|
time.timeZone = "Europe/London";
|
|
|
|
|
|
|
|
# List packages installed in system profile. To search, run:
|
|
|
|
# $ nix search wget
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
pciutils
|
|
|
|
nvidia-offload
|
|
|
|
rebuilder
|
2020-05-10 01:12:29 +00:00
|
|
|
deluge
|
2020-05-10 14:25:37 +00:00
|
|
|
(writeShellScriptBin "windows" ''
|
|
|
|
set -ue
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
exec sudo "$0" "$@"
|
|
|
|
fi
|
2020-10-25 11:36:16 +00:00
|
|
|
|
2020-05-10 14:25:37 +00:00
|
|
|
efibootmgr -n 0001
|
|
|
|
systemctl reboot
|
|
|
|
'')
|
2020-04-30 04:49:19 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Some programs need SUID wrappers, can be configured further or are
|
|
|
|
# started in user sessions.
|
|
|
|
# programs.gnupg.agent = { enable = true; enableSSHSupport = true; };
|
|
|
|
|
|
|
|
# List services that you want to enable:
|
|
|
|
|
|
|
|
# Enable CUPS to print documents.
|
2020-05-08 22:26:21 +00:00
|
|
|
services.printing.enable = true;
|
2020-04-30 04:49:19 +00:00
|
|
|
|
|
|
|
# Enable the X11 windowing system.
|
|
|
|
services.xserver.enable = true;
|
|
|
|
services.xserver.layout = "us";
|
|
|
|
services.xserver.libinput.enable = true;
|
|
|
|
services.xserver.windowManager.i3.enable = true;
|
2020-10-03 23:11:45 +00:00
|
|
|
services.xserver.videoDrivers = [ "nvidia" ];
|
2020-04-30 04:49:19 +00:00
|
|
|
services.xserver.displayManager.gdm = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
hardware.opengl.driSupport32Bit = true;
|
|
|
|
hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ];
|
|
|
|
hardware.pulseaudio.support32Bit = true;
|
|
|
|
|
|
|
|
# Define a user account.
|
2020-05-08 22:26:21 +00:00
|
|
|
users.users.lukegb = {
|
2020-11-03 16:03:22 +00:00
|
|
|
extraGroups = [ "wheel" "networkmanager" "libvirtd" ];
|
2020-10-25 11:36:16 +00:00
|
|
|
};
|
|
|
|
my.home-manager.system = {...}: {
|
|
|
|
home.packages = lib.mkAfter (with pkgs; [
|
2020-05-11 15:21:48 +00:00
|
|
|
(steam.override { extraProfile = nvidia-offload-profile; })
|
2020-05-11 15:18:17 +00:00
|
|
|
(writeScriptBin "javaws" ''
|
2020-05-08 22:26:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
exec ${depot.nix.pkgs.javaws-env}/bin/javaws-env "$@"
|
|
|
|
'')
|
2020-05-11 15:21:48 +00:00
|
|
|
(depot.nix.pkgs.secretsync.configure {
|
|
|
|
workingDir = "/home/lukegb/depot";
|
|
|
|
gitlabAccessToken = secrets.deployer.gitlabAccessToken;
|
|
|
|
manifestVariable = "SECRETS_MANIFEST";
|
|
|
|
variablesToFile = {
|
|
|
|
"OPS_SECRETS_DEFAULT_NIX" = "ops/secrets/default.nix";
|
|
|
|
};
|
|
|
|
})
|
2020-05-11 15:31:17 +00:00
|
|
|
efibootmgr
|
|
|
|
iotop
|
|
|
|
iw
|
2020-05-31 17:58:29 +00:00
|
|
|
vulkan-tools
|
2020-10-25 11:36:16 +00:00
|
|
|
]);
|
2020-10-25 12:00:15 +00:00
|
|
|
|
|
|
|
xdg.configFile."pulse/default.pa".source = ./default.pa;
|
2020-04-30 04:49:19 +00:00
|
|
|
};
|
|
|
|
|
2020-05-22 12:04:47 +00:00
|
|
|
# github.com/target/lorri
|
|
|
|
services.lorri.enable = true;
|
|
|
|
|
2020-04-30 04:49:19 +00:00
|
|
|
# Things to persist.
|
|
|
|
services.openssh.hostKeys = [
|
|
|
|
{
|
|
|
|
path = "/persist/etc/ssh/ssh_host_ed25519_key";
|
|
|
|
type = "ed25519";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
path = "/persist/etc/ssh/ssh_host_rsa_key";
|
|
|
|
type = "rsa";
|
|
|
|
bits = 4096;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
environment.etc = {
|
|
|
|
"NetworkManager/system-connections" = {
|
|
|
|
source = "/persist/etc/NetworkManager/system-connections/";
|
|
|
|
};
|
|
|
|
"nixos" = { source = "/persist/etc/nixos/"; };
|
|
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
#"L /etc/nixos - - - - /persist/etc/nixos"
|
2020-11-04 17:09:53 +00:00
|
|
|
"d /var/lib/libvirt 0755 root - - -"
|
2020-04-30 04:49:19 +00:00
|
|
|
];
|
2020-11-04 17:09:53 +00:00
|
|
|
systemd.mounts = [{
|
|
|
|
bindsTo = ["libvirtd.service"];
|
|
|
|
partOf = ["libvirtd.service"];
|
|
|
|
unitConfig.RequiresMountsFor = "/var/lib/libvirt";
|
|
|
|
options = "bind";
|
|
|
|
what = "/persist/var/lib/libvirt";
|
|
|
|
where = "/var/lib/libvirt";
|
|
|
|
}];
|
2020-04-30 04:49:19 +00:00
|
|
|
|
|
|
|
# Enable Thunderbolt device management.
|
|
|
|
services.hardware.bolt.enable = true;
|
|
|
|
|
2020-06-20 22:11:24 +00:00
|
|
|
services.redis.enable = true;
|
|
|
|
services.postgresql.enable = true;
|
|
|
|
services.postgresql.ensureUsers = [{
|
|
|
|
name = "lukegb";
|
|
|
|
ensurePermissions = {
|
|
|
|
"ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES";
|
|
|
|
"DATABASE lukegb" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
services.postgresql.authentication = ''
|
|
|
|
local all all trust
|
|
|
|
host all all 127.0.0.1/32 trust
|
|
|
|
host all all ::1/128 trust
|
|
|
|
'';
|
|
|
|
|
2020-07-19 17:47:40 +00:00
|
|
|
nix.buildMachines = [ {
|
|
|
|
hostName = "totoro";
|
|
|
|
system = "x86_64-linux";
|
|
|
|
maxJobs = 4;
|
|
|
|
speedFactor = 2;
|
|
|
|
supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
|
|
|
|
mandatoryFeatures = [ ];
|
|
|
|
}];
|
|
|
|
|
2020-06-20 22:11:24 +00:00
|
|
|
|
2020-04-30 04:49:19 +00: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.
|
2020-05-11 20:15:49 +00:00
|
|
|
system.stateVersion = "20.03"; # Did you read the comment?
|
2020-06-13 17:31:37 +00:00
|
|
|
}
|