From 0bb4941ab775e0543d455f8034441f85347cd4c0 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Fri, 6 Sep 2024 03:12:54 +0300 Subject: [PATCH] modules/communications: move simplex to the nixos configs --- hosts/asus-gl553vd/configuration.nix | 12 +++++++++++ hosts/home/configuration.nix | 5 +++++ .../home-manager/programs/communication.nix | 13 +++++------- .../nixos/programs/communication/default.nix | 1 + .../programs/communication/simplex-chat.nix | 21 +++++++++++++++++++ 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 modules/nixos/programs/communication/simplex-chat.nix diff --git a/hosts/asus-gl553vd/configuration.nix b/hosts/asus-gl553vd/configuration.nix index a426034..69f6904 100644 --- a/hosts/asus-gl553vd/configuration.nix +++ b/hosts/asus-gl553vd/configuration.nix @@ -33,6 +33,18 @@ local.programs.browsers.tor-browser.enable = true; + local.programs.communication = { + telegram = { + enable = true; + package = pkgs.unstable.tdesktop; + }; + simplex-chat = { + enable = true; + package = pkgs.unstable.simplex-chat-desktop; + openFirewall = true; + }; + }; + environment.shellInit = '' [ -n "$DISPLAY" ] && ${pkgs.xorg.xhost}/bin/xhost +si:localuser:$USER > /dev/null || true ''; diff --git a/hosts/home/configuration.nix b/hosts/home/configuration.nix index 0601efb..0833bdd 100644 --- a/hosts/home/configuration.nix +++ b/hosts/home/configuration.nix @@ -54,6 +54,11 @@ enable = true; package = pkgs.unstable.tdesktop; }; + simplex-chat = { + enable = true; + package = pkgs.unstable.simplex-chat-desktop; + openFirewall = true; + }; }; containers.games = { diff --git a/modules/home-manager/programs/communication.nix b/modules/home-manager/programs/communication.nix index a4227b8..ea3cdfe 100644 --- a/modules/home-manager/programs/communication.nix +++ b/modules/home-manager/programs/communication.nix @@ -4,10 +4,6 @@ let cfg = config.local.programs.communication; in { options.local.programs.communication = with lib; { - simplex-chat = { - enable = mkEnableOption "SimplexChat"; - package = mkPackageOption pkgs "simplex-chat-desktop" { }; - }; matrix = { enable = mkEnableOption "nheko. matrix client"; package = mkPackageOption pkgs "nheko" { }; @@ -18,8 +14,9 @@ let cfg = config.local.programs.communication; in }; }; - config.home.packages = - lib.optional cfg.simplex-chat.enable cfg.simplex-chat.package - ++ lib.optional cfg.matrix.enable cfg.matrix.package - ++ lib.optional cfg.tox.enable cfg.tox.package; + config = { + home.packages = + lib.optional cfg.matrix.enable cfg.matrix.package + ++ lib.optional cfg.tox.enable cfg.tox.package; + }; } diff --git a/modules/nixos/programs/communication/default.nix b/modules/nixos/programs/communication/default.nix index 9a842b6..d41fb9a 100644 --- a/modules/nixos/programs/communication/default.nix +++ b/modules/nixos/programs/communication/default.nix @@ -4,5 +4,6 @@ imports = [ ./skype.nix ./telegram.nix + ./simplex-chat.nix ]; } diff --git a/modules/nixos/programs/communication/simplex-chat.nix b/modules/nixos/programs/communication/simplex-chat.nix new file mode 100644 index 0000000..64accb9 --- /dev/null +++ b/modules/nixos/programs/communication/simplex-chat.nix @@ -0,0 +1,21 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.local.programs.communication.simplex-chat; +in +{ + options.local.programs.communication.simplex-chat = with lib; { + enable = mkEnableOption "SimplexChat"; + package = mkPackageOption pkgs "simplex-chat-desktop" { }; + openFirewall = mkEnableOption "Open firewall to link mobile device"; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + + networking.firewall = lib.mkIf cfg.openFirewall { + allowedTCPPorts = [ 44000 ]; + trustedInterfaces = [ "wg0" ]; + }; + }; +}