Skip to content

Commit

Permalink
clipman: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
jwygoda authored and 15cm committed Feb 9, 2023
1 parent 79d2068 commit 4b326e1
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 8 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions modules/services/clipman.nix
Original file line number Diff line number Diff line change
@@ -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 ]; };
};
};
}
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions tests/modules/services/clipman/clipman-sway-session-target.nix
Original file line number Diff line number Diff line change
@@ -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}
'';
}
13 changes: 13 additions & 0 deletions tests/modules/services/clipman/clipman-sway-session-target.service
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/modules/services/clipman/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ clipman-sway-session-target = ./clipman-sway-session-target.nix; }

0 comments on commit 4b326e1

Please sign in to comment.