From 333cb211521af7b11eabe9284f43fc9fe3345f1e Mon Sep 17 00:00:00 2001 From: Emma Thorpe Date: Thu, 4 Jun 2026 13:57:44 +0000 Subject: [PATCH] feat(nixos): add desktop module with non-portable home-manager profile Add system/modules/desktop.nix (counterpart to laptop.nix): imports the workstation base and uses wired NetworkManager instead of iwd. Thread a `portable` flag (default true) through mkHost into specialArgs and home-manager.extraSpecialArgs, mirroring username/fullName. lyrathorpe/home/ sway.nix consumes it to drop mobile components on desktop hosts: - status bar swaps the battery block for CPU temperature + network throughput - screen-brightness keybindings are omitted (no internal backlight) No host uses desktop.nix yet; a future desktop host imports it and sets `portable = false`. Verified by evaluating sway.nix both ways: laptop -> [.. sound battery time] + brightness keys; desktop -> [.. temperature net sound time], no brightness keys. Co-Authored-By: Claude Opus 4.8 (1M context) --- flake.nix | 22 +++++++++++++++-- lyrathorpe/home/sway.nix | 48 ++++++++++++++++++++++++++++---------- system/modules/desktop.nix | 13 +++++++++++ 3 files changed, 69 insertions(+), 14 deletions(-) create mode 100644 system/modules/desktop.nix diff --git a/flake.nix b/flake.nix index 4823d75..fe4d937 100644 --- a/flake.nix +++ b/flake.nix @@ -98,16 +98,34 @@ fullName, modules, homeModules, + # Host form factor. Laptops inherit the default; a desktop host sets + # `portable = false` to drop mobile components (battery block, + # brightness keys) from the home-manager Sway config. + portable ? true, }: nixpkgs.lib.nixosSystem { inherit system; - specialArgs = { inherit inputs username fullName; }; + specialArgs = { + inherit + inputs + username + fullName + portable + ; + }; modules = baseModules ++ modules ++ [ { - home-manager.extraSpecialArgs = { inherit inputs username fullName; }; + home-manager.extraSpecialArgs = { + inherit + inputs + username + fullName + portable + ; + }; home-manager.users.${username}.imports = homeModules; } ]; diff --git a/lyrathorpe/home/sway.nix b/lyrathorpe/home/sway.nix index 9862652..0d0d709 100644 --- a/lyrathorpe/home/sway.nix +++ b/lyrathorpe/home/sway.nix @@ -6,7 +6,14 @@ # pulling a second Sway. home-manager owns the user config (~/.config/sway) and # wires the systemd user session (sway-session.target), which is what lets the # swayidle/dunst user services start with the desktop. -{ pkgs, lib, ... }: +{ + pkgs, + lib, + # Threaded from mkHost (flake.nix). Desktop hosts set this false to drop + # mobile components (battery block, screen-brightness keys). + portable ? true, + ... +}: { wayland.windowManager.sway = { enable = true; @@ -42,15 +49,20 @@ } ]; - keybindings = lib.mkOptionDefault { - "${modifier}+l" = "exec ${pkgs.swaylock}/bin/swaylock -f"; - "Print" = "exec ${pkgs.grim}/bin/grim ~/screenshot-$(date +%F-%H%M%S).png"; - "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%+"; - "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-"; - "XF86AudioRaiseVolume" = "exec ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"; - "XF86AudioLowerVolume" = "exec ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"; - "XF86AudioMute" = "exec ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; - }; + keybindings = lib.mkOptionDefault ( + { + "${modifier}+l" = "exec ${pkgs.swaylock}/bin/swaylock -f"; + "Print" = "exec ${pkgs.grim}/bin/grim ~/screenshot-$(date +%F-%H%M%S).png"; + "XF86AudioRaiseVolume" = "exec ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"; + "XF86AudioLowerVolume" = "exec ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"; + "XF86AudioMute" = "exec ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; + } + # Screen backlight: laptops only (no internal backlight on a desktop). + // lib.optionalAttrs portable { + "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%+"; + "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-"; + } + ); }; }; @@ -120,8 +132,20 @@ block = "cpu"; interval = 2; } - { block = "sound"; } - { block = "battery"; } + ] + # Desktop-only: CPU temperature and wired network throughput, in place + # of the laptop's battery readout. + ++ lib.optionals (!portable) [ + { + block = "temperature"; + interval = 5; + format = " $icon $average avg, $max max "; + } + { block = "net"; } + ] + ++ [ { block = "sound"; } ] + ++ lib.optional portable { block = "battery"; } + ++ [ { block = "time"; interval = 5; diff --git a/system/modules/desktop.nix b/system/modules/desktop.nix new file mode 100644 index 0000000..f103ca7 --- /dev/null +++ b/system/modules/desktop.nix @@ -0,0 +1,13 @@ +# Desktop (non-portable) NixOS hosts. Counterpart to ./laptop.nix: imports the +# shared ./workstation.nix base and swaps the mobile Wi-Fi backend for wired +# NetworkManager. A desktop host also sets `portable = false` in its host-table +# entry (flake.nix), which drops the battery block and brightness keybindings +# from the Sway bar -- see lyrathorpe/home/sway.nix. +{ ... }: +{ + imports = [ ./workstation.nix ]; + + # Wired networking. NetworkManager handles DHCP/connections itself; do not + # combine with networking.wireless.* (laptop.nix) -- the two backends conflict. + networking.networkmanager.enable = true; +}