-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(aquaskk): add new Home Manager module
- Loading branch information
1 parent
d030959
commit 0887862
Showing
5 changed files
with
157 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
{ config, lib, pkgs, dotfiles, ... }: | ||
|
||
let | ||
cfg = config.dotfiles.aquaskk; | ||
dictTypes = [ "euc-jp" "online" "skkserv" "kotoeri" "program" "utf-8" ]; | ||
|
||
dictionarySet = lib.mapAttrsToList | ||
(name: config: { | ||
inherit (config) active location; | ||
type = | ||
let | ||
index = dotfiles.lib.indexOf config.type dictTypes; | ||
option = "dotfiles.aquaskk.dictionaries.${name}"; | ||
value = config.type; | ||
in | ||
if index >= 0 then index | ||
else throw "Option '${option}' has unknown value '${value}'."; | ||
}) | ||
cfg.dictionaries; | ||
in | ||
{ | ||
options.dotfiles.aquaskk = { | ||
enable = lib.mkEnableOption "AquaSKK"; | ||
|
||
config = lib.mkOption { | ||
type = with lib.types; attrsOf anything; | ||
default = { }; | ||
description = '' | ||
Configuration for AquaSKK. See the list of available options | ||
[here](https://github.com/codefirst/aquaskk/blob/master/platform/mac/plist/UserDefaults.plist). | ||
''; | ||
}; | ||
|
||
dictionaries = lib.mkOption { | ||
type = with lib.types; attrsOf (submodule ({ name, ... }: { | ||
options = { | ||
active = lib.mkOption { | ||
type = bool; | ||
default = true; | ||
description = "Whether to enable the dictionary \"${name}\"."; | ||
}; | ||
location = lib.mkOption { | ||
type = str; | ||
default = name; | ||
description = "Location of the dictionary \"${name}\"."; | ||
}; | ||
type = lib.mkOption { | ||
type = enum dictTypes; | ||
description = "Type of the dictionary \"${name}\"."; | ||
}; | ||
}; | ||
})); | ||
|
||
default = { | ||
"SKK-JISYO.L" = { | ||
location = "${pkgs.skk-dicts}/share/SKK-JISYO.L"; | ||
type = "utf-8"; | ||
}; | ||
}; | ||
|
||
example = { | ||
"~/.skk-jisyo".type = "euc-jp"; | ||
"SKK-JISYO.L".type = "online"; | ||
}; | ||
|
||
description = '' | ||
Dictionaries to use for SKK conversion. | ||
Dictionaries of type `online` will be fetched from | ||
{option}`dotfiles.aquaskk.config.openlab_host`. The list of available | ||
dictionaries can be seen at <https://skk-dev.github.io/dict/>. | ||
::: {.warning} | ||
Setting this option to a non-empty value will make the dictionary | ||
settings immutable. Because of this, you won't be able to add or remove | ||
dictionaries from the graphical UI. | ||
::: | ||
::: {.warning} | ||
As of 4.7.5, [AquaSKK downloads dictionaries of the `online` type over | ||
unverified HTTP connections][httpdict]. This means that the dictionaries | ||
can be tampered with in transit. The consequences can range from messed | ||
up SKK conversions to attempted attacks on any potential weaknesses in | ||
the dictionary parsing code. | ||
Prefer local dictionaries if malicious network operators are a concern. | ||
::: | ||
[httpdict]: https://github.com/codefirst/aquaskk/blob/4.7.5/src/engine/dictionary/SKKHttpDictionaryLoader.cpp#L59 | ||
''; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
assertions = [ | ||
(lib.hm.assertions.assertPlatform "dotfiles.aquaskk" pkgs | ||
lib.platforms.darwin) | ||
]; | ||
|
||
targets.darwin.defaults = { | ||
"jp.sourceforge.inputmethod.aquaskk.plist" = cfg.config; | ||
}; | ||
|
||
home.file."Library/Application Support/AquaSKK/DictionarySet.plist" = | ||
lib.mkIf (cfg.dictionaries != { }) { | ||
text = lib.generators.toPlist { } dictionarySet; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters