furthre config on laptop

This commit is contained in:
2025-07-14 15:12:21 +02:00
parent 5b2b64611e
commit e2f428bc64
54 changed files with 1479 additions and 87 deletions
+44
View File
@@ -0,0 +1,44 @@
{ config, pkgs, ... }:
{
system.stateVersion = "25.05";
nix.settings.experimental-features = [ "nix-command" "flakes" ];
boot.loader.systemd-boot.configurationLimit = 10;
# time and localization
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8";
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# networking
networking.networkmanager.enable = true;
networking.firewall.enable = true;
services.openssh.enable = true;
environment.systemPackages = with pkgs; [
# basics
lshw
git
wget
vim
neovim
# terminal related
alacritty
ranger
htop
];
}
+7
View File
@@ -0,0 +1,7 @@
{ config, lib, ... }:
{
imports = [
../../gpu/intel
];
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
+91
View File
@@ -0,0 +1,91 @@
{
config,
lib,
pkgs,
...
}:
{
imports = [
];
options.hardware.intelgpu = {
driver = lib.mkOption {
description = "Intel GPU driver to use";
type = lib.types.enum [
"i915"
"xe"
];
default = "i915";
};
loadInInitrd =
lib.mkEnableOption "Load the Intel GPU kernel module at stage 1 boot. (Added to `boot.initrd.kernelModules`)"
// {
default = true;
};
vaapiDriver = lib.mkOption {
description = "Intel VAAPI driver to use (use null to use both)";
type = lib.types.nullOr (
lib.types.enum [
"intel-vaapi-driver"
"intel-media-driver"
]
);
default = null; # Use both drivers when we don't know which one to use
};
enableHybridCodec = lib.mkEnableOption "hybrid codec support for Intel GPUs";
};
config =
let
cfg = config.hardware.intelgpu;
useIntelVaapiDriver = cfg.vaapiDriver == "intel-vaapi-driver" || cfg.vaapiDriver == null;
intel-vaapi-driver = (pkgs.intel-vaapi-driver or pkgs.vaapiIntel).override {
enableHybridCodec = cfg.enableHybridCodec;
};
intel-vaapi-driver-32 =
(pkgs.driversi686Linux.intel-vaapi-driver or pkgs.driversi686Linux.vaapiIntel).override
{
enableHybridCodec = cfg.enableHybridCodec;
};
useIntelOcl =
useIntelVaapiDriver
&& (config.hardware.enableAllFirmware or config.nixpkgs.config.allowUnfree or false);
intel-ocl = pkgs.intel-ocl;
useIntelMediaDriver = cfg.vaapiDriver == "intel-media-driver" || cfg.vaapiDriver == null;
intel-media-driver = pkgs.intel-media-driver;
intel-media-driver-32 = pkgs.driversi686Linux.intel-media-driver;
intel-compute-runtime = pkgs.intel-compute-runtime;
vpl-gpu-rt = pkgs.vpl-gpu-rt or pkgs.onevpl-intel-gpu;
in
{
boot.initrd.kernelModules = lib.optionals cfg.loadInInitrd [ cfg.driver ];
hardware.graphics.extraPackages =
lib.optionals useIntelVaapiDriver [ intel-vaapi-driver ]
++ lib.optionals useIntelOcl [ intel-ocl ]
++ lib.optionals useIntelMediaDriver [
intel-media-driver
intel-compute-runtime
vpl-gpu-rt
];
hardware.graphics.extraPackages32 =
lib.optionals useIntelVaapiDriver [ intel-vaapi-driver-32 ]
++ lib.optionals useIntelMediaDriver [ intel-media-driver-32 ];
assertions = [
{
assertion = (
cfg.driver != "xe" || lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.8"
);
message = "Intel Xe GPU driver is not supported on kernels earlier than 6.8. Update or use the i915 driver.";
}
];
};
}
+6
View File
@@ -0,0 +1,6 @@
{ lib, ... }:
{
imports = [];
services.xserver.videoDrivers = lib.mkDefault [ "modesetting" "nvidia"];
}
+31
View File
@@ -0,0 +1,31 @@
{ ... }:
{
# This runs only intel/amdgpu igpus and nvidia dgpus do not drain power.
##### disable nvidia, very nice battery life.
boot.extraModprobeConfig = ''
blacklist nouveau
options nouveau modeset=0
'';
services.udev.extraRules = ''
# Remove NVIDIA USB xHCI Host Controller devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA USB Type-C UCSI devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA Audio devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA VGA/3D controller devices
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
'';
boot.blacklistedKernelModules = [
"nouveau"
"nvidia"
"nvidia_drm"
"nvidia_modeset"
];
}
+37
View File
@@ -0,0 +1,37 @@
{ lib, config, ... }:
{
imports = [ ./. ];
options = {
hardware.nvidia.primeBatterySaverSpecialisation = lib.mkEnableOption "configure a specialisation which turns on NVIDIA Prime battery saver";
};
config = {
hardware.nvidia.prime = {
offload = {
enable = lib.mkOverride 990 true;
enableOffloadCmd = lib.mkIf config.hardware.nvidia.prime.offload.enable true; # Provides `nvidia-offload` command.
};
# Hardware should specify the bus ID for intel/nvidia devices
};
specialisation = lib.mkIf config.hardware.nvidia.primeBatterySaverSpecialisation {
battery-saver.configuration = {
system.nixos.tags = [ "battery-saver" ];
imports = [
# Leave only the integrated GPU enabled
./disable.nix
];
hardware.nvidia = {
prime.offload.enable = lib.mkForce false;
powerManagement = {
enable = lib.mkForce false;
finegrained = lib.mkForce false;
};
};
};
};
};
}
+10
View File
@@ -0,0 +1,10 @@
{ lib, config, ... }:
let
nvidiaPackage = config.hardware.nvidia.package;
in
{
imports = [ ../. ];
# enable the open source drivers if the package supports it
hardware.nvidia.open = lib.mkOverride 990 (nvidiaPackage ? open && nvidiaPackage ? firmware);
}
+13
View File
@@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
];
hardware.bluetooth.enable = true;
hardware.bluetooth.settings = {
General = {
Enable = "Source,Sink,Media,Socket";
};
};
services.blueman.enable = true;
}
+7
View File
@@ -0,0 +1,7 @@
{ config, lib, pkgs, ... }
{
environment.systemPackages = with pkgs; [
]
# Enable CUPS to print documents.
services.printing.enable = true;
}
+20
View File
@@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
{
imports = [
./fonts.nix
];
environment.systemPackages = with pkgs; [
# browsers
brave
firefox
chromium
# misc
];
# Enable CUPS to print documents.
services.printing.enable = true;
location.provider = "geoclue2";
}
+11
View File
@@ -0,0 +1,11 @@
{ config, lib, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
jdk
jetbrains.pycharm-professional
mongodb-compass
];
}
+10
View File
@@ -0,0 +1,10 @@
{ config, pkgs, ... }
{
# ly display manager
services.ly.enable = true;
# setup persmission for set in wayland
programs.seatd.enable = true;
}
+8
View File
@@ -0,0 +1,8 @@
{ config, lib, pkgs, ... }:
{
virtualisation.docker.enable = true;
virtualisation.docker.rootless = {
enable = true;
setSocketVariable = true;
};
}
+6
View File
@@ -0,0 +1,6 @@
{ config, lib, pkgs, ... }:
{
fonts.packages = with pkgs; [
nerd-fonts.jetbrains-mono
];
}
+44
View File
@@ -0,0 +1,44 @@
{ config, lib, pkgs, ... }:
{
services.keyd = {
enable = true;
keyboards = {
default = {
ids = [ "*" ];
settings = {
main = {
capslock = "layer(capslayer)";
"'" = "G-'";
};
otherlayer = {};
capslayer = {
# arrow keys vimlike
j = "down";
h = "left";
k = "up";
l = "right";
# german special keys
a = "G-q";
o = "G-p";
u = "G-y";
s = "G-s";
e = "G-5";
};
};
extraConfig = ''
# extra conf here
'';
};
};
};
# Optional, but makes sure that when you type the make palm rejection work with keyd
# https://github.com/rvaiya/keyd/issues/723
environment.etc."libinput/local-overrides.quirks".text = ''
[Serial Keyboards]
MatchUdevType=keyboard
MatchName=keyd virtual keyboard
AttrKeyboardIntegration=internal
'';
}
+55
View File
@@ -0,0 +1,55 @@
{
config,
lib,
vars,
pkgs,
...
}:
{
powerManagement.powertop.enable = true; # enable powertop auto tuning on startup.
networking.networkmanager.wifi.powersave = true;
services.system76-scheduler.settings.cfsProfiles.enable = true; # Better scheduling for CPU cycles - thanks System76!!!
services.thermald.enable = true; # Enable thermald, the temperature management daemon. (only necessary if on Intel CPUs)
services.power-profiles-daemon.enable = false; # Disable GNOMEs power management
services.tlp = {
enable = true; # Enable TLP (better than gnomes internal power manager)
settings = {
CPU_BOOST_ON_AC = 1;
CPU_BOOST_ON_BAT = 1;
CPU_HWP_DYN_BOOST_ON_AC = 1;
CPU_HWP_DYN_BOOST_ON_BAT = 1;
CPU_SCALING_GOVERNOR_ON_AC = "performance";
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
CPU_ENERGY_PERF_POLICY_ON_BAT = "balance_power";
PLATFORM_PROFILE_ON_AC = "performance";
PLATFORM_PROFILE_ON_BAT = "balanced";
START_CHARGE_THRESH_BAT0 = 75;
STOP_CHARGE_THRESH_BAT0 = 81;
};
};
environment.systemPackages = with pkgs; [
powertop
];
programs.light.enable = true;
powerManagement = {
enable = true;
cpuFreqGovernor = "schedutil";
};
services.auto-cpufreq.enable = true;
services.auto-cpufreq.settings = {
battery = {
governor = "powersave";
turbo = "never";
};
charger = {
governor = "performance";
turbo = "auto";
};
};
}
+56
View File
@@ -0,0 +1,56 @@
{ config, lib, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
];
# Enable OpenGL
hardware.graphics = {
enable = true;
};
# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = ["modesetting" "nvidia"];
hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
# Enable this if you have graphical corruption issues or application crashes after waking
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
# of just the bare essentials.
powerManagement.enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = true;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
prime = {
# Make sure to use the correct Bus ID values for your system
offload = {
enable = true;
enableOffloadCmd = true;
};
# Bus ID of the Intel GPU.
intelBusId = lib.mkDefault "PCI:0:2:0";
# Bus ID of the NVIDIA GPU.
nvidiaBusId = lib.mkDefault "PCI:1:0:0";
};
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.stable;
};
}
@@ -0,0 +1,45 @@
{ config, pkgs, ... }:
let
hibernateEnvironment = {
HIBERNATE_SECONDS = "10";
HIBERNATE_LOCK = "/var/run/autohibernate.lock";
};
in {
systemd.services."awake-after-suspend-for-a-time" = {
description = "Sets up the suspend so that it'll wake for hibernation only if not on AC power";
wantedBy = [ "suspend.target" ];
before = [ "systemd-suspend.service" ];
environment = hibernateEnvironment;
script = ''
if [ $(cat /sys/class/power_supply/AC/online) -eq 0 ]; then
curtime=$(date +%s)
echo "$curtime $1" >> /tmp/autohibernate.log
echo "$curtime" > $HIBERNATE_LOCK
${pkgs.utillinux}/bin/rtcwake -m no -s $HIBERNATE_SECONDS
else
echo "System is on AC power, skipping wake-up scheduling for hibernation." >> /tmp/autohibernate.log
fi
'';
serviceConfig.Type = "simple";
};
systemd.services."hibernate-after-recovery" = {
description = "Hibernates after a suspend recovery due to timeout";
wantedBy = [ "suspend.target" ];
after = [ "systemd-suspend.service" ];
environment = hibernateEnvironment;
script = ''
curtime=$(date +%s)
sustime=$(cat $HIBERNATE_LOCK)
rm $HIBERNATE_LOCK
if [ $(($curtime - $sustime)) -ge $HIBERNATE_SECONDS ] ; then
systemctl hibernate
else
${pkgs.utillinux}/bin/rtcwake -m no -s 1
fi
'';
serviceConfig.Type = "simple";
};
}
+47
View File
@@ -0,0 +1,47 @@
{ config, lib, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
xwayland
sway
swaylock
swayidle
nwg-displays
# screenshot stuff
grim
slurp
wl-clipboard
mako
];
programs.dconf.enable = true;
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd sway";
user = "greeter";
};
};
};
# x compatibility
programs.xwayland.enable = true;
# enable polkit to use home manager sway config
security.polkit.enable = true;
# for swaylock
security.pam.services.swaylock = {};
# keyring setup
programs.seahorse.enable = true;
services.gnome.gnome-keyring.enable = true;
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
}
+20
View File
@@ -0,0 +1,20 @@
{ config, pkgs, ... }:
{
# Install tools
environment.systemPackages = with pkgs; [
pavucontrol
];
# Enable PipeWire and its PulseAudio compatibility layer
services.pipewire = {
enable = true;
audio.enable = true;
pulse.enable = true;
alsa.enable = true;
alsa.support32Bit = true;
};
# Disable legacy PulseAudio
services.pulseaudio.enable = false;
}
+18
View File
@@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
pavucontrol
];
services.pipewire.enable = false;
services.pulseaudio.enable = true;
services.pulseaudio.configFile = pkgs.writeText "default.pa" ''
load-module module-bluetooth-policy
load-module module-bluetooth-discover
## module fails to load with
## module-bluez5-device.c: Failed to get device path from module arguments
## module.c: Failed to load module "module-bluez5-device" (argument: ""): initialization failed.
# load-module module-bluez5-device
# load-module module-bluez5-discover
'';
}
+7
View File
@@ -0,0 +1,7 @@
{ config, lib, ... }:
{
boot.blacklistedKernelModules = lib.optionals (!config.hardware.enableRedistributableFirmware) [
"ath3k"
];
}
+13
View File
@@ -0,0 +1,13 @@
{ config, lib, ... }:
{
imports = [ ../. ];
# Gnome 40 introduced a new way of managing power, without tlp.
# However, these 2 services clash when enabled simultaneously.
# https://github.com/NixOS/nixos-hardware/issues/260
services.tlp.enable = lib.mkDefault (
(lib.versionOlder (lib.versions.majorMinor lib.version) "21.05")
|| !config.services.power-profiles-daemon.enable
);
}
+5
View File
@@ -0,0 +1,5 @@
{ lib, ... }:
{
services.fstrim.enable = lib.mkDefault true;
}