at master 2.4 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7let 8 cfg = config.services.ringboard; 9in 10{ 11 options.services.ringboard = { 12 x11.enable = lib.mkEnableOption "X11 support for Ringboard"; 13 wayland.enable = lib.mkEnableOption "Wayland support for Ringboard"; 14 x11.package = lib.mkPackageOption pkgs "ringboard" { }; 15 wayland.package = lib.mkPackageOption pkgs "ringboard-wayland" { }; 16 }; 17 18 config = lib.mkIf (cfg.x11.enable || cfg.wayland.enable) { 19 systemd.user.services.ringboard-server = { 20 description = "Ringboard server"; 21 documentation = [ "https://github.com/SUPERCILEX/clipboard-history" ]; 22 after = [ "multi-user.target" ]; 23 wantedBy = [ "multi-user.target" ]; 24 serviceConfig = { 25 Type = "notify"; 26 Environment = "RUST_LOG=trace"; 27 ExecStart = "${ 28 if cfg.x11.enable then cfg.x11.package else cfg.wayland.package 29 }/bin/ringboard-server"; 30 Restart = "on-failure"; 31 Slice = "session-ringboard.slice"; 32 }; 33 }; 34 35 systemd.user.services.ringboard-listener = { 36 description = "Ringboard clipboard listener"; 37 documentation = [ "https://github.com/SUPERCILEX/clipboard-history" ]; 38 requires = [ "ringboard-server.service" ]; 39 after = [ 40 "ringboard-server.service" 41 "graphical-session.target" 42 ]; 43 bindsTo = [ "graphical-session.target" ]; 44 wantedBy = [ "graphical-session.target" ]; 45 script = 46 if cfg.x11.enable && cfg.wayland.enable then 47 '' 48 if [ "$XDG_SESSION_TYPE" = "wayland" ]; then 49 exec '${cfg.wayland.package}'/bin/ringboard-wayland 50 else 51 exec '${cfg.x11.package}'/bin/ringboard-x11 52 fi 53 '' 54 else if cfg.wayland.enable then 55 '' 56 exec '${cfg.wayland.package}'/bin/ringboard-wayland 57 '' 58 else 59 '' 60 exec '${cfg.x11.package}'/bin/ringboard-x11 61 ''; 62 serviceConfig = { 63 Type = "exec"; 64 Restart = "on-failure"; 65 Slice = "session-ringboard.slice"; 66 }; 67 environment.RUST_LOG = "trace"; 68 }; 69 70 systemd.user.slices.session-ringboard = { 71 description = "Ringboard clipboard services"; 72 }; 73 74 environment.systemPackages = 75 lib.optionals cfg.x11.enable [ cfg.x11.package ] 76 ++ lib.optionals cfg.wayland.enable [ cfg.wayland.package ]; 77 }; 78}