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
+10
View File
@@ -20,6 +20,16 @@
./hosts/dev-vm/default.nix
];
};
alex-laptop = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit home-manager;
};
modules = [
./system/common.nix
./hosts/alex-laptop/default.nix
];
};
};
};
}
+28
View File
@@ -0,0 +1,28 @@
{ lib, ... }:
let
thermald-conf = ./thermald-conf.xml;
in
{
imports = [
../../system/cpu/intel
../../system/pc/laptop
../../system/pc/ssd
];
# Boot loader
boot.kernelParams = lib.mkDefault [ "acpi_rev_override" ];
# This will save you money and possibly your life!
services.thermald.enable = lib.mkDefault true;
# Thermald doesn't have a default config for the 9500 yet, the one in this repo
# was generated with dptfxtract-static (https://github.com/intel/dptfxtract)
services.thermald.configFile = lib.mkDefault thermald-conf;
# WiFi speed is slow and crashes by default (https://bugzilla.kernel.org/show_bug.cgi?id=213381)
# disable_11ax - required until ax driver support is fixed
# power_save - works well on this card
boot.extraModprobeConfig = ''
options iwlwifi power_save=1 disable_11ax=1
'';
}
+27
View File
@@ -0,0 +1,27 @@
{ lib, ... }:
{
imports = [
../default.nix
../../../system/gpu/nvidia/prime.nix
../../../system/gpu/nvidia/turing
];
hardware.graphics.enable = true;
hardware.nvidia = {
modesetting.enable = true;
nvidiaSettings = true;
powerManagement.enable = false;
powerManagement.finegrained = true;
};
hardware.nvidia.prime = {
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";
};
}
+205
View File
@@ -0,0 +1,205 @@
<?xml version="1.0"?>
<!-- BEGIN -->
<ThermalConfiguration>
<Platform>
<Name> Auto generated </Name>
<ProductName>XPS 15 9500</ProductName>
<Preference>QUIET</Preference>
<PPCC>
<PowerLimitIndex>0</PowerLimitIndex>
<PowerLimitMinimum>10000</PowerLimitMinimum>
<PowerLimitMaximum>68000</PowerLimitMaximum>
<TimeWindowMinimum>56000</TimeWindowMinimum>
<TimeWindowMaximum>56000</TimeWindowMaximum>
<StepSize>250</StepSize>
</PPCC>
<ThermalZones>
<ThermalZone>
<Type>auto_zone_0</Type>
<TripPoints>
<TripPoint>
<SensorType>SEN2</SensorType>
<Temperature>55000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>1</SamplingPeriod>
<TargetState>45000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>SEN2</SensorType>
<Temperature>57000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>1</SamplingPeriod>
<TargetState>40000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>SEN2</SensorType>
<Temperature>60000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>1</SamplingPeriod>
<TargetState>35000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>SEN2</SensorType>
<Temperature>64000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>3</SamplingPeriod>
<TargetState>35000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>SEN2</SensorType>
<Temperature>68000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>3</SamplingPeriod>
<TargetState>20000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>SEN2</SensorType>
<Temperature>70000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>3</SamplingPeriod>
<TargetState>15000000</TargetState>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
<ThermalZone>
<Type>auto_zone_1</Type>
<TripPoints>
<TripPoint>
<SensorType>SEN5</SensorType>
<Temperature>38000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>1</SamplingPeriod>
<TargetState>22000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>SEN5</SensorType>
<Temperature>39000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>1</SamplingPeriod>
<TargetState>17000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>SEN5</SensorType>
<Temperature>40000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>3</SamplingPeriod>
<TargetState>12000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>SEN5</SensorType>
<Temperature>41000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>3</SamplingPeriod>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
<ThermalZone>
<Type>auto_zone_2</Type>
<TripPoints>
<TripPoint>
<SensorType>VIR1</SensorType>
<Temperature>57000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>3</SamplingPeriod>
<TargetState>15000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>VIR1</SensorType>
<Temperature>60000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>3</SamplingPeriod>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
<ThermalZone>
<Type>auto_zone_3</Type>
<TripPoints>
<TripPoint>
<SensorType>VIR2</SensorType>
<Temperature>76000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>1</SamplingPeriod>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
<ThermalZone>
<Type>auto_zone_4</Type>
<TripPoints>
<TripPoint>
<SensorType>WRLS</SensorType>
<Temperature>80000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>1</SamplingPeriod>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
<ThermalZone>
<Type>auto_zone_5</Type>
<TripPoints>
<TripPoint>
<SensorType>STG1</SensorType>
<Temperature>66000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>1</SamplingPeriod>
<TargetState>19000000</TargetState>
</CoolingDevice>
</TripPoint>
<TripPoint>
<SensorType>STG1</SensorType>
<Temperature>90000</Temperature>
<Type>Passive</Type>
<CoolingDevice>
<Type>B0D4</Type>
<SamplingPeriod>1</SamplingPeriod>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
</ThermalZones>
</Platform>
</ThermalConfiguration>
<!-- END -->
Binary file not shown.
+71
View File
@@ -0,0 +1,71 @@
{ config, pkgs, lib, home-manager, ... }:
let
thermald-conf = ./thermald-conf.xml;
in
{
imports = [
../../system/modules/sway.nix
../../system/modules/dev.nix
../../system/modules/docker.nix
../../system/modules/bluetooth.nix
../../system/modules/desktop_tools.nix
../../system/modules/laptop.nix
../../system/modules/keyd.nix
../../system/modules/suspend_then_hibernate_on_battery.nix
../../system/pc/audio/pipewire.nix
./hardware-configuration.nix
../../hardware/xps-9500/nvidia
# home manager integration
home-manager.nixosModules.home-manager
./user.nix
];
home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true;
# bootloader
boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
};
# hibernation setup
boot.resumeDevice = "/dev/disk/by-uuid/55f855b8-ffa8-4369-be7d-fcc13b40c074";
#services.power-profiles-daemon.enable = true;
# Suspend first then hibernate when closing the lid
services.logind.lidSwitch = "suspend-then-hibernate";
# Hibernate on power button pressed
services.logind.powerKey = "hibernate";
services.logind.powerKeyLongPress = "poweroff";
# Suspend first
boot.kernelParams = [ "resume" "mem_sleep_default=s2idle" ];
# Define time delay for hibernation
systemd.sleep.extraConfig = ''
HibernateDelaySec=30m
SuspendState=mem
'';
# networking and connection
networking.hostName = "alex-laptop";
hardware.bluetooth.powerOnBoot = false;
# time and localization
time.timeZone = "Europe/Berlin";
# users
programs.fish.enable = true;
users.users.alex = {
isNormalUser = true;
extraGroups = [ "wheel" "video" "network" "audio" "networkmanager" ];
shell = pkgs.fish;
};
}
@@ -0,0 +1,45 @@
# 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, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "uas" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ "cryptd" ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/mapper/cryptroot";
fsType = "ext4";
};
boot.initrd.luks.devices."cryptroot".device = "/dev/disk/by-uuid/95e9780b-b902-4da8-bff1-451e0d5e3240";
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/E88C-AD28";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
};
swapDevices =
[ { device = "/dev/disk/by-uuid/55f855b8-ffa8-4369-be7d-fcc13b40c074"; }
];
# 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.enp57s0u2.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.enableAllFirmware = true;
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
+20
View File
@@ -0,0 +1,20 @@
{ config, pkgs, ... }:
{
home-manager.users.alex= {
imports = [
../../user/modules/common.nix
../../user/modules/sway.nix
../../user/modules/rofi.nix
../../user/modules/waybar.nix
../../user/modules/terminal.nix
../../user/modules/ranger.nix
../../user/modules/fish.nix
../../user/modules/alacritty.nix
../../user/modules/zellij.nix
];
home.packages = with pkgs; [
neovim
];
};
}
-4
View File
@@ -1,4 +0,0 @@
{ pkgs, ... }
{
}
-29
View File
@@ -1,29 +0,0 @@
{ config, lib, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
xwayland
ly
sway
swaylock
swayidle
waybar
nwg-displays
# screenshot stuff
grim
slurp
wl-clipboard
mako
];
services.displayManager.ly.enable = true;
programs.xwayland.enable = true;
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
}
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
# Check the current state of the speaker
state=$(amixer -D pulse sget Master | awk '/\[on\]/{print "unmute"; exit} /\[off\]/{print "mute"; exit}')
# Toggle the state of the speaker
#
if [ "$state" = "[on] "]; then
amixer
# amixer -D pulse sset Master "$state" > /dev/null
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
check() {
command -v "$1" 1>/dev/null
}
notify() {
check notify-send && {
notify-send -a "Color Picker" "$@"
return
}
echo "$@"
}
loc="$HOME/.cache/colorpicker"
[ -d "$loc" ] || mkdir -p "$loc"
[ -f "$loc/colors" ] || touch "$loc/colors"
limit=10
[[ $# -eq 1 && $1 = "-l" ]] && {
cat "$loc/colors"
exit
}
[[ $# -eq 1 && $1 = "-j" ]] && {
text="$(head -n 1 "$loc/colors")"
mapfile -t allcolors < <(tail -n +2 "$loc/colors")
# allcolors=($(tail -n +2 "$loc/colors"))
tooltip="<b> COLORS</b>\n\n"
tooltip+="-> <b>$text</b> <span color='$text'></span> \n"
for i in "${allcolors[@]}"; do
tooltip+=" <b>$i</b> <span color='$i'></span> \n"
done
cat <<EOF
{ "text":"<span color='$text'></span>", "tooltip":"$tooltip"}
EOF
exit
}
check hyprpicker || {
notify "hyprpicker is not installed"
exit
}
killall -q hyprpicker
color=$(hyprpicker)
check wl-copy && {
echo "$color" | sed -z 's/\n//g' | wl-copy
}
prevColors=$(head -n $((limit - 1)) "$loc/colors")
echo "$color" >"$loc/colors"
echo "$prevColors" >>"$loc/colors"
sed -i '/^$/d' "$loc/colors"
pkill -RTMIN+1 waybar
+53
View File
@@ -0,0 +1,53 @@
# Temp file to store previous readings
tmpfile="/tmp/cpu_prev_all"
# Get all per-core lines
mapfile -t cpu_lines < <(grep '^cpu[0-9]' /proc/stat)
# On first run, save and exit
if [[ ! -f $tmpfile ]]; then
printf "%s\n" "${cpu_lines[@]}" > "$tmpfile"
echo "..." # No previous data
exit 0
fi
# Load previous readings
mapfile -t prev_lines < "$tmpfile"
# Sanity check
if (( ${#cpu_lines[@]} != ${#prev_lines[@]} )); then
echo "..." # Core count mismatch (e.g., suspend/resume)
printf "%s\n" "${cpu_lines[@]}" > "$tmpfile"
exit 0
fi
total_usage=0
for i in "${!cpu_lines[@]}"; do
# Current
read -r cpu user nice system idle iowait irq softirq steal _ _ <<< "${cpu_lines[$i]}"
total_now=$((user + nice + system + idle + iowait + irq + softirq + steal))
idle_now=$((idle + iowait))
# Previous
read -r _ pu pn ps pi piw pir psf pst _ _ <<< "${prev_lines[$i]}"
total_prev=$((pu + pn + ps + pi + piw + pir + psf + pst))
idle_prev=$((pi + piw))
# Deltas
diff_total=$((total_now - total_prev))
diff_idle=$((idle_now - idle_prev))
if ((diff_total > 0)); then
usage=$((100 * (diff_total - diff_idle) / diff_total))
total_usage=$((total_usage + usage))
fi
done
# Output total usage (per-core sum)
#echo '{"usage": ${total_usage}%}'}
printf "{ \"text\": %6.0f, \"tooltip\": \"%s\" }" "$total_usage" "test"
# Save current readings
printf "%s\n" "${cpu_lines[@]}" > "$tmpfile"
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
format() {
if [ "$1" -eq 0 ]; then
echo '-'
else
echo "$1"
fi
}
if ! updates_arch="$(checkupdates | wc -l)"; then
updates_arch=0
fi
if ! updates_aur="$(yay -Qum 2>/dev/null | wc -l)"; then
updates_aur=0
fi
updates="$((updates_arch + updates_aur))"
if [ "$updates" -gt 0 ]; then
echo " ($(format $updates_arch)/$(format $updates_aur))"
else
echo
fia
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
pkgmgr="pacman"
hash paru 2>/dev/null && pkgmgr="paru"
hash yay 2>/dev/null && pkgmgr="yay"
IFS=$'\n'$'\r'
updatesli=($($pkgmgr -Qu))
text=${#updatesli[@]}
icon=""
[ $text -eq 0 ] && icon="" || icon="📦"
for i in ${updatesli[@]}
do
tooltip+="$i\n"
done
cat << EOF
{ "text":"$icon", "tooltip":"UPDATES: $text"}
EOF
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
if [ -f /sys/class/power_supply/BAT*/current_now ]; then
powerDraw="󰠰 $(($(cat /sys/class/power_supply/BAT*/current_now)/1000000))w"
fi
cat << EOF
{ "text":"$powerDraw", "tooltip":"power Draw $powerDraw"}
EOF
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
BSSIDS="$(nmcli device wifi list |
awk 'NR>1 {if ($1 != "*") {print $1}}' |
tr -d ":" |
tr "\n" ",")"
LOC=""
REQUEST_GEO="$(wget -qO - http://openwifi.su/api/v1/bssids/"$BSSIDS")"
if [[ "$(jq ".count_results" <<< "$REQUEST_GEO")" -gt 0 ]] ; then
LAT="$(jq ".lat" <<< "$REQUEST_GEO")"
LON="$(jq ".lon" <<< "$REQUEST_GEO")"
LOC="$LAT,$LON"
fi
text="$(curl -s "https://wttr.in/$LOC?format=1" | sed 's/ //g')"
tooltip="$(curl -s "https://wttr.in/$LOC?0QT" |
sed 's/\\/\\\\/g' |
sed ':a;N;$!ba;s/\n/\\n/g' |
sed 's/"/\\"/g')"
if ! grep -q "Unknown location" <<< "$text"; then
echo "{\"text\": \"$text\", \"tooltip\": \"<tt>$tooltip</tt>\", \"class\": \"weather\"}"
fi
+3 -13
View File
@@ -4,6 +4,8 @@
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 = {
@@ -26,26 +28,14 @@
networking.firewall.enable = true;
services.openssh.enable = true;
# auth stuff
security.polkit.enable = true;
# keyring setup
programs.seahorse.enable = true;
services.gnome.gnome-keyring.enable = true;
# shells
programs.fish.enable = true;
environment.systemPackages = with pkgs; [
# basics
lshw
git
wget
vim
neovim
seahorse
# terminal related
alacritty
ranger
+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;
}
@@ -4,10 +4,4 @@
]
# Enable CUPS to print documents.
services.printing.enable = true;
# sound setup
nixpkgs.config.pulseaudio.enable = true;
services.pulseaudio.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";
}
+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;
}
+21
View File
@@ -0,0 +1,21 @@
{ pkgs, ... }:
{
programs.alacritty = {
enable = true;
settings = {
terminal.shell = {
program = "/bin/sh";
args = [
"-c"
''
if command -v zellij >/dev/null 2>&1; then
exec zellij
else
exec "${SHELL:-/bin/bash}"
fi
''
];
};
};
};
}
@@ -2,14 +2,7 @@
{
home.packages = with pkgs; [
git
starship
];
programs.git = {
enable = true;
};
home.stateVersion = "24.05";
}
+9
View File
@@ -0,0 +1,9 @@
{ pkgs, ... }:
{
programs.fish = {
enable = true;
interactiveShellInit = ''
set fish_greeting # Disable greeting
'';
};
}
+12
View File
@@ -0,0 +1,12 @@
{ lib, ... }:
{
# night light
services.gammastep = {
enable = true;
provider = "geoclue2";
tray = true;
temperature = {
night = 1700;
};
};
}
+4
View File
@@ -0,0 +1,4 @@
{ config, lib, pkgs, ... }:
{
}
+45 -23
View File
@@ -4,20 +4,40 @@ let
# define some constants
mod = "Mod4";
alt = "Mod1";
num_workspaces = 9;
ws = builtins.listToAttrs (builtins.genList (n: {
name = "ws${toString (n + 1)}";
value = toString (n + 1);
}) num_workspaces);
in
{
imports = [
./swaylock.nix
./swayidle.nix
./gammastep.nix
];
# enable clipboard history
services.cliphist.enable = true;
# define cursor, also fixes tiny cursor on hidpi
home.pointerCursor = {
name = "Adwaita";
package = pkgs.adwaita-icon-theme;
size = 24;
x11 = {
enable = true;
defaultCursor = "Adwaita";
};
};
# configure sway
wayland.windowManager.sway = {
enable = true;
systemd.enable = true;
wrapperFeatures.gtk = true;
config = rec {
config = rec {
modifier = mod;
terminal = "alacritty";
startup = [
{ command = "blueman-applet";}
];
defaultWorkspace = "1";
bars = [];
fonts = {
names = [ "MesloLGS NF" ];
size = 11.0;
@@ -25,35 +45,37 @@ in
input = {
"type:touchpad" = {
tap = "enabled";
dwt = "enabled";
click_method = "clickfinger";
natural_scroll = "enabled";
tap_button_map = "lrm";
};
"type:keyboard" = {
"*" = {
xkb_layout = "us";
xkb_variant = "intl";
};
};
gaps = {
inner = 8;
outer = -4;
gaps = { inner = 8; outer = -4;
smartGaps = true;
smartBorders = "on";
};
keybindings = lib.mkOptionDefault {
"${mod}+Return" = "exec alacritty --command tmux";
"${mod}+Ctrl+Return" = "exec alacritty";
"${mod}+Return" = "exec alacritty";
"${mod}+Ctrl+Return" = "exec alacritty zellij";
"${mod}+Shift+Return" = "exec rofi -show combi";
"${mod}+Print" = "exec flameshot full -c";
"${mod}+Shift+Print" = "exec flameshot gui";
"${mod}+Ctrl+Shift+Print" = "exec simplescreenrecorder --start-hidden --start-recording";
"${mod}+Ctrl+l" = "exec swaylock";
"${mod}+Shift+r" = "reload";
"XF86AudioLowerVolume" = "exec pamixer --decrease 5";
"XF86AudioRaiseVolume" = "exec pamixer --increase 5";
"XF86AudioMute" = "exec pamixer -t";
"${mod}+XF86AudioMute" = "exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"${mod}+Ctrl+Shift+Alt+s" = "exec systemctl suspend";
"${mod}+Ctrl+Shift+Alt+h" = "exec systemctl hibernate";
"XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
"XF86AudioRaiseVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+";
"XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
"${mod}+XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioNext" = "exec playerctl next";
@@ -73,6 +95,7 @@ in
"${mod}+u" = "border none";
"${mod}+y" = "border pixel 1";
"${mod}+n" = "border normal";
"${mod}+Shift+n" = "border none";
"${mod}+h" = "focus left";
"${mod}+j" = "focus down";
@@ -112,9 +135,8 @@ in
"${mod}+Shift+s" = "sticky toggle";
"${mod}+a" = "focus parent";
"${mod}+Ctrl+l" = "exec i3lock -c 000000";
"${mod}+Shift+r" = "reload";
} // builtins.listToAttrs (builtins.concatMap (n: let
# create keybindings for workspaces
key = toString (n + 1);
in [
{
@@ -191,7 +213,7 @@ in
};
};
extraConfig = ''
default_border none
default_border pixel 1
floating_modifier ${mod}
# === Floating Windows ===
+53
View File
@@ -0,0 +1,53 @@
{ lib, pkgs, ... }:
{
# config swayidle
services.swayidle =
let
# Lock command
lock = "${pkgs.swaylock}/bin/swaylock --daemonize";
# TODO: modify "display" function based on your window manager
# Sway
display = status: "swaymsg 'output * power ${status}'";
in
{
enable = true;
timeouts = [
{
timeout = 295; # in seconds
command = "${pkgs.libnotify}/bin/notify-send 'Locking in 5 seconds' -t 5000";
}
{
timeout = 300;
command = lock;
}
{
timeout = 305;
command = display "off";
resumeCommand = display "on";
}
{
timeout = 600;
command = "${pkgs.systemd}/bin/systemctl suspend-then-hibernate";
}
];
events = [
{
event = "before-sleep";
# adding duplicated entries for the same event may not work
command = (display "off") + "; " + lock;
}
{
event = "after-resume";
command = display "on";
}
{
event = "lock";
command = (display "off") + "; " + lock;
}
{
event = "unlock";
command = display "on";
}
];
};
}
+22
View File
@@ -0,0 +1,22 @@
{ lib, pkgs, ... }:
let
wallpaper = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/8957e93c95867faafec7f9988cedddd6837859fa/wallpapers/nix-wallpaper-binary-black.png";
sha256 = "0v3111a1ihsh4ajijbjh6y7a8p5cb5g3rdxqjbzx37pn1k9s254s";
};
in
{
programs.swaylock = {
enable = true;
settings = {
image = "${wallpaper}";
color = "000000";
font-size = 24;
indicator-idle-visible = false;
indicator-radius = 100;
line-color = "ffffff";
show-failed-attempts = true;
};
};
}
+23
View File
@@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
{
home.packages = with pkgs; [
];
programs.starship.enable = true;
programs.fish = {
enable = true;
interactiveShellInit = ''
if type -q starship
starship init fish | source
end
export VISUAL=nvim;
export EDITOR=nvim;
'';
};
programs.zellij = {
enable = true;
};
}
@@ -1,15 +1,41 @@
{ config, lib, pkgs, ... }:
{
let
scriptDir = ./../../scripts/waybar;
# Get all files in the scriptDir
scriptFiles = builtins.filter (name:
(builtins.readDir scriptDir).${name} == "regular"
) (builtins.attrNames (builtins.readDir scriptDir));
# Map to home.file entries
waybarScripts = builtins.listToAttrs (map (name: {
name = "bin/${name}";
value = {
source = "${scriptDir}/${name}";
executable = true;
};
}) scriptFiles);
in {
home.packages = with pkgs; [
gnugrep
coreutils
gawk
bash
];
home.file = waybarScripts;
programs.waybar = {
enable = true;
systemd.enable = true;
settings = [{
command = "waybar";
layer = "top";
position = "top";
"modules-left" = [
"tray"
"custom/cpu_linux"
#"custom/cpu_linux"
"cpu"
"temperature"
"memory"
"disk"
@@ -51,9 +77,12 @@
"memory" = {
format = " {percentage}% {used:.1f}/{total:.1f} S: {swapUsed:.1f}/{swapTotal:.1f}";
};
"cpu" = {
interval = 1;
format = "{usage}% ";
};
"custom/cpu_linux" = {
exec = "~/.config/waybar/scripts/cpu_linux.sh";
exec = "~/bin/cpu_linux.sh";
"return-type" = "json";
interval = 2;
format = ": {text}%";
@@ -175,7 +204,7 @@
format = "{capacity}% <span font='16px'>{icon}</span> {power:.2f}W {time}";
format-time = "{H}h {M}min";
tooltip = "{time}";
format-charging = "{capacity}% Full at {full-at}%";
format-charging = "{capacity}% Full at {timeTo}%";
format-plugged = "{capacity}% 󰠠";
format-icons = [
"󰪞" "󰪟" "󰪠" "󰪡"
@@ -183,5 +212,94 @@
];
};
}];
style = ''
* {
font-family: "JetBrainsMono Nerd Font,JetBrainsMono NF" ;
color: white;
}
window#waybar {
background: transparent;
}
.modules-right {
background: #000000;
}
.modules-center {
background: #000000;
}
.modules-left {
background: #000000;
}
#battery,
#custom-clipboard,
#custom-colorpicker,
#custom-powerDraw,
#bluetooth,
#pulseaudio,
#network,
#disk,
#memory,
#backlight,
#cpu,
#temperature,
#custom-weather,
#idle_inhibitor,
#jack,
#tray,
#window,
#workspaces,
#clock {
min-width: 1ex;
padding-right: 5px;
}
#tray menu * {
color: black;
}
#temperature.critical,
#pulseaudio {
min-width: 5ex;
}
#pulseaudio.muted {
color: #FF0000;
}
#pulseaudio.mic.muted {
color: #ffffff;
}
#pulseaudio.mic:not(.source-muted) {
color: #fc0202;
}
#clock{
color: #f9780e;
}
#battery.charging {
color: #ffffff;
background-color: #26A65B;
}
#battery.warning:not(.charging) {
background-color: #ffbe61;
color: black;
}
#battery.critical:not(.charging) {
background-color: #f53c3c;
color: #ffffff;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#network.speed {
min-width: 30ex;
}
'';
};
}
+12
View File
@@ -0,0 +1,12 @@
{ pkgs, ... }:
{
programs.zellij = {
enable = true;
enableFishIntegration = true;
settings = {
theme = "dracula";
copy_on_select = true;
show_startup_tips = false;
};
};
}