diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 1859fef63..65dd9bedb 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -164,6 +164,9 @@
/modules/programs/zsh/prezto.nix @NickHu
+/modules/services/barrier.nix @Kritnich
+/tests/modules/services/barrier @Kritnich
+
/modules/services/caffeine.nix @uvNikita
/modules/services/cbatticon.nix @pmiddend
diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index 5244b2a64..f2bf06405 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -1929,6 +1929,13 @@ in
'';
}
+ {
+ time = "2021-04-30T22:05:01+00:00";
+ condition = hostPlatform.isLinux;
+ message = ''
+ A new service is available: 'services.barrier'.
+ '';
+ }
];
};
}
diff --git a/modules/modules.nix b/modules/modules.nix
index b68eed0ac..0b983ecb3 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -139,6 +139,7 @@ let
(loadModule ./programs/zplug.nix { })
(loadModule ./programs/zsh.nix { })
(loadModule ./programs/zsh/prezto.nix { })
+ (loadModule ./services/barrier.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/blueman-applet.nix { })
(loadModule ./services/caffeine.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/cbatticon.nix { condition = hostPlatform.isLinux; })
diff --git a/modules/services/barrier.nix b/modules/services/barrier.nix
new file mode 100644
index 000000000..ae9b7d936
--- /dev/null
+++ b/modules/services/barrier.nix
@@ -0,0 +1,71 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let cfg = config.services.barrier;
+in {
+
+ meta.maintainers = with maintainers; [ kritnich ];
+
+ options.services.barrier = {
+
+ client = {
+
+ enable = mkEnableOption "Barrier Client daemon";
+
+ name = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ description = ''
+ Screen name of client. Defaults to hostname.
+ '';
+ };
+
+ server = mkOption {
+ type = types.str;
+ description = ''
+ Server to connect to formatted as
+ <host>[:<port>].
+ Port defaults to 24800.
+ '';
+ };
+
+ tray = mkEnableOption "the system tray icon" // { default = true; };
+
+ enableCrypto = mkEnableOption "crypto (SSL) plugin" // {
+ default = true;
+ };
+
+ enableDragDrop = mkEnableOption "file drag & drop";
+
+ extraFlags = mkOption {
+ type = types.listOf types.str;
+ default = [ "-f" ];
+ defaultText = literalExample ''[ "-f" ]'';
+ description = ''
+ Additional flags to pass to barrierc.
+ See barrierc --help.
+ '';
+ };
+
+ };
+ };
+
+ config = mkIf cfg.client.enable {
+ systemd.user.services.barrierc = {
+ Unit = {
+ Description = "Barrier Client daemon";
+ After = [ "graphical-session-pre.target" ];
+ PartOf = [ "graphical-session.target" ];
+ };
+ Install.WantedBy = [ "graphical-session.target" ];
+ Service.ExecStart = with cfg.client;
+ toString ([ "${pkgs.barrier}/bin/barrierc" ]
+ ++ optional (name != null) "--name ${name}"
+ ++ optional (!tray) "--no-tray"
+ ++ optional enableCrypto "--enable-crypto"
+ ++ optional enableDragDrop "--enable-drag-drop" ++ extraFlags
+ ++ [ server ]);
+ };
+ };
+
+}
diff --git a/tests/default.nix b/tests/default.nix
index 80589f6ed..72decbe7e 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -102,6 +102,7 @@ import nmt {
./modules/programs/rofi
./modules/programs/rofi-pass
./modules/programs/waybar
+ ./modules/services/barrier
./modules/services/dropbox
./modules/services/emacs
./modules/services/fluidsynth
diff --git a/tests/modules/services/barrier/basic-configuration.nix b/tests/modules/services/barrier/basic-configuration.nix
new file mode 100644
index 000000000..83a9365e4
--- /dev/null
+++ b/tests/modules/services/barrier/basic-configuration.nix
@@ -0,0 +1,20 @@
+{ config, pkgs, ... }:
+
+{
+ config = {
+ services.barrier.client = {
+ enable = true;
+ server = "testServer";
+ };
+
+ nixpkgs.overlays =
+ [ (self: super: { barrier = pkgs.writeScriptBin "dummy-barrier" ""; }) ];
+
+ nmt.script = ''
+ clientServiceFile=home-files/.config/systemd/user/barrierc.service
+
+ assertFileExists $clientServiceFile
+ assertFileRegex $clientServiceFile 'ExecStart=.*/bin/barrierc --enable-crypto -f testServer'
+ '';
+ };
+}
diff --git a/tests/modules/services/barrier/default.nix b/tests/modules/services/barrier/default.nix
new file mode 100644
index 000000000..d36f79532
--- /dev/null
+++ b/tests/modules/services/barrier/default.nix
@@ -0,0 +1 @@
+{ barrier-basic-configuration = ./basic-configuration.nix; }