1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

element-desktop: add module (#6935)

This commit is contained in:
Aguirre Matteo 2025-05-02 13:17:24 +00:00 committed by GitHub
parent f045bd46b7
commit 669e813c75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 304 additions and 0 deletions

View file

@ -97,6 +97,7 @@ let
./programs/distrobox.nix ./programs/distrobox.nix
./programs/earthly.nix ./programs/earthly.nix
./programs/eclipse.nix ./programs/eclipse.nix
./programs/element-desktop.nix
./programs/emacs.nix ./programs/emacs.nix
./programs/eww.nix ./programs/eww.nix
./programs/eza.nix ./programs/eza.nix

View file

@ -0,0 +1,121 @@
{
lib,
pkgs,
config,
...
}:
let
inherit (lib)
types
mkIf
mkEnableOption
mkPackageOption
mkOption
;
cfg = config.programs.element-desktop;
formatter = pkgs.formats.json { };
prefix =
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.configHome;
in
{
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
options.programs.element-desktop = {
enable = mkEnableOption "element-desktop";
package = mkPackageOption pkgs "element-desktop" { nullable = true; };
settings = mkOption {
type = formatter.type;
default = { };
example = ''
{
default_server_config = {
"m.homeserver" = {
base_url = "https://matrix-client.matrix.org";
server_name = "matrix.org";
};
"m.identity_server" = {
base_url = "https://vector.im";
};
};
disable_custom_urls = false;
disable_guests = false;
disable_login_language_selector = false;
disable_3pid_login = false;
force_verification = false;
brand = "Element";
integrations_ui_url = "https://scalar.vector.im/";
integrations_rest_url = "https://scalar.vector.im/api";
}
'';
description = ''
Configuration settings for Element's default profiles.
WARNING: Element doesn't combine this config with the defaults,
so make sure to configure most options. For details about this
behavior and available configuration options see:
<https://github.com/element-hq/element-web/blob/develop/docs/config.md>
'';
};
profiles = mkOption {
type = types.attrsOf formatter.type;
default = { };
example = ''
{
work = {
default_server_config = {
"m.homeserver" = {
base_url = "https://matrix-client.matrix.org";
server_name = "matrix.org";
};
"m.identity_server" = {
base_url = "https://vector.im";
};
};
};
home = {
disable_custom_urls = false;
disable_guests = false;
disable_login_language_selector = false;
disable_3pid_login = false;
};
other = {
force_verification = false;
brand = "Element";
integrations_ui_url = "https://scalar.vector.im/";
integrations_rest_url = "https://scalar.vector.im/api";
};
}
'';
description = ''
Extra profiles for Element. Those can be accessed using the
"--profile $NAME" flag. The same warning and options apply
here.
'';
};
};
config = mkIf cfg.enable {
home.packages = mkIf (cfg.package != null) [ cfg.package ];
home.file =
let
defaultConfig =
if (cfg.settings != { }) then
{
"${prefix}/Element/config.json".source = (
formatter.generate "element-desktop-default" cfg.settings
);
}
else
{ };
in
defaultConfig
// (lib.mapAttrs' (
name: value:
lib.nameValuePair "${prefix}/Element-${name}/config.json" {
source = (formatter.generate "element-desktop-${name}" cfg.profiles."${name}");
}
) cfg.profiles);
};
}

View file

@ -326,6 +326,7 @@ import nmtSrc {
++ lib.optionals isDarwin [ ++ lib.optionals isDarwin [
./modules/launchd ./modules/launchd
./modules/programs/aerospace ./modules/programs/aerospace
./modules/programs/element-desktop/darwin.nix
./modules/services/emacs-darwin ./modules/services/emacs-darwin
./modules/services/espanso-darwin ./modules/services/espanso-darwin
./modules/services/git-sync-darwin ./modules/services/git-sync-darwin
@ -359,6 +360,7 @@ import nmtSrc {
./modules/programs/boxxy ./modules/programs/boxxy
./modules/programs/cavalier ./modules/programs/cavalier
./modules/programs/distrobox ./modules/programs/distrobox
./modules/programs/element-desktop/linux.nix
./modules/programs/eww ./modules/programs/eww
./modules/programs/firefox ./modules/programs/firefox
./modules/programs/firefox/firefox.nix ./modules/programs/firefox/firefox.nix

View file

@ -0,0 +1,19 @@
{
"brand": "Element",
"default_server_config": {
"m.homeserver": {
"base_url": "https://matrix-client.matrix.org",
"server_name": "matrix.org"
},
"m.identity_server": {
"base_url": "https://vector.im"
}
},
"disable_3pid_login": false,
"disable_custom_urls": false,
"disable_guests": false,
"disable_login_language_selector": false,
"force_verification": false,
"integrations_rest_url": "https://scalar.vector.im/api",
"integrations_ui_url": "https://scalar.vector.im/"
}

View file

@ -0,0 +1,6 @@
{
"disable_3pid_login": false,
"disable_custom_urls": false,
"disable_guests": false,
"disable_login_language_selector": false
}

View file

@ -0,0 +1,6 @@
{
"brand": "Element",
"force_verification": false,
"integrations_rest_url": "https://scalar.vector.im/api",
"integrations_ui_url": "https://scalar.vector.im/"
}

View file

@ -0,0 +1,11 @@
{
"default_server_config": {
"m.homeserver": {
"base_url": "https://matrix-client.matrix.org",
"server_name": "matrix.org"
},
"m.identity_server": {
"base_url": "https://vector.im"
}
}
}

View file

@ -0,0 +1 @@
{ element-desktop-darwin = ./example-config-darwin.nix; }

View file

@ -0,0 +1,68 @@
{
programs.element-desktop = {
enable = true;
settings = {
default_server_config = {
"m.homeserver" = {
base_url = "https://matrix-client.matrix.org";
server_name = "matrix.org";
};
"m.identity_server" = {
base_url = "https://vector.im";
};
};
disable_custom_urls = false;
disable_guests = false;
disable_login_language_selector = false;
disable_3pid_login = false;
force_verification = false;
brand = "Element";
integrations_ui_url = "https://scalar.vector.im/";
integrations_rest_url = "https://scalar.vector.im/api";
};
profiles = {
work = {
default_server_config = {
"m.homeserver" = {
base_url = "https://matrix-client.matrix.org";
server_name = "matrix.org";
};
"m.identity_server" = {
base_url = "https://vector.im";
};
};
};
home = {
disable_custom_urls = false;
disable_guests = false;
disable_login_language_selector = false;
disable_3pid_login = false;
};
other = {
force_verification = false;
brand = "Element";
integrations_ui_url = "https://scalar.vector.im/";
integrations_rest_url = "https://scalar.vector.im/api";
};
};
};
nmt.script = ''
assertFileExists "home-files/Library/Application Support/Element/config.json"
assertFileExists "home-files/Library/Application Support/Element-work/config.json"
assertFileExists "home-files/Library/Application Support/Element-home/config.json"
assertFileExists "home-files/Library/Application Support/Element-other/config.json"
assertFileContent "home-files/Library/Application Support/Element/config.json" \
${./cfg/default.json}
assertFileContent "home-files/Library/Application Support/Element-work/config.json" \
${./cfg/work.json}
assertFileContent "home-files/Library/Application Support/Element-home/config.json" \
${./cfg/home.json}
assertFileContent "home-files/Library/Application Support/Element-other/config.json" \
${./cfg/other.json}
'';
}

View file

@ -0,0 +1,68 @@
{
programs.element-desktop = {
enable = true;
settings = {
default_server_config = {
"m.homeserver" = {
base_url = "https://matrix-client.matrix.org";
server_name = "matrix.org";
};
"m.identity_server" = {
base_url = "https://vector.im";
};
};
disable_custom_urls = false;
disable_guests = false;
disable_login_language_selector = false;
disable_3pid_login = false;
force_verification = false;
brand = "Element";
integrations_ui_url = "https://scalar.vector.im/";
integrations_rest_url = "https://scalar.vector.im/api";
};
profiles = {
work = {
default_server_config = {
"m.homeserver" = {
base_url = "https://matrix-client.matrix.org";
server_name = "matrix.org";
};
"m.identity_server" = {
base_url = "https://vector.im";
};
};
};
home = {
disable_custom_urls = false;
disable_guests = false;
disable_login_language_selector = false;
disable_3pid_login = false;
};
other = {
force_verification = false;
brand = "Element";
integrations_ui_url = "https://scalar.vector.im/";
integrations_rest_url = "https://scalar.vector.im/api";
};
};
};
nmt.script = ''
assertFileExists home-files/.config/Element/config.json
assertFileExists home-files/.config/Element-work/config.json
assertFileExists home-files/.config/Element-home/config.json
assertFileExists home-files/.config/Element-other/config.json
assertFileContent home-files/.config/Element/config.json \
${./cfg/default.json}
assertFileContent home-files/.config/Element-work/config.json \
${./cfg/work.json}
assertFileContent home-files/.config/Element-home/config.json \
${./cfg/home.json}
assertFileContent home-files/.config/Element-other/config.json \
${./cfg/other.json}
'';
}

View file

@ -0,0 +1 @@
{ element-desktop-linux = ./example-config-linux.nix; }