From a2e7adbc79e1209e19ef8829e702f89bd3442a9d Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Sun, 19 Nov 2023 15:49:57 +0100 Subject: [PATCH] element: Add themes --- flake.lock | 18 ++++++++++++++++++ flake.nix | 3 +++ .../apps/matrix/element-client-config.nix | 13 ++++++------- hosts/nachtigall/apps/nginx-matrix.nix | 2 +- overlays/default.nix | 2 ++ overlays/pkgs/element-themes/default.nix | 9 +++++++++ 6 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 overlays/pkgs/element-themes/default.nix diff --git a/flake.lock b/flake.lock index 7c8c8f48..be945455 100644 --- a/flake.lock +++ b/flake.lock @@ -70,6 +70,23 @@ "type": "github" } }, + "element-themes": { + "flake": false, + "locked": { + "lastModified": 1690602100, + "narHash": "sha256-fc/YOx5Py0iOBg2Aw3qjl0SHm+byIjuKdU1b/3q0FXs=", + "owner": "aaronraimist", + "repo": "element-themes", + "rev": "b1dbe27acee74cebe180538ef215208a1c26dc02", + "type": "github" + }, + "original": { + "owner": "aaronraimist", + "ref": "master", + "repo": "element-themes", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -271,6 +288,7 @@ "inputs": { "agenix": "agenix", "deploy-rs": "deploy-rs", + "element-themes": "element-themes", "flake-parts": "flake-parts", "home-manager": "home-manager", "keycloak-theme-pub-solar": "keycloak-theme-pub-solar", diff --git a/flake.nix b/flake.nix index b87603aa..c1711809 100644 --- a/flake.nix +++ b/flake.nix @@ -28,6 +28,9 @@ triton-vmtools.url = "git+https://git.pub.solar/pub-solar/infra-vintage?ref=main&dir=vmtools"; triton-vmtools.inputs.nixpkgs.follows = "nixpkgs"; + + element-themes.url = "github:aaronraimist/element-themes/master"; + element-themes.flake = false; }; outputs = inputs@{ self, ... }: diff --git a/hosts/nachtigall/apps/matrix/element-client-config.nix b/hosts/nachtigall/apps/matrix/element-client-config.nix index e89ea95c..d1425401 100644 --- a/hosts/nachtigall/apps/matrix/element-client-config.nix +++ b/hosts/nachtigall/apps/matrix/element-client-config.nix @@ -1,4 +1,4 @@ -{ +{ pkgs, lib, ... }: { default_server_config = { "m.homeserver" = { base_url = "https://matrix.test.pub.solar"; @@ -8,12 +8,11 @@ base_url = ""; }; }; - # TODO: Add themes - # setting_defaults = { - # custom_themes = {{ matrix_client_element_setting_defaults_custom_themes | to_json }} - # }; - # default_theme = {{ matrix_client_element_default_theme | string | to_json }}; - # default_country_code = {{ matrix_client_element_default_country_code | string | to_json }}; + setting_defaults = { + custom_themes = (lib.modules.importJSON "${pkgs.element-themes}").config; + }; + default_theme = "light"; + default_country_code = "DE"; permalink_prefix = "https://matrix.to"; disable_custom_urls = true; disable_guests = true; diff --git a/hosts/nachtigall/apps/nginx-matrix.nix b/hosts/nachtigall/apps/nginx-matrix.nix index d110248b..dbf927bf 100644 --- a/hosts/nachtigall/apps/nginx-matrix.nix +++ b/hosts/nachtigall/apps/nginx-matrix.nix @@ -5,7 +5,7 @@ let add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header X-XSS-Protection "1; mode=block"; ''; - clientConfig = import ./matrix/element-client-config.nix; + clientConfig = import ./matrix/element-client-config.nix { inherit lib pkgs; }; wellKnownClient = domain: { "m.homeserver".base_url = "https://matrix.${domain}"; "m.identity_server".base_url = "https://matrix.${domain}"; diff --git a/overlays/default.nix b/overlays/default.nix index 3ebaefa0..c11a2c9f 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -13,6 +13,8 @@ forgejo-actions-runner = inputs.unstable.legacyPackages.${prev.system}.forgejo-actions-runner; mediawiki = inputs.unstable.legacyPackages.${prev.system}.mediawiki; + + element-themes = prev.callPackage ./pkgs/element-themes { inherit (inputs) element-themes; }; }) ]; }); diff --git a/overlays/pkgs/element-themes/default.nix b/overlays/pkgs/element-themes/default.nix new file mode 100644 index 00000000..c8a1a598 --- /dev/null +++ b/overlays/pkgs/element-themes/default.nix @@ -0,0 +1,9 @@ +{ stdenvNoCC, jq, element-themes }: +stdenvNoCC.mkDerivation { + src = element-themes; + name = "element-themes"; + nativeBuildInputs = [ jq ]; + buildPhase = '' + find "$src" -name '*.json' -print0 | xargs -0 jq -s '.' > $out + ''; +}