diff --git a/flake.nix b/flake.nix
index 24c884a..85215ef 100644
--- a/flake.nix
+++ b/flake.nix
@@ -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
+ ];
+ };
};
};
}
diff --git a/hardware/xps-9500/default.nix b/hardware/xps-9500/default.nix
new file mode 100644
index 0000000..11de5c1
--- /dev/null
+++ b/hardware/xps-9500/default.nix
@@ -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
+ '';
+}
diff --git a/hardware/xps-9500/nvidia/default.nix b/hardware/xps-9500/nvidia/default.nix
new file mode 100644
index 0000000..e51e115
--- /dev/null
+++ b/hardware/xps-9500/nvidia/default.nix
@@ -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";
+ };
+}
diff --git a/hardware/xps-9500/thermald-conf.xml b/hardware/xps-9500/thermald-conf.xml
new file mode 100644
index 0000000..bc13d35
--- /dev/null
+++ b/hardware/xps-9500/thermald-conf.xml
@@ -0,0 +1,205 @@
+
+
+
+
+ Auto generated
+ XPS 15 9500
+ QUIET
+
+ 0
+ 10000
+ 68000
+ 56000
+ 56000
+ 250
+
+
+
+ auto_zone_0
+
+
+ SEN2
+ 55000
+ Passive
+
+ B0D4
+ 1
+ 45000000
+
+
+
+ SEN2
+ 57000
+ Passive
+
+ B0D4
+ 1
+ 40000000
+
+
+
+ SEN2
+ 60000
+ Passive
+
+ B0D4
+ 1
+ 35000000
+
+
+
+ SEN2
+ 64000
+ Passive
+
+ B0D4
+ 3
+ 35000000
+
+
+
+ SEN2
+ 68000
+ Passive
+
+ B0D4
+ 3
+ 20000000
+
+
+
+ SEN2
+ 70000
+ Passive
+
+ B0D4
+ 3
+ 15000000
+
+
+
+
+
+ auto_zone_1
+
+
+ SEN5
+ 38000
+ Passive
+
+ B0D4
+ 1
+ 22000000
+
+
+
+ SEN5
+ 39000
+ Passive
+
+ B0D4
+ 1
+ 17000000
+
+
+
+ SEN5
+ 40000
+ Passive
+
+ B0D4
+ 3
+ 12000000
+
+
+
+ SEN5
+ 41000
+ Passive
+
+ B0D4
+ 3
+
+
+
+
+
+ auto_zone_2
+
+
+ VIR1
+ 57000
+ Passive
+
+ B0D4
+ 3
+ 15000000
+
+
+
+ VIR1
+ 60000
+ Passive
+
+ B0D4
+ 3
+
+
+
+
+
+ auto_zone_3
+
+
+ VIR2
+ 76000
+ Passive
+
+ B0D4
+ 1
+
+
+
+
+
+ auto_zone_4
+
+
+ WRLS
+ 80000
+ Passive
+
+ B0D4
+ 1
+
+
+
+
+
+ auto_zone_5
+
+
+ STG1
+ 66000
+ Passive
+
+ B0D4
+ 1
+ 19000000
+
+
+
+ STG1
+ 90000
+ Passive
+
+ B0D4
+ 1
+
+
+
+
+
+
+
+
diff --git a/home-manager/.rofi.nix.swp b/home-manager/.rofi.nix.swp
deleted file mode 100644
index de21e5d..0000000
Binary files a/home-manager/.rofi.nix.swp and /dev/null differ
diff --git a/hosts/alex-laptop/default.nix b/hosts/alex-laptop/default.nix
new file mode 100755
index 0000000..761486a
--- /dev/null
+++ b/hosts/alex-laptop/default.nix
@@ -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;
+ };
+}
diff --git a/hosts/alex-laptop/hardware-configuration.nix b/hosts/alex-laptop/hardware-configuration.nix
new file mode 100644
index 0000000..2a2bbb3
--- /dev/null
+++ b/hosts/alex-laptop/hardware-configuration.nix
@@ -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..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;
+}
diff --git a/hosts/alex-laptop/user.nix b/hosts/alex-laptop/user.nix
new file mode 100755
index 0000000..83e5b5d
--- /dev/null
+++ b/hosts/alex-laptop/user.nix
@@ -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
+ ];
+ };
+}
diff --git a/modules/laptop.nix b/modules/laptop.nix
deleted file mode 100644
index e21d43c..0000000
--- a/modules/laptop.nix
+++ /dev/null
@@ -1,4 +0,0 @@
-{ pkgs, ... }
-{
-
-}
diff --git a/modules/sway.nix b/modules/sway.nix
deleted file mode 100644
index 84af617..0000000
--- a/modules/sway.nix
+++ /dev/null
@@ -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;
- };
-}
diff --git a/scripts/waybar/amixer-toggle.sh b/scripts/waybar/amixer-toggle.sh
new file mode 100755
index 0000000..ca45bba
--- /dev/null
+++ b/scripts/waybar/amixer-toggle.sh
@@ -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
+
diff --git a/scripts/waybar/brightness.sh b/scripts/waybar/brightness.sh
new file mode 100644
index 0000000..7a693aa
--- /dev/null
+++ b/scripts/waybar/brightness.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+
diff --git a/scripts/waybar/colorpicker.sh b/scripts/waybar/colorpicker.sh
new file mode 100755
index 0000000..3047757
--- /dev/null
+++ b/scripts/waybar/colorpicker.sh
@@ -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=" COLORS\n\n"
+
+ tooltip+="-> $text \n"
+ for i in "${allcolors[@]}"; do
+ tooltip+=" $i \n"
+ done
+
+ cat <", "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
diff --git a/scripts/waybar/cpu_linux.sh b/scripts/waybar/cpu_linux.sh
new file mode 100755
index 0000000..2dca844
--- /dev/null
+++ b/scripts/waybar/cpu_linux.sh
@@ -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"
diff --git a/scripts/waybar/myUpdates.sh b/scripts/waybar/myUpdates.sh
new file mode 100755
index 0000000..5011866
--- /dev/null
+++ b/scripts/waybar/myUpdates.sh
@@ -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
diff --git a/scripts/waybar/myupdate.sh b/scripts/waybar/myupdate.sh
new file mode 100755
index 0000000..99e5e72
--- /dev/null
+++ b/scripts/waybar/myupdate.sh
@@ -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
+
diff --git a/scripts/waybar/powerdraw.sh b/scripts/waybar/powerdraw.sh
new file mode 100755
index 0000000..4c908a7
--- /dev/null
+++ b/scripts/waybar/powerdraw.sh
@@ -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
diff --git a/scripts/waybar/weather.sh b/scripts/waybar/weather.sh
new file mode 100755
index 0000000..0eaeaf9
--- /dev/null
+++ b/scripts/waybar/weather.sh
@@ -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\": \"$tooltip\", \"class\": \"weather\"}"
+fi
+
diff --git a/common.nix b/system/common.nix
similarity index 80%
rename from common.nix
rename to system/common.nix
index 4cf1019..b4b63b9 100644
--- a/common.nix
+++ b/system/common.nix
@@ -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
diff --git a/system/cpu/intel/default.nix b/system/cpu/intel/default.nix
new file mode 100644
index 0000000..1eaf8d4
--- /dev/null
+++ b/system/cpu/intel/default.nix
@@ -0,0 +1,7 @@
+{ config, lib, ... }:
+{
+ imports = [
+ ../../gpu/intel
+ ];
+ hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
+}
diff --git a/system/gpu/intel/default.nix b/system/gpu/intel/default.nix
new file mode 100644
index 0000000..9965407
--- /dev/null
+++ b/system/gpu/intel/default.nix
@@ -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.";
+ }
+ ];
+ };
+}
diff --git a/system/gpu/nvidia/default.nix b/system/gpu/nvidia/default.nix
new file mode 100644
index 0000000..cc16def
--- /dev/null
+++ b/system/gpu/nvidia/default.nix
@@ -0,0 +1,6 @@
+{ lib, ... }:
+
+{
+ imports = [];
+ services.xserver.videoDrivers = lib.mkDefault [ "modesetting" "nvidia"];
+}
diff --git a/system/gpu/nvidia/disable.nix b/system/gpu/nvidia/disable.nix
new file mode 100644
index 0000000..550da56
--- /dev/null
+++ b/system/gpu/nvidia/disable.nix
@@ -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"
+ ];
+}
diff --git a/system/gpu/nvidia/prime.nix b/system/gpu/nvidia/prime.nix
new file mode 100644
index 0000000..edfda26
--- /dev/null
+++ b/system/gpu/nvidia/prime.nix
@@ -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;
+ };
+ };
+ };
+ };
+ };
+}
diff --git a/system/gpu/nvidia/turing/default.nix b/system/gpu/nvidia/turing/default.nix
new file mode 100644
index 0000000..5e8d48f
--- /dev/null
+++ b/system/gpu/nvidia/turing/default.nix
@@ -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);
+}
diff --git a/system/modules/bluetooth.nix b/system/modules/bluetooth.nix
new file mode 100644
index 0000000..33a0cc8
--- /dev/null
+++ b/system/modules/bluetooth.nix
@@ -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;
+}
diff --git a/modules/desktop.nix b/system/modules/desktop.nix
similarity index 60%
rename from modules/desktop.nix
rename to system/modules/desktop.nix
index 56c648a..265d79a 100644
--- a/modules/desktop.nix
+++ b/system/modules/desktop.nix
@@ -4,10 +4,4 @@
]
# Enable CUPS to print documents.
services.printing.enable = true;
-
- # sound setup
- nixpkgs.config.pulseaudio.enable = true;
- services.pulseaudio.enable = true;
-
-
}
diff --git a/system/modules/desktop_tools.nix b/system/modules/desktop_tools.nix
new file mode 100644
index 0000000..d06c1ac
--- /dev/null
+++ b/system/modules/desktop_tools.nix
@@ -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";
+}
diff --git a/modules/dev.nix b/system/modules/dev.nix
similarity index 100%
rename from modules/dev.nix
rename to system/modules/dev.nix
diff --git a/modules/display.nix b/system/modules/display.nix
similarity index 100%
rename from modules/display.nix
rename to system/modules/display.nix
diff --git a/system/modules/docker.nix b/system/modules/docker.nix
new file mode 100644
index 0000000..39088f4
--- /dev/null
+++ b/system/modules/docker.nix
@@ -0,0 +1,8 @@
+{ config, lib, pkgs, ... }:
+{
+ virtualisation.docker.enable = true;
+ virtualisation.docker.rootless = {
+ enable = true;
+ setSocketVariable = true;
+ };
+}
diff --git a/system/modules/fonts.nix b/system/modules/fonts.nix
new file mode 100644
index 0000000..e448133
--- /dev/null
+++ b/system/modules/fonts.nix
@@ -0,0 +1,6 @@
+{ config, lib, pkgs, ... }:
+{
+ fonts.packages = with pkgs; [
+ nerd-fonts.jetbrains-mono
+ ];
+}
diff --git a/system/modules/keyd.nix b/system/modules/keyd.nix
new file mode 100644
index 0000000..241abbd
--- /dev/null
+++ b/system/modules/keyd.nix
@@ -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
+ '';
+}
diff --git a/system/modules/laptop.nix b/system/modules/laptop.nix
new file mode 100644
index 0000000..bccfdc9
--- /dev/null
+++ b/system/modules/laptop.nix
@@ -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";
+ };
+ };
+}
diff --git a/system/modules/nvidia_laptop.nix b/system/modules/nvidia_laptop.nix
new file mode 100644
index 0000000..c545be2
--- /dev/null
+++ b/system/modules/nvidia_laptop.nix
@@ -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;
+ };
+}
diff --git a/system/modules/suspend_then_hibernate_on_battery.nix b/system/modules/suspend_then_hibernate_on_battery.nix
new file mode 100644
index 0000000..d63ce67
--- /dev/null
+++ b/system/modules/suspend_then_hibernate_on_battery.nix
@@ -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";
+ };
+}
diff --git a/system/modules/sway.nix b/system/modules/sway.nix
new file mode 100644
index 0000000..2181c79
--- /dev/null
+++ b/system/modules/sway.nix
@@ -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;
+ };
+}
diff --git a/system/pc/audio/pipewire.nix b/system/pc/audio/pipewire.nix
new file mode 100644
index 0000000..91be448
--- /dev/null
+++ b/system/pc/audio/pipewire.nix
@@ -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;
+}
diff --git a/system/pc/audio/pulseaudio.nix b/system/pc/audio/pulseaudio.nix
new file mode 100644
index 0000000..2fa6849
--- /dev/null
+++ b/system/pc/audio/pulseaudio.nix
@@ -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
+ '';
+
+}
diff --git a/system/pc/default.nix b/system/pc/default.nix
new file mode 100644
index 0000000..e56304b
--- /dev/null
+++ b/system/pc/default.nix
@@ -0,0 +1,7 @@
+{ config, lib, ... }:
+
+{
+ boot.blacklistedKernelModules = lib.optionals (!config.hardware.enableRedistributableFirmware) [
+ "ath3k"
+ ];
+}
diff --git a/system/pc/laptop/default.nix b/system/pc/laptop/default.nix
new file mode 100644
index 0000000..abc76fa
--- /dev/null
+++ b/system/pc/laptop/default.nix
@@ -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
+ );
+}
diff --git a/system/pc/ssd/default.nix b/system/pc/ssd/default.nix
new file mode 100644
index 0000000..c29d03b
--- /dev/null
+++ b/system/pc/ssd/default.nix
@@ -0,0 +1,5 @@
+{ lib, ... }:
+
+{
+ services.fstrim.enable = lib.mkDefault true;
+}
diff --git a/user/modules/alacritty.nix b/user/modules/alacritty.nix
new file mode 100644
index 0000000..3fab37c
--- /dev/null
+++ b/user/modules/alacritty.nix
@@ -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
+ ''
+ ];
+ };
+ };
+ };
+}
diff --git a/home-manager/common.nix b/user/modules/common.nix
similarity index 59%
rename from home-manager/common.nix
rename to user/modules/common.nix
index 63eed56..db8e55b 100644
--- a/home-manager/common.nix
+++ b/user/modules/common.nix
@@ -2,14 +2,7 @@
{
home.packages = with pkgs; [
- git
- starship
];
-
- programs.git = {
- enable = true;
- };
-
home.stateVersion = "24.05";
}
diff --git a/user/modules/fish.nix b/user/modules/fish.nix
new file mode 100644
index 0000000..0c333a0
--- /dev/null
+++ b/user/modules/fish.nix
@@ -0,0 +1,9 @@
+{ pkgs, ... }:
+{
+ programs.fish = {
+ enable = true;
+ interactiveShellInit = ''
+ set fish_greeting # Disable greeting
+ '';
+ };
+}
diff --git a/user/modules/gammastep.nix b/user/modules/gammastep.nix
new file mode 100644
index 0000000..8632b4b
--- /dev/null
+++ b/user/modules/gammastep.nix
@@ -0,0 +1,12 @@
+{ lib, ... }:
+{
+ # night light
+ services.gammastep = {
+ enable = true;
+ provider = "geoclue2";
+ tray = true;
+ temperature = {
+ night = 1700;
+ };
+ };
+}
diff --git a/user/modules/ranger.nix b/user/modules/ranger.nix
new file mode 100644
index 0000000..4edcc6e
--- /dev/null
+++ b/user/modules/ranger.nix
@@ -0,0 +1,4 @@
+{ config, lib, pkgs, ... }:
+{
+
+}
diff --git a/home-manager/rofi.nix b/user/modules/rofi.nix
similarity index 100%
rename from home-manager/rofi.nix
rename to user/modules/rofi.nix
diff --git a/home-manager/sway.nix b/user/modules/sway.nix
similarity index 81%
rename from home-manager/sway.nix
rename to user/modules/sway.nix
index 3500b18..9274acc 100644
--- a/home-manager/sway.nix
+++ b/user/modules/sway.nix
@@ -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 ===
diff --git a/user/modules/swayidle.nix b/user/modules/swayidle.nix
new file mode 100644
index 0000000..4de4295
--- /dev/null
+++ b/user/modules/swayidle.nix
@@ -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";
+ }
+ ];
+ };
+}
diff --git a/user/modules/swaylock.nix b/user/modules/swaylock.nix
new file mode 100644
index 0000000..0933d92
--- /dev/null
+++ b/user/modules/swaylock.nix
@@ -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;
+ };
+ };
+}
diff --git a/user/modules/terminal.nix b/user/modules/terminal.nix
new file mode 100644
index 0000000..6fdf8b4
--- /dev/null
+++ b/user/modules/terminal.nix
@@ -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;
+
+ };
+
+}
diff --git a/home-manager/waybar.nix b/user/modules/waybar.nix
similarity index 71%
rename from home-manager/waybar.nix
rename to user/modules/waybar.nix
index c7b5d5a..2eb3557 100644
--- a/home-manager/waybar.nix
+++ b/user/modules/waybar.nix
@@ -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}% {icon} {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;
+ }
+ '';
};
}
diff --git a/user/modules/zellij.nix b/user/modules/zellij.nix
new file mode 100644
index 0000000..8d8e1c6
--- /dev/null
+++ b/user/modules/zellij.nix
@@ -0,0 +1,12 @@
+{ pkgs, ... }:
+{
+ programs.zellij = {
+ enable = true;
+ enableFishIntegration = true;
+ settings = {
+ theme = "dracula";
+ copy_on_select = true;
+ show_startup_tips = false;
+ };
+ };
+}