diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 9793d5c3f..e5ea6e1b7 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -101,6 +101,12 @@ github = "diniamo"; githubId = 55629891; }; + dsoverlord = { + name = "Kirill Zakharov"; + email = "dsoverlord@vk.com"; + github = "dsoverlord"; + githubId = 78819443; + }; dwagenk = { email = "dwagenk@mailbox.org"; github = "dwagenk"; diff --git a/modules/modules.nix b/modules/modules.nix index dbeebfbf7..732983440 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -283,6 +283,7 @@ let ./services/cliphist.nix ./services/clipman.nix ./services/clipmenu.nix + ./services/clipse.nix ./services/comodoro.nix ./services/conky.nix ./services/copyq.nix diff --git a/modules/services/clipse.nix b/modules/services/clipse.nix new file mode 100644 index 000000000..dee11fc68 --- /dev/null +++ b/modules/services/clipse.nix @@ -0,0 +1,109 @@ +{ pkgs, config, lib, ... }: +let + cfg = config.services.clipse; + jsonFormat = pkgs.formats.json { }; + +in with lib; + +{ + meta.maintainers = [ lib.maintainers.dsoverlord ]; + + options.services.clipse = { + enable = mkEnableOption "Enable clipse clipboard manager"; + + package = mkPackageOption pkgs "clipse" { }; + + systemdTarget = lib.mkOption { + type = lib.types.str; + default = "graphical-session.target"; + example = "sway-session.target"; + description = '' + The systemd target that will automatically start the clipse service. + + When setting this value to `"sway-session.target"`, + make sure to also enable {option}`wayland.windowManager.sway.systemd.enable`, + otherwise the service may never be started. + ''; + }; + + allowDuplicates = mkOption { + type = types.bool; + default = false; + description = "Allow duplicates"; + }; + + historySize = mkOption { + type = types.int; + default = 100; + description = "Number of history lines to keep."; + }; + + theme = mkOption { + type = jsonFormat.type; + + default = { useCustomTheme = false; }; + + example = literalExpression '' + { + useCustomTheme = true; + DimmedDesc = "#ffffff"; + DimmedTitle = "#ffffff"; + FilteredMatch = "#ffffff"; + NormalDesc = "#ffffff"; + NormalTitle = "#ffffff"; + SelectedDesc = "#ffffff"; + SelectedTitle = "#ffffff"; + SelectedBorder = "#ffffff"; + SelectedDescBorder = "#ffffff"; + TitleFore = "#ffffff"; + Titleback = "#434C5E"; + StatusMsg = "#ffffff"; + PinIndicatorColor = "#ff0000"; + }; + ''; + + description = '' + Configuration written to + {file}`$XDG_CONFIG_HOME/clipse/custom_theme.json`. + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.clipse" pkgs + lib.platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + xdg.configFile."clipse/config.json".source = + jsonFormat.generate "settings" { + allowDuplicates = cfg.allowDuplicates; + historyFile = "clipboard_history.json"; + maxHistory = cfg.historySize; + logFile = "clipse.log"; + themeFile = "custom_theme.json"; + tempDir = "tmp_files"; + }; + + xdg.configFile."clipse/custom_theme.json".source = + jsonFormat.generate "theme" cfg.theme; + + systemd.user.services.clipse = { + Unit = { + Description = "Clipse listener"; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session.target" ]; + }; + + Service = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${cfg.package}/bin/clipse -listen"; + }; + + Install = { WantedBy = [ cfg.systemdTarget ]; }; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 1c143716f..63d5f6262 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -229,6 +229,7 @@ in import nmtSrc { ./modules/services/cachix-agent ./modules/services/cliphist ./modules/services/clipman + ./modules/services/clipse ./modules/services/comodoro ./modules/services/conky ./modules/services/darkman diff --git a/tests/modules/services/clipse/clipse-sway-session-target.nix b/tests/modules/services/clipse/clipse-sway-session-target.nix new file mode 100644 index 000000000..d3223cf6f --- /dev/null +++ b/tests/modules/services/clipse/clipse-sway-session-target.nix @@ -0,0 +1,17 @@ +{ ... }: + +{ + services.clipse = { + enable = true; + systemdTarget = "sway-session.target"; + }; + + test.stubs = { + clipse = { }; + wl-clipboard = { }; + }; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/clipse.service + ''; +} diff --git a/tests/modules/services/clipse/default.nix b/tests/modules/services/clipse/default.nix new file mode 100644 index 000000000..f92f1b679 --- /dev/null +++ b/tests/modules/services/clipse/default.nix @@ -0,0 +1 @@ +{ clipse-sway-session-target = ./clipse-sway-session-target.nix; }