fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . nheko ; 8 9iniFmt = pkgs . formats . ini { }; 10 11configDir = if pkgs . stdenv . hostPlatform . isDarwin then 12"Library/Application Support" 13else 14config . xdg . configHome ; 15 16camelCaseToSnakeCase = 17replaceStrings upperChars ( map ( s :"_ ${ s } " ) lowerChars ); 18 19inherit ( generators ) mkKeyValueDefault toINI ; 20 21in { 22meta . maintainers = [ maintainers . gvolpe ]; 23 24options . programs . nheko = { 25enable = mkEnableOption "Qt desktop client for Matrix" ; 26 27package = mkPackageOption pkgs "nheko" { }; 28 29settings = mkOption { 30type = iniFmt . type ; 31default = { }; 32example = literalExpression '' 33{ 34general.disableCertificateValidation = false; 35auth = { 36accessToken = "SECRET"; 37deviceId = "MY_DEVICE"; 38homeServer = "https://matrix-client.matrix.org:443"; 39userId = "@@user:matrix.org"; 40}; 41settings.scaleFactor = 1.0; 42sidebar.width = 416; 43user = { 44alertOnNotification = true; 45animateImagesOnHover = false; 46"sidebar\\roomListWidth" = 308; 47}; 48} 49'' ; 50description = '' 51Attribute set of Nheko preferences (converted to an INI file). 52 53For now, it is recommended to run nheko and sign-in before filling in 54the configuration settings in this module, as nheko writes the access 55token to {file}`$XDG_CONFIG_HOME/nheko/nheko.conf` the 56first time we sign in, and we need that data into these settings for the 57correct functionality of the application. 58 59This a temporary inconvenience, however, as nheko has plans to move the 60authentication stuff into the local database they currently use. Once 61this happens, this will no longer be an issue. 62'' ; 63}; 64}; 65 66config = mkIf cfg . enable { 67home . packages = [ cfg . package ]; 68 69home . file . " ${ configDir } /nheko/nheko.conf" = mkIf ( cfg . settings != { }) { 70text = '' 71; Generated by Home Manager. 72 73${ toINI { 74mkKeyValue = k : v : 75mkKeyValueDefault { } "=" ( camelCaseToSnakeCase k ) v ; 76} cfg . settings } 77'' ; 78}; 79}; 80} 81