clipse: use rfc 042 style settings
This commit is contained in:
parent
a4d410db95
commit
3a60d513d0
4 changed files with 76 additions and 77 deletions
|
|
@ -11,6 +11,25 @@ in
|
|||
{
|
||||
meta.maintainers = [ lib.hm.maintainers.dsoverlord ];
|
||||
|
||||
imports = [
|
||||
(lib.mkRenamedOptionModule
|
||||
[ "services" "clipse" "allowDuplicates" ]
|
||||
[ "services" "clipse" "settings" "allowDuplicates" ]
|
||||
)
|
||||
(lib.mkRenamedOptionModule
|
||||
[ "services" "clipse" "imageDisplay" ]
|
||||
[ "services" "clipse" "settings" "imageDisplay" ]
|
||||
)
|
||||
(lib.mkRenamedOptionModule
|
||||
[ "services" "clipse" "keyBindings" ]
|
||||
[ "services" "clipse" "settings" "keyBindings" ]
|
||||
)
|
||||
(lib.mkRenamedOptionModule
|
||||
[ "services" "clipse" "historySize" ]
|
||||
[ "services" "clipse" "settings" "maxHistory" ]
|
||||
)
|
||||
];
|
||||
|
||||
options.services.clipse = {
|
||||
enable = lib.mkEnableOption "Enable clipse clipboard manager";
|
||||
|
||||
|
|
@ -29,82 +48,26 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
allowDuplicates = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Allow duplicates";
|
||||
};
|
||||
|
||||
historySize = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 100;
|
||||
description = "Number of history lines to keep.";
|
||||
};
|
||||
|
||||
imageDisplay = {
|
||||
type = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"basic"
|
||||
"kitty"
|
||||
"sixel"
|
||||
];
|
||||
default = "basic";
|
||||
description = "Preview image method";
|
||||
};
|
||||
|
||||
scaleX = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 9;
|
||||
description = "Image scaling factor X";
|
||||
};
|
||||
|
||||
scaleY = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 9;
|
||||
description = "Image scaling factor Y";
|
||||
};
|
||||
|
||||
heightCut = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 2;
|
||||
description = "Height cut";
|
||||
};
|
||||
};
|
||||
|
||||
keyBindings = lib.mkOption {
|
||||
settings = lib.mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
|
||||
default = { };
|
||||
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
"choose" = "enter";
|
||||
"clearSelected" = "S";
|
||||
"down" = "down";
|
||||
"end" = "end";
|
||||
"filter" = "/";
|
||||
"home" = "home";
|
||||
"more" = "?";
|
||||
"nextPage" = "right";
|
||||
"prevPage" = "left";
|
||||
"preview" = "t";
|
||||
"quit" = "q";
|
||||
"remove" = "x";
|
||||
"selectDown" = "ctrl+down";
|
||||
"selectSingle" = "s";
|
||||
"selectUp" = "ctrl+up";
|
||||
"togglePin" = "p";
|
||||
"togglePinned" = "tab";
|
||||
"up" = "up";
|
||||
"yankFilter" = "ctrl+s";
|
||||
};
|
||||
{
|
||||
allowDuplicates = true;
|
||||
maxHistory = 1001;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to
|
||||
{file}`$XDG_CONFIG_HOME/clipse/config.json`
|
||||
|
||||
description = "Custom key bindings";
|
||||
Please refer to <https://github.com/savedra1/clipse#configuration> for
|
||||
more information.
|
||||
'';
|
||||
};
|
||||
|
||||
theme = lib.mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
type = lib.types.either jsonFormat.type lib.types.path;
|
||||
|
||||
default = {
|
||||
useCustomTheme = false;
|
||||
|
|
@ -143,17 +106,12 @@ in
|
|||
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
xdg.configFile."clipse/config.json".source = jsonFormat.generate "settings" {
|
||||
inherit (cfg) allowDuplicates imageDisplay keyBindings;
|
||||
historyFile = "clipboard_history.json";
|
||||
maxHistory = cfg.historySize;
|
||||
logFile = "clipse.log";
|
||||
themeFile = "custom_theme.json";
|
||||
tempDir = "tmp_files";
|
||||
xdg.configFile = {
|
||||
"clipse/config.json".source = jsonFormat.generate "settings" cfg.settings;
|
||||
"clipse/custom_theme.json".source =
|
||||
if lib.isPath cfg.theme then cfg.theme else jsonFormat.generate "theme" cfg.theme;
|
||||
};
|
||||
|
||||
xdg.configFile."clipse/custom_theme.json".source = jsonFormat.generate "theme" cfg.theme;
|
||||
|
||||
systemd.user.services.clipse = lib.mkIf (cfg.package != null) {
|
||||
Unit = {
|
||||
Description = "Clipse listener";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"allowDuplicates": true,
|
||||
"imageDisplay": {
|
||||
"scaleX": 9,
|
||||
"scaleY": 9,
|
||||
"type": "kitty"
|
||||
},
|
||||
"maxHistory": 1001
|
||||
}
|
||||
31
tests/modules/services/clipse/clipse-settings.nix
Normal file
31
tests/modules/services/clipse/clipse-settings.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
services.clipse = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
allowDuplicates = true;
|
||||
imageDisplay = {
|
||||
type = "kitty";
|
||||
scaleX = 9;
|
||||
scaleY = 9;
|
||||
};
|
||||
};
|
||||
|
||||
# Legacy option renamed to `services.clipse.settings.maxHistory`.
|
||||
historySize = 1001;
|
||||
};
|
||||
|
||||
test = {
|
||||
stubs.clipse = { };
|
||||
|
||||
asserts.warnings.expected = [
|
||||
"The option `services.clipse.historySize' defined in `${toString ./clipse-settings.nix}' has been renamed to `services.clipse.settings.maxHistory'."
|
||||
];
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
configFile=home-files/.config/clipse/config.json
|
||||
assertFileExists "$configFile"
|
||||
assertFileContent "$configFile" ${./clipse-settings-expected.json}
|
||||
'';
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
clipse-settings = ./clipse-settings.nix;
|
||||
clipse-sway-session-target = ./clipse-sway-session-target.nix;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue