levi: init

This commit is contained in:
Sean Buckley 2022-10-07 00:58:13 -04:00
parent ff32101060
commit 3a353e863b
4 changed files with 144 additions and 0 deletions

View file

@ -15,4 +15,5 @@ builtins.mapAttrs
cube = "x86_64-linux"; cube = "x86_64-linux";
hp = "x86_64-linux"; hp = "x86_64-linux";
lenny = "x86_64-linux"; lenny = "x86_64-linux";
levi = "x86_64-linux";
} }

54
hosts/levi/default.nix Normal file
View file

@ -0,0 +1,54 @@
{ config, pkgs, ... }:
let
persist = "/var/lib/persist-${config.networking.hostName}";
in
{
imports = [
./optimus.nix
];
environment.etc = {
"machine-id".source = "${persist}/machine-id";
"NetworkManager/system-connections".source =
"${persist}/network-connections";
};
systemd.tmpfiles.rules = [ "d ${persist}/network-connections 0700" ];
services.openssh.hostKeys = [
{ type = "ed25519"; path = "${persist}/ssh_host_ed25519_key"; }
];
sconfig = {
gnome = true;
profile = "desktop";
gaming.enable = true;
horizon.enable = true;
wg-home.enable = true;
};
boot = {
loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = true;
initrd.availableKernelModules = [ "xhci_pci" "vmd" "nvme" "sd_mod" ];
};
fileSystems = {
"/" = { device = "tmpfs"; fsType = "tmpfs"; options = [ "mode=755" ]; };
"/boot" = { fsType = "vfat"; device = "/dev/nvme0n1p1"; };
"/nix" = { device = "levi/nix"; fsType = "zfs"; };
"/home" = { device = "levi/home"; fsType = "zfs"; };
"/var/lib" = { device = "levi/lib"; fsType = "zfs"; };
"/var/log" = { device = "levi/log"; fsType = "zfs"; };
};
users.mutableUsers = false;
users.users.sean.passwordFile = "${persist}/shadow_sean";
users.users.root.passwordFile = "${persist}/shadow_sean";
services.openssh.enable = true;
hardware.video.hidpi.enable = true;
hardware.cpu.intel.updateMicrocode = true;
hardware.enableRedistributableFirmware = true;
system.stateVersion = "22.05";
}

88
hosts/levi/optimus.nix Normal file
View file

@ -0,0 +1,88 @@
{ lib, pkgs, ... }:
let
current-mode = "nvidia-mux";
constants = {
hardware.nvidia.prime.intelBusId = "PCI:0:2:0";
hardware.nvidia.prime.nvidiaBusId = "PCI:1:0:0";
boot.kernelPackages = pkgs.linuxPackages_latest;
};
available-modes = {
nvidia = {
### "sync mode"
#
# good:
# max performance on external displays
# no BIOS settings change needed
#
# bad:
# graphics performance overhead on internal display
# internal display capped at 60hz
#
hardware.nvidia.prime.sync.enable = true;
hardware.nvidia.modesetting.enable = true;
services.xserver.displayManager.gdm.wayland = false;
services.xserver.videoDrivers = [ "nvidia" ];
# xrandr workaround for laptop panel not showing up with GDM. Reference:
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/hardware/video/nvidia.nix
services.xserver.displayManager.sessionCommands = ''
${pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource modesetting NVIDIA-0
'';
};
nvidia-mux = {
### optimus disabled in BIOS with MUX switch.
#
# good:
# simple, always works.
# max performance everywhere.
#
# bad:
# cant change laptop brightness.
# requires BIOS setting changes, which is annoying.
#
boot.kernelParams = [ "module_blacklist=i915" ];
services.xserver.videoDrivers = [ "nvidia" ];
};
intel = {
### nvidia drivers disabled
#
# Not well tested. Possibly Incomplete.
#
# Shutting off Nvidia GPU would theoretically save power.
#
boot.kernelParams = [ "module_blacklist=nouveau" ];
};
hybrid = {
### hybrid graphics
#
# Not well tested. Possibly Incomplete.
# Won't allow external displays connected to nvidia GPU.
#
# Everything would use intel by default,
# but specific apps would run on the nvidia GPU under the script.
#
hardware.nvidia.prime.offload.enable = true;
services.xserver.videoDrivers = [ "nvidia" ];
environment.systemPackages = [
(pkgs.writeShellScriptBin "nv" ''
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
exec "$@"
'')
];
};
};
in
lib.mkMerge [
(constants)
(available-modes.${current-mode})
]

View file

@ -4,6 +4,7 @@ let
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIqWHzIXaF88Y8+64gBlLbZ5ZZcLl08kTHG1clHd7gaq desktop" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIqWHzIXaF88Y8+64gBlLbZ5ZZcLl08kTHG1clHd7gaq desktop"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJlMPWSVyDNAvXYtpXCI/geCeUEMbL9Nthm9B0zg1sIy sean@hp" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJlMPWSVyDNAvXYtpXCI/geCeUEMbL9Nthm9B0zg1sIy sean@hp"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDuuBHq3x28cdQ0JWAZ0R+2rVlRoPnA+MOvpdF5rraGp sean@lenny" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDuuBHq3x28cdQ0JWAZ0R+2rVlRoPnA+MOvpdF5rraGp sean@lenny"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE59uvHtxmdjqMaKyPiKLdiwfu0i59iFczrbGY0t6Oed sean@levi"
]; ];
in in
{ {