From 68b22892d053f9dc33682d5e88429b08c1a7dd58 Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Thu, 26 Oct 2023 19:29:26 +0200 Subject: [PATCH] mastodon: Install BirdUI --- system/nixos/mastodon.nix | 63 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/system/nixos/mastodon.nix b/system/nixos/mastodon.nix index e65f47c..207bb4c 100644 --- a/system/nixos/mastodon.nix +++ b/system/nixos/mastodon.nix @@ -2,12 +2,73 @@ let web-domain = "mastodon.kempkens.io"; + + pkg-mastodon = pkgs.mastodon.overrideAttrs (_: { + mastodonModules = pkgs.mastodon.mastodonModules.overrideAttrs (oldMods: + let + # https://github.com/ronilaukkarinen/mastodon-bird-ui + birdui-version = "1.6.4"; + + birdui-single-column = builtins.fetchurl { + url = "https://raw.githubusercontent.com/ronilaukkarinen/mastodon-bird-ui/${birdui-version}/layout-single-column.css"; + sha256 = "05wfq7v1vznq0jv12jm4h4nxg76rz6digjycc63rf3rh6jdz5dn9"; + }; + + birdui-multi-column = builtins.fetchurl { + url = "https://raw.githubusercontent.com/ronilaukkarinen/mastodon-bird-ui/${birdui-version}/layout-multiple-columns.css"; + sha256 = "17p5mg09kwfpn0xfhwpqax32k7zzr660agkfp36b95333hdy4cwa"; + }; + in + { + pname = "${oldMods.pname}+themes"; + + postPatch = '' + # Import theme + styleDir=$PWD/app/javascript/styles + birduiDir=$styleDir/mastodon-bird-ui + + mkdir -p $birduiDir + cat ${birdui-single-column} >$birduiDir/layout-single-column.scss + cat ${birdui-multi-column} >$birduiDir/layout-multiple-columns.scss + + sed -i 's/theme-contrast/theme-mastodon-bird-ui-contrast/g' $birduiDir/layout-single-column.scss + sed -i 's/theme-mastodon-light/theme-mastodon-bird-ui-light/g' $birduiDir/layout-single-column.scss + + sed -i 's/theme-contrast/theme-mastodon-bird-ui-contrast/g' $birduiDir/layout-multiple-columns.scss + sed -i 's/theme-mastodon-light/theme-mastodon-bird-ui-light/g' $birduiDir/layout-multiple-columns.scss + + echo -e "@import 'contrast/variables';\n@import 'application';\n@import 'contrast/diff';\n@import 'mastodon-bird-ui/layout-single-column.scss';\n@import 'mastodon-bird-ui/layout-multiple-columns.scss';" >$styleDir/mastodon-bird-ui-contrast.scss + + echo -e "@import 'mastodon-light/variables';\n@import 'application';\n@import 'mastodon-light/diff';\n@import 'mastodon-bird-ui/layout-single-column.scss';\n@import 'mastodon-bird-ui/layout-multiple-columns.scss';" >$styleDir/mastodon-bird-ui-light.scss + + echo -e "@import 'application';\n@import 'mastodon-bird-ui/layout-single-column.scss';\n@import 'mastodon-bird-ui/layout-multiple-columns.scss';" >$styleDir/mastodon-bird-ui-dark.scss + + # Build theme + echo "mastodon-bird-ui-dark: styles/mastodon-bird-ui-dark.scss" >>$PWD/config/themes.yml + echo "mastodon-bird-ui-light: styles/mastodon-bird-ui-light.scss" >>$PWD/config/themes.yml + echo "mastodon-bird-ui-contrast: styles/mastodon-bird-ui-contrast.scss" >>$PWD/config/themes.yml + ''; + }); + + nativeBuildInputs = [ pkgs.yq-go ]; + + postBuild = '' + # Make theme available + echo "mastodon-bird-ui-dark: styles/mastodon-bird-ui-dark.scss" >>$PWD/config/themes.yml + echo "mastodon-bird-ui-light: styles/mastodon-bird-ui-light.scss" >>$PWD/config/themes.yml + echo "mastodon-bird-ui-contrast: styles/mastodon-bird-ui-contrast.scss" >>$PWD/config/themes.yml + + yq -i '.en.themes.mastodon-bird-ui-dark = "Mastodon Bird UI (Dark)"' $PWD/config/locales/en.yml + yq -i '.en.themes.mastodon-bird-ui-light = "Mastodon Bird UI (Light)"' $PWD/config/locales/en.yml + yq -i '.en.themes.mastodon-bird-ui-contrast = "Mastodon Bird UI (High contrast)"' $PWD/config/locales/en.yml + ''; + }); in { services.mastodon = { enable = true; - # package = pkgs.pkgs-master.mastodon; + package = pkg-mastodon; configureNginx = false;