From 50611592c64823ceb9d74c41f9f397f9b5edbfd6 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 00:31:39 +0200 Subject: [PATCH 1/5] Add system/linux_x86 --- nix/system/linux_x86.nix | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 nix/system/linux_x86.nix diff --git a/nix/system/linux_x86.nix b/nix/system/linux_x86.nix new file mode 100644 index 0000000..e7dcfe0 --- /dev/null +++ b/nix/system/linux_x86.nix @@ -0,0 +1,97 @@ +{ pkgs, config, ... }: +{ + imports = [ + ./hardware-configuration.nix + ]; + + boot = { + consoleLogLevel = 0; + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + kernelModules = [ + "nvidia" + "nvidia_modeset" + "nvidia_uvm" + "nvidia_drm" + ]; + blacklistedKernelModules = [ "nouveau" ]; + kernelParams = [ + "nvidia-drm.modeset=1" + "nvidia-drm.fbdev=1" + ]; + }; + + hardware = { + nvidia = { + modesetting.enable = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + open = true; + powerManagement = { + enable = true; + finegrained = false; + }; + nvidiaPersistenced = true; + + }; + graphics.enable = true; + + bluetooth.enable = true; + bluetooth.powerOnBoot = true; + bluetooth.settings = { + General = { + Enable = "Source,Sink,Media,Socket"; + Experimental = true; + }; + }; + }; + + networking.hostName = "walnut-nixos"; + + networking = { + wireless.iwd = { + enable = true; + settings.General.EnableNetworkConfiguration = true; + }; + networkmanager = { + enable = true; + wifi.backend = "iwd"; + wifi.powersave = true; + }; + }; + + programs = { + xwayland.enable = true; + sway = { + enable = true; + package = pkgs.swayfx; + extraOptions = [ + "--unsupported-gpu" + ]; + }; + }; + + environment.variables = { + GBM_BACKEND = "nvidia-drm"; + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + NIXOS_OZONE_WL = "1"; + WLR_NO_HARDWARE_CURSORS = "1"; + WLR_RENDERER = "vulkan"; + }; + + services = { + xserver = { + enable = true; + videoDrivers = [ "nvidia" ]; + }; + }; + + users.users.larssonmartin = { + isNormalUser = true; + home = "/home/larssonmartin"; + extraGroups = [ "wheel" ]; + packages = [ ]; + shell = pkgs.zsh; + }; +} From 70138db12d940b02402b93a75961a4a9e6b6e42c Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 00:32:03 +0200 Subject: [PATCH 2/5] Slight refactor to main flake, enable vim as systme package for all systems --- flake.nix | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index d5a0283..c5bcf07 100644 --- a/flake.nix +++ b/flake.nix @@ -61,6 +61,12 @@ }: let lib = nixpkgs.lib; + get_pkgs = { system }: import nixpkgs { + inherit system; + config = { + allowUnfree = true; + }; + }; makeSystemConfig = { @@ -70,17 +76,17 @@ extraModules ? [ ], specialArgs ? { }, }: - builder { + let + pkgs = get_pkgs { inherit system; }; + in builder { inherit system; - pkgs = import nixpkgs { - inherit system; - config = { - allowUnfree = true; - }; - }; + pkgs = pkgs; modules = [ { nix.settings.experimental-features = "nix-command flakes"; + environment.systemPackages = with pkgs; [ + vim + ]; } ./nix/local_system.nix ] ++ extraModules; @@ -93,14 +99,10 @@ name, system, extraModules ? [ ], - }: - home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { - inherit system; - config = { - allowUnfree = true; - }; - }; + }: let + pkgs = get_pkgs { inherit system; }; + in home-manager.lib.homeManagerConfiguration { + pkgs = pkgs; modules = [ ./nix/pkgs/home.nix ./nix/local_home.nix @@ -128,7 +130,10 @@ name = "linux-x86"; system = "x86_64-linux"; builder = lib.nixosSystem; - extraModules = [ ./nix/system/linux.nix ]; + extraModules = [ + ./nix/system/linux.nix + ./nix/system/linux_x86.nix + ]; }; "linux-aarch" = makeSystemConfig { From 8f973cc3a28a145bcd68d6e4849321b9a70c15de Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 00:32:25 +0200 Subject: [PATCH 3/5] Sway is now configured specifically for x86 and aarch64 --- nix/system/linux.nix | 4 ---- nix/system/linux_aarch.nix | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nix/system/linux.nix b/nix/system/linux.nix index 6601eeb..d905ff6 100644 --- a/nix/system/linux.nix +++ b/nix/system/linux.nix @@ -2,10 +2,6 @@ { programs = { zsh.enable = true; - sway = { - enable = true; - package = pkgs.swayfx; - }; }; networking = { diff --git a/nix/system/linux_aarch.nix b/nix/system/linux_aarch.nix index 49c0ed9..6565667 100644 --- a/nix/system/linux_aarch.nix +++ b/nix/system/linux_aarch.nix @@ -5,6 +5,13 @@ apple-silicon-support.nixosModules.apple-silicon-support ]; + programs = { + sway = { + enable = true; + package = pkgs.swayfx; + }; + }; + boot = { consoleLogLevel = 0; kernelParams = [ "apple_dcp.show_notch=1" ]; From 49d6de007f8f36ab3251ffab72c97b03dd24050a Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 01:05:17 +0200 Subject: [PATCH 4/5] Add playerctl to home environment --- nix/pkgs/linux.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/pkgs/linux.nix b/nix/pkgs/linux.nix index f495153..1f45d4d 100644 --- a/nix/pkgs/linux.nix +++ b/nix/pkgs/linux.nix @@ -141,6 +141,7 @@ in grim slurp pavucontrol + playerctl ]; file = { From f53b2dfcf345356b4787311f331ff2e2f772975c Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 01:06:01 +0200 Subject: [PATCH 5/5] Conditionally hide Brightness and Network info depending on external displays and ethernet --- sway/status.sh | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/sway/status.sh b/sway/status.sh index bf9d628..163501e 100755 --- a/sway/status.sh +++ b/sway/status.sh @@ -26,12 +26,18 @@ update_status() { fi # Network status - ssid=$(nmcli -t -f ACTIVE,SSID dev wifi | grep -E '^yes' | cut -d: -f2) - if [ -z "$ssid" ]; then - network_display="$wifi_icon Disconnected" - else - network_display="$wifi_icon $ssid" - fi + ethernet_connected=$(nmcli -t -f DEVICE,STATE device | grep -E '^en.*:connected' | wc -l) + if [ "$ethernet_connected" -gt 0 ]; then + network_display="" + else + # Check WiFi connection + ssid=$(nmcli -t -f ACTIVE,SSID dev wifi | grep -E '^yes' | cut -d: -f2) + if [ -z "$ssid" ]; then + network_display="$wifi_icon Disconnected" + else + network_display="$wifi_icon $ssid" + fi + fi # Date/time date_time_icon="$date_icon $(date +"%a %b %d, %H:%M")" @@ -39,9 +45,14 @@ update_status() { # Battery battery=$("$HOME/.config/confutils/get-battery.sh") - # Brightness - brightness=$(brightnessctl | grep -oP '[0-9]+(?=%)') - brightness_display="$brightness_icon $brightness%" + # Only show brightness if a laptop/internal display is detected + internal_display_active=$(swaymsg -t get_outputs | jq -r '.[] | select(.name == "eDP-1" or .name == "LVDS-1") | .name' | wc -l) + if [ "$internal_display_active" -gt 0 ] && command -v brightnessctl &> /dev/null; then + brightness=$(brightnessctl | grep -oP '[0-9]+(?=%)') + brightness_display="$brightness_icon $brightness%" + else + brightness_display="" + fi # Bluetooth bluetooth_device=$(bluetoothctl devices Connected \ @@ -82,11 +93,17 @@ update_status() { space=" " # Using standard spaces for separation final_status="$final_status$space$volume_display" - final_status="$final_status$space$brightness_display" - final_status="$final_status$space$battery" + if [ -n "$brightness_display" ]; then + final_status="$final_status$space$brightness_display" + fi + if [ -n "$battery" ]; then + final_status="$final_status$space$battery" + fi final_status="$final_status$space$keyboard_display" final_status="$final_status$space$vpn_display" - final_status="$final_status$space$network_display" + if [ -n "$network_display" ]; then + final_status="$final_status$space$network_display" + fi final_status="$final_status$space$date_time_icon" final_status="$final_status " # Trailing space