nheko: add module

This commit is contained in:
Gabriel Volpe 2022-08-17 13:58:46 +02:00 committed by Robert Helgesson
parent 340ec22f6f
commit 6ec6b2e362
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
9 changed files with 265 additions and 0 deletions

3
.github/CODEOWNERS vendored
View file

@ -204,6 +204,9 @@ Makefile @thiagokokada
/modules/programs/newsboat.nix @sumnerevans /modules/programs/newsboat.nix @sumnerevans
/tests/modules/programs/newsboat @sumnerevans /tests/modules/programs/newsboat @sumnerevans
/modules/programs/nheko.nix @gvolpe
/tests/modules/programs/nheko @gvolpe
/modules/programs/nix-index.nix @ambroisie /modules/programs/nix-index.nix @ambroisie
/tests/modules/programs/nix-index @ambroisie /tests/modules/programs/nix-index @ambroisie

View file

@ -675,6 +675,13 @@ in
A new module is available: 'editorconfig'. A new module is available: 'editorconfig'.
''; '';
} }
{
time = "2022-09-08T15:41:46+00:00";
message = ''
A new module is available: 'programs.nheko'.
'';
}
]; ];
}; };
} }

View file

@ -124,6 +124,7 @@ let
./programs/neomutt.nix ./programs/neomutt.nix
./programs/neovim.nix ./programs/neovim.nix
./programs/newsboat.nix ./programs/newsboat.nix
./programs/nheko.nix
./programs/nix-index.nix ./programs/nix-index.nix
./programs/nnn.nix ./programs/nnn.nix
./programs/noti.nix ./programs/noti.nix

View file

