barrier: add module

Co-authored-by: Sumner Evans <me@sumnerevans.com>
This commit is contained in:
Kritnich 2021-04-29 02:48:05 +02:00 committed by Robert Helgesson
parent 5e6f09795c
commit 2eed138026
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
7 changed files with 104 additions and 0 deletions

3
.github/CODEOWNERS vendored
View file

@ -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

View file

@ -1929,6 +1929,13 @@ in
'';
}
{
time = "2021-04-30T22:05:01+00:00";
condition = hostPlatform.isLinux;
message = ''
A new service is available: 'services.barrier'.
'';
}
];
};
}

View file

@ -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; })

View file

@ -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
<literal>&lt;host&gt;[:&lt;port&gt;]</literal>.
Port defaults to <literal>24800</literal>.
'';
};
tray = mkEnableOption "the system tray icon" // { default = true; };
enableCrypto = mkEnableOption "crypto (SSL) plugin" // {
default = true;
};
enableDragDrop = mkEnableOption "file drag &amp; drop";
extraFlags = mkOption {
type = types.listOf types.str;
default = [ "-f" ];
defaultText = literalExample ''[ "-f" ]'';
description = ''
Additional flags to pass to <command>barrierc</command>.
See <command>barrierc --help</command>.
'';
};
};
};
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 ]);
};
};
}

View file

@ -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

View file

@ -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'
'';
};
}

View file

@ -0,0 +1 @@
{ barrier-basic-configuration = ./basic-configuration.nix; }