clipman: add module

This commit is contained in:
Jarosław Wygoda 2022-08-27 20:52:41 +02:00 committed by Robert Helgesson
parent 8745cc9a21
commit fb49fbc368
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
9 changed files with 111 additions and 0 deletions

3
.github/CODEOWNERS vendored
View file

@ -369,6 +369,9 @@ Makefile @thiagokokada
/modules/services/cbatticon.nix @pmiddend
/modules/services/clipman.nix @jwygoda
/tests/modules/services/clipman @jwygoda
/modules/services/clipmenu.nix @DamienCassou
/modules/services/devilspie2.nix @dawidsowa

View file

@ -233,6 +233,12 @@
githubId = 1553581;
name = "Josh Robson Chase";
};
jwygoda = {
name = "Jarosław Wygoda";
email = "jaroslaw@wygoda.me";
github = "jwygoda";
githubId = 20658981;
};
hawkw = {
name = "Eliza Weisman";
email = "eliza@elizas.website";

View file

@ -869,6 +869,14 @@ in
A new module is available: 'services.cachix-agent'.
'';
}
{
time = "2022-12-28T21:48:22+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.clipman'.
'';
}
];
};
}

View file

@ -207,6 +207,7 @@ let
./services/cachix-agent.nix
./services/caffeine.nix
./services/cbatticon.nix
./services/clipman.nix
./services/clipmenu.nix
./services/devilspie2.nix
./services/dropbox.nix

View file

@ -0,0 +1,58 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.clipman;
in {
meta.maintainers = [ maintainers.jwygoda ];
options.services.clipman = {
enable = mkEnableOption "clipman, a simple clipboard manager for Wayland";
package = mkPackageOption pkgs "clipman" { };
systemdTarget = mkOption {
type = types.str;
default = "graphical-session.target";
example = "sway-session.target";
description = ''
The systemd target that will automatically start the Waybar service.
</para>
<para>
When setting this value to <literal>"sway-session.target"</literal>,
make sure to also enable <option>wayland.windowManager.sway.systemdIntegration</option>,
otherwise the service may never be started.
'';
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.clipman" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ];
systemd.user.services.clipman = {
Unit = {
Description = "Clipboard management daemon";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart =
"${pkgs.wl-clipboard}/bin/wl-paste -t text --watch ${cfg.package}/bin/clipman store";
ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR2 $MAINPID";
Restart = "on-failure";
KillMode = "mixed";
};
Install = { WantedBy = [ cfg.systemdTarget ]; };
};
};
}

View file

@ -167,6 +167,7 @@ import nmt {
./modules/services/barrier
./modules/services/borgmatic
./modules/services/cachix-agent
./modules/services/clipman
./modules/services/devilspie2
./modules/services/dropbox
./modules/services/emacs

View file

@ -0,0 +1,20 @@
{ ... }:
{
home.stateVersion = "21.11";
services.clipman = {
enable = true;
systemdTarget = "sway-session.target";
};
test.stubs = {
clipman = { };
wl-clipboard = { };
};
nmt.script = ''
serviceFile=$(normalizeStorePaths home-files/.config/systemd/user/clipman.service)
assertFileContent "$serviceFile" ${./clipman-sway-session-target.service}
'';
}

View file

@ -0,0 +1,13 @@
[Install]
WantedBy=sway-session.target
[Service]
ExecReload=/nix/store/00000000000000000000000000000000-coreutils/bin/kill -SIGUSR2 $MAINPID
ExecStart=@wl-clipboard@/bin/wl-paste -t text --watch @clipman@/bin/clipman store
KillMode=mixed
Restart=on-failure
[Unit]
After=graphical-session.target
Description=Clipboard management daemon
PartOf=graphical-session.target

View file

@ -0,0 +1 @@
{ clipman-sway-session-target = ./clipman-sway-session-target.nix; }