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 { diff --git a/nix/pkgs/linux.nix b/nix/pkgs/linux.nix index cb3fadd..817c4a4 100644 --- a/nix/pkgs/linux.nix +++ b/nix/pkgs/linux.nix @@ -197,6 +197,7 @@ in spotify-qt librespot blueman + playerctl ]; file = { 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" ]; 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; + }; +} 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