@ -0,0 +1,85 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.nheko;
iniFmt = pkgs.formats.ini { };
configDir = if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support"
else
config.xdg.configHome;
camelCaseToSnakeCase =
replaceStrings upperChars (map (s: "_${s}") lowerChars);
inherit (generators) mkKeyValueDefault toINI;
in {
meta.maintainers = [ maintainers.gvolpe ];
options.programs.nheko = {
enable = mkEnableOption "Qt desktop client for Matrix";
package = mkPackageOption pkgs "nheko" { };
settings = mkOption {
type = iniFmt.type;
default = { };
example = literalExpression ''
{
general.disableCertificateValidation = false;
auth = {
accessToken = "SECRET";
deviceId = "MY_DEVICE";
homeServer = "https://matrix-client.matrix.org:443";
userId = "@@user:matrix.org";
};
settings.scaleFactor = 1.0;
sidebar.width = 416;
user = {
alertOnNotification = true;
animateImagesOnHover = false;
"sidebar\\roomListWidth" = 308;
};
}
'';
description = ''
Attribute set of Nheko preferences (converted to an INI file).
</para><para>
For now, it is recommended to run nheko and sign-in before filling in
the configuration settings in this module, as nheko writes the access
token to <filename>$XDG_CONFIG_HOME/nheko/nheko.conf</filename> the
first time we sign in, and we need that data into these settings for the
correct functionality of the application.
</para><para>
This a temporary inconvenience, however, as nheko has plans to move the
authentication stuff into the local database they currently use. Once
this happens, this will no longer be an issue.
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
home.file."${configDir}/nheko/nheko.conf" = mkIf (cfg.settings != { }) {
text = ''
; Generated by Home Manager.
${toINI {
mkKeyValue = k: v:
mkKeyValueDefault { } "=" (camelCaseToSnakeCase k) v;
} cfg.settings}
'';
};
};
}

View file

@ -94,6 +94,7 @@ import nmt {
./modules/programs/ne ./modules/programs/ne
./modules/programs/neomutt ./modules/programs/neomutt
./modules/programs/newsboat ./modules/programs/newsboat
./modules/programs/nheko
./modules/programs/nix-index ./modules/programs/nix-index
./modules/programs/nnn ./modules/programs/nnn
./modules/programs/nushell ./modules/programs/nushell

View file

@ -0,0 +1,4 @@
{
nheko-empty-settings = ./nheko-empty-settings.nix;
nheko-example-settings = ./nheko-example-settings.nix;
}

View file

@ -0,0 +1,16 @@
{ pkgs, ... }:
let
configDir = if pkgs.stdenv.isDarwin then
"home-files/Library/Application Support"
else
"home-files/.config";
in {
programs.nheko.enable = true;
test.stubs.nheko = { };
nmt.script = ''
assertPathNotExists "${configDir}/nheko/nheko.conf"
'';
}

View file

@ -0,0 +1,64 @@
; Generated by Home Manager.
[auth]
access_token=MY_ACCESS_TOKEN
device_id=MY_DEVICE
home_server=https://matrix-client.matrix.org:443
user_id=@@user:matrix.org
[general]
disable_certificate_validation=false
[settings]
scale_factor=0.700000
[sidebar]
width=416
[user]
alert_on_notification=true
animate_images_on_hover=false
automatically_share_keys_with_trusted_users=false
avatar_circles=true
bubbles_enabled=false
decrypt_sidebar=true
desktop_notifications=true
emoji_font_family=Noto Emoji
expose_dbus_api=false
font_family=JetBrainsMonoMedium Nerd Font Mono
font_size=9
group_view=true
markdown_enabled=true
minor_events=false
mobile_mode=false
muted_tags=global
online_key_backup=false
only_share_keys_with_verified_users=false
open_image_external=false
open_video_external=false
presence=AutomaticPresence
privacy_screen=false
privacy_screen_timeout=0
read_receipts=true
ringtone=Mute
share_keys_with_trusted_users=true
sidebar\community_list_width=40
sidebar\room_list_width=308
small_avatars_enabled=false
sort_by_unread=true
space_notifications=true
theme=dark
timeline\buttons=true
timeline\enlarge_emoji_only_msg=true
timeline\max_width=0
timeline\message_hover_highlight=false
typing_notifications=true
use_identicon=true
use_stun_server=false
window\start_in_tray=false
window\tray=true
[window]
height=482
width=950

View file

@ -0,0 +1,84 @@
{ pkgs, ... }:
let
configDir = if pkgs.stdenv.isDarwin then
"home-files/Library/Application Support"
else
"home-files/.config";
in {
programs.nheko = {
enable = true;
settings = {
general = { disableCertificateValidation = false; };
auth = {
accessToken = "MY_ACCESS_TOKEN";
deviceId = "MY_DEVICE";
homeServer = "https://matrix-client.matrix.org:443";
userId = "@@user:matrix.org";
};
sidebar = { width = 416; };
settings = { scaleFactor = 0.7; };
user = {
alertOnNotification = true;
animateImagesOnHover = false;
automaticallyShareKeysWithTrustedUsers = false;
avatarCircles = true;
bubblesEnabled = false;
decryptSidebar = true;
desktopNotifications = true;
emojiFontFamily = "Noto Emoji";
exposeDbusApi = false;
fontFamily = "JetBrainsMonoMedium Nerd Font Mono";
fontSize = 9;
groupView = true;
markdownEnabled = true;
minorEvents = false;
mobileMode = false;
mutedTags = "global";
onlineKeyBackup = false;
onlyShareKeysWithVerifiedUsers = false;
openImageExternal = false;
openVideoExternal = false;
presence = "AutomaticPresence";
privacyScreen = false;
privacyScreenTimeout = 0;
readReceipts = true;
ringtone = "Mute";
shareKeysWithTrustedUsers = true;
smallAvatarsEnabled = false;
"sidebar\\communityListWidth" = 40;
"sidebar\\roomListWidth" = 308;
sortByUnread = true;
spaceNotifications = true;
theme = "dark";
"timeline\\buttons" = true;
"timeline\\enlargeEmojiOnlyMsg" = true;
"timeline\\maxWidth" = 0;
"timeline\\messageHoverHighlight" = false;
typingNotifications = true;
useIdenticon = true;
useStunServer = false;
"window\\startInTray" = false;
"window\\tray" = true;
};
window = {
height = 482;
width = 950;
};
};
};
test.stubs.nheko = { };
nmt.script = ''
assertFileContent \
"${configDir}/nheko/nheko.conf" \
${./nheko-example-settings-expected-config.ini}
'';
}