Unverified Commit 316b4b6f authored by h7x4's avatar h7x4 Committed by GitHub
Browse files

add Ringboard pkg and service module (#445583)

parents dd0e3fd5 07850aa9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -142,6 +142,8 @@

- [nvme-rs](https://github.com/liberodark/nvme-rs), NVMe monitoring [services.nvme-rs](#opt-services.nvme-rs.enable).

- [ringboard](https://github.com/SUPERCILEX/clipboard-history), a fast, efficient, and composable clipboard manager for Linux. Available for x11 as [services.ringboard](#opt-services.ringboard.x11.enable) and for wayland as [services.ringboard](#opt-services.ringboard.wayland.enable).

## Backward Incompatibilities {#sec-release-25.11-incompatibilities}

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
+1 −0
Original line number Diff line number Diff line
@@ -915,6 +915,7 @@
  ./services/misc/redlib.nix
  ./services/misc/redmine.nix
  ./services/misc/renovate.nix
  ./services/misc/ringboard.nix
  ./services/misc/rkvm.nix
  ./services/misc/rmfakecloud.nix
  ./services/misc/rshim.nix
+78 −0
Original line number Diff line number Diff line
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.services.ringboard;
in
{
  options.services.ringboard = {
    x11.enable = lib.mkEnableOption "X11 support for Ringboard";
    wayland.enable = lib.mkEnableOption "Wayland support for Ringboard";
    x11.package = lib.mkPackageOption pkgs "ringboard" { };
    wayland.package = lib.mkPackageOption pkgs "ringboard-wayland" { };
  };

  config = lib.mkIf (cfg.x11.enable || cfg.wayland.enable) {
    systemd.user.services.ringboard-server = {
      description = "Ringboard server";
      documentation = [ "https://github.com/SUPERCILEX/clipboard-history" ];
      after = [ "multi-user.target" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        Type = "notify";
        Environment = "RUST_LOG=trace";
        ExecStart = "${
          if cfg.x11.enable then cfg.x11.package else cfg.wayland.package
        }/bin/ringboard-server";
        Restart = "on-failure";
        Slice = "session-ringboard.slice";
      };
    };

    systemd.user.services.ringboard-listener = {
      description = "Ringboard clipboard listener";
      documentation = [ "https://github.com/SUPERCILEX/clipboard-history" ];
      requires = [ "ringboard-server.service" ];
      after = [
        "ringboard-server.service"
        "graphical-session.target"
      ];
      bindsTo = [ "graphical-session.target" ];
      wantedBy = [ "graphical-session.target" ];
      script =
        if cfg.x11.enable && cfg.wayland.enable then
          ''
            if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
              exec '${cfg.wayland.package}'/bin/ringboard-wayland
            else
              exec '${cfg.x11.package}'/bin/ringboard-x11
            fi
          ''
        else if cfg.wayland.enable then
          ''
            exec '${cfg.wayland.package}'/bin/ringboard-wayland
          ''
        else
          ''
            exec '${cfg.x11.package}'/bin/ringboard-x11
          '';
      serviceConfig = {
        Type = "exec";
        Restart = "on-failure";
        Slice = "session-ringboard.slice";
      };
      environment.RUST_LOG = "trace";
    };

    systemd.user.slices.session-ringboard = {
      description = "Ringboard clipboard services";
    };

    environment.systemPackages =
      lib.optionals cfg.x11.enable [ cfg.x11.package ]
      ++ lib.optionals cfg.wayland.enable [ cfg.wayland.package ];
  };
}
+1 −0
Original line number Diff line number Diff line
@@ -1300,6 +1300,7 @@ in
  restic = runTest ./restic.nix;
  restic-rest-server = runTest ./restic-rest-server.nix;
  retroarch = runTest ./retroarch.nix;
  ringboard = runTest ./ringboard.nix;
  rke2 = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./rke2 { };
  rkvm = handleTest ./rkvm { };
  rmfakecloud = runTest ./rmfakecloud.nix;
+49 −0
Original line number Diff line number Diff line
{
  config,
  pkgs,
  lib,
  ...
}:
{
  name = "ringboard";
  meta = { inherit (pkgs.ringboard.meta) maintainers; };

  nodes.machine = {
    imports = [
      ./common/user-account.nix
      ./common/x11.nix
    ];

    test-support.displayManager.auto.user = "alice";

    services.xserver.displayManager.sessionCommands = ''
      '${lib.getExe pkgs.gedit}' &
    '';

    services.ringboard.x11.enable = true;
  };

  testScript =
    { nodes, ... }:
    let
      inherit (nodes.machine.test-support.displayManager.auto) user;
    in
    ''
      @polling_condition
      def gedit_running():
        machine.succeed("pgrep gedit")

      with subtest("Wait for service startup"):
        machine.wait_for_unit("graphical.target")
        machine.wait_for_unit("ringboard-server.service", "${user}")
        machine.wait_for_unit("ringboard-listener.service", "${user}")

      with subtest("Ensure clipboard is monitored"):
        with gedit_running: # type: ignore[union-attr]
          machine.send_chars("Hello world!")
          machine.send_key("ctrl-a")
          machine.send_key("ctrl-c")
          machine.wait_for_console_text("Small selection transfer complete")
          machine.succeed("su - '${user}' -c 'ringboard search Hello | grep world!'")
    '';
}
Loading