From 12de1420cb32da638079694142bc3c3b10281424 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 15 Mar 2024 08:03:56 -0600 Subject: [PATCH] gui/kde: add a kdeConnect option and enable it in europa --- gui/kde.nix | 44 +++++++++++++++++++++++++++++++--------- hosts/europa/default.nix | 8 +++++++- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/gui/kde.nix b/gui/kde.nix index af93350..b5cd871 100644 --- a/gui/kde.nix +++ b/gui/kde.nix @@ -3,12 +3,30 @@ , isUnstable , ... }: +let + inherit (lib) mkIf mkEnableOption mkMerge mkOption types; +in { - options = { kde = { enable = lib.mkEnableOption "Enable KDE desktop."; }; }; + options = { + kde = { enable = mkEnableOption "Enable KDE desktop."; }; + kdeConnect = { + enable = mkEnableOption { + description = "Enable PipeWire"; + default = false; + example = true; + }; - config = lib.mkIf config.kde.enable { + interface = mkOption { + description = "listen interface for kde connect"; + default = "tailscale0"; + type = types.str; + }; + }; + }; + + config = mkIf config.kde.enable { services.xserver = - lib.mkMerge [ + mkMerge [ (if isUnstable then { desktopManager.plasma6.enable = true; displayManager.sddm.wayland.enable = true; @@ -22,13 +40,19 @@ ]; # Listen for KDE Connect connections on the tailnet - networking.firewall.interfaces = { - "tailscale0" = { - allowedTCPPorts = lib.range 1714 1764; - allowedUDPPorts = lib.range 1714 1764; - }; + networking.firewall.interfaces = mkIf config.kdeConnect.enable { + "${config.kdeConnect.interface}" = + let + range = { + from = 1714; + to = 1764; + }; + in + { + allowedUDPPortRanges = [ range ]; + allowedTCPPortRanges = [ range ]; + }; }; - - programs.kdeconnect.enable = true; + programs.kdeconnect.enable = config.kdeConnect.enable; }; } diff --git a/hosts/europa/default.nix b/hosts/europa/default.nix index db0a9b9..45622b6 100644 --- a/hosts/europa/default.nix +++ b/hosts/europa/default.nix @@ -137,6 +137,7 @@ in }; kde.enable = lib.mkDefault true; + kdeConnect.enable = true; virtualisation.libvirtd.enable = lib.mkDefault true; @@ -152,7 +153,12 @@ in firewall = { enable = true; allowedTCPPorts = [ 22 ]; - interfaces = { "tailscale0" = { allowedTCPPorts = [ 8384 ]; }; }; + interfaces = { + "tailscale0" = + { + allowedTCPPorts = [ 8384 ]; + }; + }; }; };