diff options
author | Ivar <ivar.scholten@protonmail.com> | 2020-12-03 03:55:37 +0100 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2020-12-09 23:45:51 +0100 |
commit | e6a58a7e718ac5b21fa8bc9e937cc19bcd8d9293 (patch) | |
tree | 69f282d9d95a9b1ca738048ef1d438eb76d74aef | |
parent | e3828769e877b1869129a3816515a8c0ea454977 (diff) |
pbgopy: add service
-rw-r--r-- | .github/CODEOWNERS | 3 | ||||
-rw-r--r-- | modules/misc/news.nix | 8 | ||||
-rw-r--r-- | modules/modules.nix | 1 | ||||
-rw-r--r-- | modules/services/pbgopy.nix | 40 | ||||
-rw-r--r-- | tests/default.nix | 1 | ||||
-rw-r--r-- | tests/modules/services/pbgopy/default.nix | 1 | ||||
-rw-r--r-- | tests/modules/services/pbgopy/service.nix | 22 |
7 files changed, 76 insertions, 0 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5967e4f43db3..4a66e1a7805e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -194,6 +194,9 @@ /modules/services/pasystray.nix @pltanton +/modules/services/pbgopy.nix @ivarwithoutbones +/tests/modules/services/pbgopy @ivarwithoutbones + /modules/services/pulseeffects.nix @jonringer /modules/services/random-background.nix @rycee diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 96bd94fe7ca5..1cab8d89b0b1 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1767,6 +1767,14 @@ in A new module is available: 'services.wlsunset'. ''; } + + { + time = "2020-12-09T22:34:33+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.pbgopy'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index b599fe99099a..8ecdc462aeb9 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -169,6 +169,7 @@ let (loadModule ./services/parcellite.nix { }) (loadModule ./services/password-store-sync.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/pasystray.nix { }) + (loadModule ./services/pbgopy.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/picom.nix { }) (loadModule ./services/polybar.nix { }) (loadModule ./services/pulseeffects.nix { condition = hostPlatform.isLinux; }) diff --git a/modules/services/pbgopy.nix b/modules/services/pbgopy.nix new file mode 100644 index 000000000000..a95ad959f008 --- /dev/null +++ b/modules/services/pbgopy.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.pbgopy; + package = pkgs.pbgopy; +in { + meta.maintainers = [ maintainers.ivar ]; + + options.services.pbgopy = { + enable = mkEnableOption "pbgopy"; + + cache.ttl = mkOption { + type = types.str; + default = "24h"; + example = "10m"; + description = '' + The TTL for the cache. Use <literal>"0s"</literal> to disable it. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ package ]; + + systemd.user.services.pbgopy = { + Unit = { + Description = "pbgopy server for sharing the clipboard between devices"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + Service = { + ExecStart = "${package}/bin/pbgopy serve --ttl ${cfg.cache.ttl}"; + Restart = "on-abort"; + }; + Install = { WantedBy = [ "graphical-session.target" ]; }; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 1ce1b5a27ca3..1bc54ec9bc45 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -95,6 +95,7 @@ import nmt { ./modules/services/fluidsynth ./modules/services/kanshi ./modules/services/lieer + ./modules/services/pbgopy ./modules/services/polybar ./modules/services/sxhkd ./modules/services/window-managers/i3 diff --git a/tests/modules/services/pbgopy/default.nix b/tests/modules/services/pbgopy/default.nix new file mode 100644 index 000000000000..c2c9d485ddba --- /dev/null +++ b/tests/modules/services/pbgopy/default.nix @@ -0,0 +1 @@ +{ pbgopy = import ./service.nix; } diff --git a/tests/modules/services/pbgopy/service.nix b/tests/modules/services/pbgopy/service.nix new file mode 100644 index 000000000000..2212143949ab --- /dev/null +++ b/tests/modules/services/pbgopy/service.nix @@ -0,0 +1,22 @@ +{ config, pkgs, ... }: { + config = { + services.pbgopy.enable = true; + + nixpkgs.overlays = [ + (self: super: { + pbgopy = pkgs.writeScriptBin "dummy-pbgopy" "" // { + outPath = "@pbgopy@"; + }; + }) + ]; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/pbgopy.service + + assertFileExists $serviceFile + + assertFileContains $serviceFile \ + 'ExecStart=@pbgopy@/bin/pbgopy serve --ttl 24h' + ''; + }; +} |