465 lines
12 KiB
Nix
465 lines
12 KiB
Nix
{
|
|
config,
|
|
options,
|
|
pkgs,
|
|
lib,
|
|
username,
|
|
system,
|
|
hostname,
|
|
inputs,
|
|
niri-package,
|
|
...
|
|
}:
|
|
{
|
|
imports = [
|
|
./vm.nix
|
|
./steam.nix
|
|
./networking.nix
|
|
|
|
inputs.disko.nixosModules.disko
|
|
inputs.lanzaboote.nixosModules.lanzaboote
|
|
|
|
inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
|
|
inputs.nixos-hardware.nixosModules.common-cpu-amd-zenpower
|
|
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
|
];
|
|
|
|
# allow overclocking (I actually underclock but lol)
|
|
hardware.amdgpu.overdrive.ppfeaturemask = "0xFFFFFFFF";
|
|
|
|
hardware.enableRedistributableFirmware = true;
|
|
hardware.cpu.amd.updateMicrocode = true;
|
|
|
|
services.kmscon.enable = true;
|
|
|
|
# Add niri to display manager session packages
|
|
services.displayManager.sessionPackages = [ niri-package ];
|
|
|
|
programs = {
|
|
gamescope = {
|
|
enable = true;
|
|
capSysNice = true;
|
|
};
|
|
steam = {
|
|
enable = true;
|
|
gamescopeSession.enable = true;
|
|
};
|
|
};
|
|
|
|
system.activationScripts = {
|
|
# FIX: https://github.com/NixOS/nix/issues/2982
|
|
"profile-channel-dummy".text = ''
|
|
#!/bin/sh
|
|
mkdir -p /nix/var/nix/profiles/per-user/root/channels
|
|
'';
|
|
|
|
# extract all my secureboot keys
|
|
# TODO! proper secrets management
|
|
"secureboot-keys".text = ''
|
|
#!/usr/bin/env sh
|
|
rm -fr ${config.boot.lanzaboote.pkiBundle} || true
|
|
mkdir -p ${config.boot.lanzaboote.pkiBundle}
|
|
${lib.getExe pkgs.gnutar} xf ${./secrets/secureboot.tar} -C ${config.boot.lanzaboote.pkiBundle}
|
|
chown -R root:wheel ${config.boot.lanzaboote.pkiBundle}
|
|
chmod -R 500 ${config.boot.lanzaboote.pkiBundle}
|
|
'';
|
|
};
|
|
|
|
swapDevices = [ ];
|
|
|
|
nix = {
|
|
# optimize the store
|
|
optimise.automatic = true;
|
|
|
|
# auto garbage collect old generations
|
|
gc = {
|
|
automatic = true;
|
|
dates = "weekly";
|
|
options = "--delete-older-than 30d";
|
|
};
|
|
|
|
settings = {
|
|
# enable flakes!
|
|
experimental-features = [
|
|
"nix-command"
|
|
"flakes"
|
|
];
|
|
|
|
# Use muffin server as a binary cache
|
|
substituters = [ "https://nix-cache.sigkill.computer" ];
|
|
trusted-public-keys = [
|
|
"nix-cache.sigkill.computer-1:ONtQC9gUjL+2yNgMWB68NudPySXhyzJ7I3ra56/NPgk="
|
|
];
|
|
netrc-file = "${./secrets/nix-cache-netrc}";
|
|
};
|
|
};
|
|
|
|
# cachyos kernel overlay
|
|
nixpkgs.overlays = [ inputs.nix-cachyos-kernel.overlays.default ];
|
|
|
|
# kernel options
|
|
boot = {
|
|
|
|
# disable legacy subsystems neither host will ever use
|
|
kernelPatches = [
|
|
{
|
|
name = "disable-legacy-subsystems";
|
|
patch = null;
|
|
structuredExtraConfig = with lib.kernel; {
|
|
# ancient bus/card standards
|
|
PCMCIA = lib.mkForce no;
|
|
PCCARD = lib.mkForce no;
|
|
PARPORT = lib.mkForce no;
|
|
GAMEPORT = lib.mkForce module;
|
|
FIREWIRE = lib.mkForce no;
|
|
AGP = lib.mkForce no;
|
|
|
|
# legacy networking
|
|
ATM = lib.mkForce no;
|
|
FDDI = lib.mkForce no;
|
|
ISDN = lib.mkForce no;
|
|
CAN = lib.mkForce no;
|
|
NFC = lib.mkForce no;
|
|
INFINIBAND = lib.mkForce no;
|
|
|
|
# amateur radio (HAMRADIO is the umbrella but these are separate symbols)
|
|
HAMRADIO = lib.mkForce no;
|
|
AX25 = lib.mkForce no;
|
|
NETROM = lib.mkForce no;
|
|
ROSE = lib.mkForce no;
|
|
|
|
# dead protocols
|
|
PHONET = lib.mkForce no;
|
|
IEEE802154 = lib.mkForce no;
|
|
"6LOWPAN" = lib.mkForce no;
|
|
NET_9P = lib.mkForce no;
|
|
BATMAN_ADV = lib.mkForce no;
|
|
|
|
# tv tuners / digital video broadcasting
|
|
MEDIA_ANALOG_TV_SUPPORT = lib.mkForce no;
|
|
MEDIA_DIGITAL_TV_SUPPORT = lib.mkForce no;
|
|
DVB_CORE = lib.mkForce no;
|
|
|
|
# hypervisor guest support (bare metal only)
|
|
HYPERV = lib.mkForce no;
|
|
XEN = lib.mkForce no;
|
|
VMWARE_VMCI = lib.mkForce no;
|
|
VMWARE_BALLOON = lib.mkForce no;
|
|
VMWARE_PVSCSI = lib.mkForce no;
|
|
VMWARE_VMCI_VSOCKETS = lib.mkForce no;
|
|
VMXNET3 = lib.mkForce no;
|
|
DRM_VMWGFX = lib.mkForce no;
|
|
VBOXGUEST = lib.mkForce no;
|
|
VBOXSF_FS = lib.mkForce no;
|
|
|
|
# staging drivers (experimental/unmaintained)
|
|
STAGING = lib.mkForce no;
|
|
|
|
# legacy storage (AHCI for modern SATA is independent)
|
|
ATA_SFF = lib.mkForce no;
|
|
SCSI_LOWLEVEL = lib.mkForce no;
|
|
FUSION = lib.mkForce no;
|
|
|
|
# misc legacy
|
|
MOST = lib.mkForce no;
|
|
PPDEV = lib.mkForce no;
|
|
PHANTOM = lib.mkForce no;
|
|
X86_ANDROID_TABLETS = lib.mkForce no;
|
|
CHROME_PLATFORMS = lib.mkForce no;
|
|
SURFACE_PLATFORMS = lib.mkForce no;
|
|
MCTP = lib.mkForce no;
|
|
GPIB = lib.mkForce no;
|
|
SIOX = lib.mkForce no;
|
|
SLIMBUS = lib.mkForce no;
|
|
WWAN = lib.mkForce no;
|
|
|
|
# nvidia gpu
|
|
DRM_NOUVEAU = lib.mkForce no;
|
|
|
|
# other gpus not present
|
|
DRM_RADEON = lib.mkForce no;
|
|
DRM_GMA500 = lib.mkForce no;
|
|
DRM_AST = lib.mkForce no;
|
|
DRM_MGAG200 = lib.mkForce no;
|
|
DRM_HISI_HIBMC = lib.mkForce no;
|
|
DRM_APPLETBDRM = lib.mkForce no;
|
|
|
|
# intel gpu
|
|
DRM_I915 = lib.mkForce no;
|
|
DRM_XE = lib.mkForce no;
|
|
|
|
# intel cpu / platform
|
|
INTEL_IOMMU = lib.mkForce no;
|
|
INTEL_IDLE = lib.mkForce no;
|
|
INTEL_HFI_THERMAL = lib.mkForce no;
|
|
INTEL_TCC_COOLING = lib.mkForce no;
|
|
INTEL_SOC_DTS_THERMAL = lib.mkForce no;
|
|
INTEL_PCH_THERMAL = lib.mkForce no;
|
|
INTEL_POWERCLAMP = lib.mkForce no;
|
|
X86_PKG_TEMP_THERMAL = lib.mkForce no;
|
|
X86_INTEL_LPSS = lib.mkForce no;
|
|
INTEL_MEI = lib.mkForce no;
|
|
INTEL_TH = lib.mkForce no;
|
|
INTEL_VSEC = lib.mkForce no;
|
|
INTEL_IDXD = lib.mkForce no;
|
|
INTEL_IOATDMA = lib.mkForce no;
|
|
|
|
# intel audio
|
|
SND_SOC_SOF_INTEL_TOPLEVEL = lib.mkForce no;
|
|
SND_SOC_INTEL_SST_TOPLEVEL = lib.mkForce no;
|
|
|
|
# mellanox networking
|
|
MLX4_CORE = lib.mkForce no;
|
|
MLX5_CORE = lib.mkForce no;
|
|
MLXSW_CORE = lib.mkForce no;
|
|
MLX_PLATFORM = lib.mkForce no;
|
|
|
|
# fpga
|
|
FPGA = lib.mkForce no;
|
|
|
|
# old x86 cpufreq / platform (both systems are modern Zen)
|
|
AMD_NUMA = lib.mkForce no;
|
|
X86_POWERNOW_K8 = lib.mkForce no;
|
|
X86_P4_CLOCKMOD = lib.mkForce no;
|
|
X86_SPEEDSTEP_LIB = lib.mkForce no;
|
|
|
|
# cxl (datacenter memory expansion)
|
|
CXL_BUS = lib.mkForce no;
|
|
|
|
# embedded SoC peripherals (not present on desktop/laptop)
|
|
INPUT_TOUCHSCREEN = lib.mkForce no;
|
|
INPUT_TABLET = lib.mkForce no;
|
|
INPUT_JOYSTICK = lib.mkForce no;
|
|
MEDIA_PLATFORM_DRIVERS = lib.mkForce no;
|
|
MEDIA_TEST_SUPPORT = lib.mkForce no;
|
|
|
|
# deprecated userland compat
|
|
SGETMASK_SYSCALL = lib.mkForce no;
|
|
UID16 = lib.mkForce no;
|
|
X86_X32_ABI = lib.mkForce no;
|
|
};
|
|
}
|
|
];
|
|
|
|
# aes_generic is built-in as of linux 7.0, no longer a loadable module
|
|
initrd.luks.cryptoModules = lib.mkForce (
|
|
lib.filter (m: m != "aes_generic") options.boot.initrd.luks.cryptoModules.default
|
|
);
|
|
|
|
lanzaboote = {
|
|
enable = true;
|
|
# TODO: proper secrets management so this is not stored in nix store
|
|
pkiBundle = "/var/lib/sbctl";
|
|
};
|
|
|
|
# Bootloader.
|
|
loader = {
|
|
efi.canTouchEfiVariables = true;
|
|
|
|
timeout = 1;
|
|
/*
|
|
Lanzaboote currently replaces the systemd-boot module.
|
|
This setting is usually set to true in configuration.nix
|
|
generated at installation time. So we force it to false
|
|
for now.
|
|
*/
|
|
systemd-boot.enable = lib.mkForce false;
|
|
systemd-boot.configurationLimit = 10;
|
|
};
|
|
|
|
initrd = {
|
|
systemd.enable = true;
|
|
compressor = "zstd";
|
|
availableKernelModules = [
|
|
"xhci_pci"
|
|
"thunderbolt"
|
|
"nvme"
|
|
"usbhid"
|
|
"amdgpu"
|
|
];
|
|
};
|
|
|
|
kernelModules = [
|
|
"kvm-amd"
|
|
"ip_tables"
|
|
"iptable_nat"
|
|
"msr"
|
|
"btusb"
|
|
];
|
|
|
|
kernelParams = [
|
|
# 1gb huge pages
|
|
"hugepagesz=1G"
|
|
"hugepages=3"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
environment.etc = {
|
|
# override default nixos /etc/issue
|
|
"issue".text = "";
|
|
};
|
|
|
|
services = {
|
|
# fwupd for updating firmware
|
|
fwupd = {
|
|
enable = true;
|
|
extraRemotes = [ "lvfs-testing" ];
|
|
};
|
|
|
|
# auto detect network printers
|
|
avahi = {
|
|
enable = true;
|
|
nssmdns4 = true;
|
|
openFirewall = true;
|
|
};
|
|
|
|
# Enable CUPS to print documents.
|
|
printing = {
|
|
enable = true;
|
|
drivers = with pkgs; [ hplip ];
|
|
};
|
|
|
|
# I don't want fingerprint login
|
|
fprintd.enable = false;
|
|
|
|
# Making sure mullvad works on boot
|
|
mullvad-vpn.enable = true;
|
|
|
|
# power statistics
|
|
upower.enable = true;
|
|
|
|
# power profiles for noctalia shell
|
|
power-profiles-daemon.enable = true;
|
|
|
|
# geolocation (uses beacondb.net by default)
|
|
geoclue2 = {
|
|
enable = true;
|
|
appConfig.zen-twilight = {
|
|
isAllowed = true;
|
|
isSystem = false;
|
|
};
|
|
};
|
|
};
|
|
|
|
# EST
|
|
time.timeZone = "America/New_York";
|
|
|
|
security = {
|
|
# lets use doas and not sudo!
|
|
doas.enable = true;
|
|
sudo.enable = false;
|
|
# Configure doas
|
|
doas.extraRules = [
|
|
{
|
|
users = [ username ];
|
|
keepEnv = true;
|
|
persist = true;
|
|
}
|
|
];
|
|
};
|
|
|
|
# Select internationalisation properties.
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
|
|
|
# Enable Bluetooth
|
|
hardware.bluetooth = {
|
|
enable = true;
|
|
powerOnBoot = true;
|
|
|
|
# Enable experimental features for battery % of bluetooth devices
|
|
settings.General.Experimental = true;
|
|
};
|
|
|
|
# Apply gtk themes by enabling dconf
|
|
programs.dconf.enable = true;
|
|
|
|
# Enable sound with pipewire.
|
|
services.pulseaudio.enable = false; # pipewire >>>>>>> pulseaudio
|
|
security.rtkit.enable = true;
|
|
services.pipewire = {
|
|
enable = true;
|
|
alsa.enable = true;
|
|
alsa.support32Bit = true;
|
|
pulse.enable = true;
|
|
};
|
|
|
|
# Define my user account (the rest of the configuration if found in `~/.config/home-manager/...`)
|
|
users.users.${username} = {
|
|
isNormalUser = true;
|
|
extraGroups = [
|
|
"networkmanager"
|
|
"wheel"
|
|
"video"
|
|
"camera"
|
|
"adbusers"
|
|
];
|
|
# TODO! this is really bad :( I should really figure out how to do proper secrets management
|
|
hashedPasswordFile = "${./secrets/password-hash}";
|
|
};
|
|
|
|
services.gvfs.enable = true;
|
|
programs.gphoto2.enable = true;
|
|
|
|
# Enable thermal data
|
|
services.thermald.enable = true;
|
|
|
|
services.pcscd.enable = true;
|
|
programs.gnupg.agent = {
|
|
enable = true;
|
|
pinentryPackage = pkgs.pinentry-curses;
|
|
enableSSHSupport = false;
|
|
};
|
|
|
|
# System packages
|
|
environment.systemPackages = with pkgs; [
|
|
# mullvad-vpn is provided by services.mullvad-vpn.enable
|
|
|
|
#secureboot ctl
|
|
sbctl
|
|
|
|
dmidecode
|
|
|
|
doas-sudo-shim
|
|
|
|
glib
|
|
usbutils
|
|
libmtp
|
|
man-pages
|
|
man-pages-posix
|
|
|
|
# needed for home-manager
|
|
git
|
|
|
|
tmux
|
|
android-tools
|
|
];
|
|
|
|
# wayland with electron/chromium applications
|
|
environment.sessionVariables.NIXOS_OZONE_WL = "1";
|
|
|
|
# https://nixos.wiki/wiki/Fish#Setting_fish_as_your_shell
|
|
programs.fish.enable = true;
|
|
programs.bash = {
|
|
interactiveShellInit = ''
|
|
if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]
|
|
then
|
|
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
|
|
exec ${lib.getExe pkgs.fish} $LOGIN_OPTION
|
|
fi
|
|
'';
|
|
};
|
|
|
|
# port 53317 for localsend
|
|
networking.firewall.allowedUDPPorts = [ 53317 ];
|
|
networking.firewall.allowedTCPPorts = [ 53317 ];
|
|
|
|
system.stateVersion = "25.05";
|
|
nixpkgs.hostPlatform = "x86_64-linux";
|
|
|
|
documentation.enable = true;
|
|
documentation.man.enable = true;
|
|
documentation.dev.enable = true;
|
|
}
|