From 759ec7b031e7070f7bfe193340a4e5edbbc72021 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Wed, 18 Sep 2019 21:48:14 +0400 Subject: [PATCH] Add barrier (test), disable compton --- modules/barrier-conf.nix | 91 +++++++++++++++++++++++++++++++++++ modules/default.nix | 4 +- modules/filesystems.nix | 1 - modules/workspace/barrier.nix | 27 +++++++++++ 4 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 modules/barrier-conf.nix create mode 100644 modules/workspace/barrier.nix diff --git a/modules/barrier-conf.nix b/modules/barrier-conf.nix new file mode 100644 index 0000000..55b9653 --- /dev/null +++ b/modules/barrier-conf.nix @@ -0,0 +1,91 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfgC = config.services.barrier.client; + cfgS = config.services.barrier.server; +in +{ + options = { + services.barrier = { + client = { + enable = mkOption { + default = false; + description = " + Whether to enable the Barrier client (receive keyboard and mouse events from a Barrier server). + "; + }; + screenName = mkOption { + default = ""; + description = '' + Use the given name instead of the hostname to identify + ourselves to the server. + ''; + }; + serverAddress = mkOption { + description = '' + The server address is of the form: [hostname][:port]. The + hostname must be the address or hostname of the server. The + port overrides the default port, 24800. + ''; + }; + autoStart = mkOption { + default = true; + type = types.bool; + description = "Whether the Barrier client should be started automatically."; + }; + }; + + server = { + enable = mkOption { + default = false; + description = '' + Whether to enable the Barrier server (send keyboard and mouse events). + ''; + }; + configFile = mkOption { + default = "/etc/barrier-server.conf"; + description = "The Barrier server configuration file."; + }; + screenName = mkOption { + default = ""; + description = '' + Use the given name instead of the hostname to identify + this screen in the configuration. + ''; + }; + address = mkOption { + default = ""; + description = "Address on which to listen for clients."; + }; + autoStart = mkOption { + default = true; + type = types.bool; + description = "Whether the Barrier server should be started automatically."; + }; + }; + }; + }; + + config = mkMerge [ + (mkIf cfgC.enable { + systemd.user.services."barrier-client" = { + after = [ "network.target" "graphical-session.target" ]; + description = "Barrier client"; + wantedBy = optional cfgC.autoStart "graphical-session.target"; + path = [ pkgs.barrier ]; + serviceConfig.ExecStart = ''${pkgs.barrier}/bin/barrierc -f ${optionalString (cfgC.screenName != "") "-n ${cfgC.screenName}"} ${cfgC.serverAddress}''; + serviceConfig.Restart = "on-failure"; + }; + }) + (mkIf cfgS.enable { + systemd.user.services."barrier-server" = { + after = [ "network.target" "graphical-session.target" ]; + description = "Barrier server"; + wantedBy = optional cfgS.autoStart "graphical-session.target"; + path = [ pkgs.barrier ]; + serviceConfig.ExecStart = ''${pkgs.barrier}/bin/barriers -c ${cfgS.configFile} -f ${optionalString (cfgS.address != "") "-a ${cfgS.address}"} ${optionalString (cfgS.screenName != "") "-n ${cfgS.screenName}" }''; + serviceConfig.Restart = "on-failure"; + }; + }) + ]; +} \ No newline at end of file diff --git a/modules/default.nix b/modules/default.nix index d6977f7..9d986a8 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -7,7 +7,7 @@ ./workspace/i3 ./workspace/zsh.nix ./workspace/gtk.nix - ./workspace/compton.nix + # ./workspace/compton.nix ./workspace/misc.nix ./workspace/dunst.nix ./workspace/cursor.nix @@ -21,6 +21,8 @@ # ./workspace/gcalcli.nix # ./workspace/rclone.nix ./workspace/xresources.nix + ./workspace/barrier.nix + ./barrier-conf.nix ./themes.nix ./applications.nix ./secrets.nix diff --git a/modules/filesystems.nix b/modules/filesystems.nix index a6ffdfd..35f1003 100644 --- a/modules/filesystems.nix +++ b/modules/filesystems.nix @@ -21,7 +21,6 @@ with deviceSpecific; { "dmode=0755" "fmode=0644" "uid=${toString config.users.users.alukard.uid}" - # "gid=${toString config.users.groups.users.gid}" "gid=${toString config.users.groups.smbgrp.gid}" ]; }; diff --git a/modules/workspace/barrier.nix b/modules/workspace/barrier.nix new file mode 100644 index 0000000..3d6fa36 --- /dev/null +++ b/modules/workspace/barrier.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: { + services.barrier = if config.device == "NixOS-VM" then { + server.enable = true; + server.autoStart = true; + server.configFile = pkgs.writeTextFile { + name = "barrier.conf"; + text = '' + section: screens + NixOS-VM: + Dell-Laptop: + end + section: links + Dell-Laptop: + right = NixOS-VM + end + section: options + keystroke(super+alt+left) = switchInDirection(left) + keystroke(super+alt+right) = switchInDirection(right) + end + ''; + }; + } else { + client.enable = true; + client.autoStart = true; + client.serverAddress = "NixOS-VM"; + }; +} \ No newline at end of file