Major config overhaul: use custom modules, setup for multi-host config, and less boilerplate

This commit is contained in:
Emmet K
2025-02-09 16:50:26 -06:00
parent 1fa8b17b07
commit 0453901d17
303 changed files with 3560 additions and 5566 deletions

15
hosts/README.org Normal file
View File

@@ -0,0 +1,15 @@
#+title: System Profiles
This directory contains various system profiles which can easily be set in [[../flake.nix][my flake.nix]] by setting the =profile= variable. Each profile directory contains a =configuration.nix= for system-level configuration and a =home.nix= for user-level configuration. Setting the =profile= variable in [[../flake.nix][my flake]] will automatically source the correct =configuration.nix= and =home.nix=.
Current profiles I have available are:
- [[./personal][Personal]] - What I would run on a personal laptop/desktop*
- [[./work][Work]] - What I would run on my work laptop/desktop*
- [[./homelab][Homelab]] - What I would run on a server or homelab*
- [[./worklab][Worklab]] - My homelab config with my work SSH keys preinstalled*
- [[./wsl][WSL]] - Windows Subsystem for Emacs (uses [[https://github.com/nix-community/NixOS-WSL][NixOS-WSL]])
- [[./nix-on-droid][Nix on Droid]] - So that I can run Emacs on my phone (uses [[https://github.com/nix-community/nix-on-droid][nix-on-droid]])
*My [[./personal][personal]] and [[./work][work]] profiles are actually functionally identical (the [[./work][work]] profile is actually imported into the [[./personal][personal]] profile)! The only difference between them is that my [[./personal][personal]] profile has a few extra things like gaming and social apps.
*My [[./homelab][homelab]] and [[./worklab][worklab]] profiles are similarly functionally identical (they both utilize the this [[./homelab/base.nix][base.nix]] file)! The only difference is that they have different preinstalled ssh keys.

View File

@@ -0,0 +1,3 @@
#+title: Just chillin'
This is my profile for a personal computer. It is functionally identical to my [[../work]] profile, but includes extra things like games and social apps!

View File

@@ -0,0 +1,50 @@
{ config, lib, pkgs, ... }:
{
config = {
systemSettings = {
# users
users = [ "emmet" ];
adminUsers = [ "emmet" ];
# hardware
cachy.enable = true;
bluetooth.enable = true;
tlp.enable = true;
printing.enable = true;
# software
flatpak.enable = false;
gaming.enable = true;
virtualization = {
docker.enable = true;
virtualMachines.enable = true;
};
# wm
hyprland.enable = true;
# dotfiles
dotfilesDir = "/etc/nixos";
# security
security = {
automount.enable = true;
blocklist.enable = true;
doas.enable = true;
firejail.enable = false; # TODO setup firejail profiles
firewall.enable = true;
gpg.enable = true;
openvpn.enable = true;
sshd.enable = false;
};
# style
stylix = {
enable = true;
theme = "io";
};
};
};
}

View File

@@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
{
imports = [
./configuration.nix
./hardware-configuration.nix
];
config = {
home-manager.users = builtins.listToAttrs
(map (user: { name = user; value =
({ imports = [ ./home.nix ../../modules/user ]; });}) config.systemSettings.users);
};
}

View File

@@ -0,0 +1,117 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, inputs, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
services.fstrim.enable = true;
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usbhid" "usb_storage" "sd_mod" "radeon" ];
boot.initrd.kernelModules = [ "radeon" ];
boot.kernelModules = [ "kvm-amd" "radeon" "zenpower" "8812au" ];
boot.blacklistedKernelModules = [ "k10temp" ];
boot.kernelParams = [ "amd_pstate=active" "acpi_osi=Linux" "acpi_wake=USB0" ];
boot.extraModulePackages = with config.boot.kernelPackages; [ zenpower rtl8812au ];
hardware.opengl.enable = true;
hardware.opengl.extraPackages = [ pkgs.rocmPackages.clr.icd ];
hardware.opengl.extraPackages32 = [ ];
#environment.systemPackages = with pkgs.rocmPackages; [ hipcc hip-common hiprand hipblas hipfft hipcub hipify ];
environment.systemPackages = with pkgs.rocmPackages; [ hipcc hip-common hiprand hipfft hipcub hipify ];
services.xserver.videoDrivers = lib.mkDefault [ "modesetting" ];
hardware.graphics = {
enable = lib.mkDefault true;
enable32Bit = lib.mkDefault true;
};
hardware.amdgpu.initrd.enable = true;
hardware.amdgpu.opencl.enable = true;
hardware.amdgpu.amdvlk.enable = true;
# makes disk io not freeze the computer
services.udev.extraRules = ''
ACTION=="add|change", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="BTKA121225GP512A", ATTR{queue/scheduler}="bfq"
'';
systemd.tmpfiles.rules =
let
rocmEnv = pkgs.symlinkJoin {
name = "rocm-combined";
paths = with pkgs.rocmPackages; [
#rocblas
#hipblas
clr
];
};
in [
"L+ /opt/rocm - - - - ${rocmEnv}"
];
# my stupid usb hub crashes systemct suspend half of the time now
# https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Sleep_hooks
systemd.services.root-suspend = {
enable = true;
description = "Root systemd suspend prehook";
unitConfig = {
Description = "Root systemd suspend prehook";
Before = "sleep.target";
};
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.uhubctl}/bin/uhubctl -a off";
};
wantedBy = [ "sleep.target" ];
};
systemd.services.root-resume = {
enable = true;
description = "Root systemd suspend posthook";
unitConfig = {
Description = "Root systemd suspend posthook";
After = "suspend.target";
};
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.uhubctl}/bin/uhubctl -a on";
};
wantedBy = [ "suspend.target" ];
};
boot.kernel.sysctl = {
"vm.swappiness" = 180;
"vm.vfs_cache_pressure" = 500;
"vm.dirty_background_ratio" = 4;
"vm.dirty_ratio" = 8;
};
fileSystems."/" =
{ device = "/dev/disk/by-uuid/88f5f921-0a64-4711-9d74-e0f8a3a1b3af";
fsType = "ext4";
};
boot.initrd.luks.devices."luks-09f429eb-1add-48da-b3b8-1a811c0d1472".device = "/dev/disk/by-uuid/09f429eb-1add-48da-b3b8-1a811c0d1472";
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/4695-0F2E";
fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ];
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp4s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp5s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

44
hosts/snowfire/home.nix Normal file
View File

@@ -0,0 +1,44 @@
{ config, lib, pkgs, ... }:
{
config = {
userSettings = {
# setup
shell = {
enable = true;
apps.enable = true;
extraApps.enable = true;
};
xdg.enable = true;
# programs
browser = "qutebrowser";
brave.enable = true;
editor = "emacs";
ranger.enable = true;
git.enable = true;
engineering.enable = true;
art.enable = true;
flatpak.enable = false;
godot.enable = true;
keepass.enable = true;
media.enable = true;
music.enable = true;
office.enable = true;
recording.enable = true;
virtualization = {
virtualMachines.enable = true;
};
# wm
hyprland.enable = true;
# style
stylix.enable = true;
# hardware
bluetooth.enable = true;
};
};
}