diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9eb116a..c9abbf6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,8 @@ jobs: - rofi-calc-wayland - rofi-emoji-wayland - headscale-ui + - mastodon-bird-ui + - mastodon-bird-ui uses: ./.github/workflows/nix.yml with: diff --git a/README.md b/README.md index 89a949f..3dcdecc 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ There are several packages exposed by this flake. Each directory in `pkgs` conta | cloneit | A CLI tool to download specific GitHub directories or files | | foot-transparent | A patched version of the foot terminal emulator that brings back fullscreen transparency[^1] | | headscale-ui | A web frontend for the headscale Tailscale-compatible coordination server | +| mastodon-bird-ui | Mastodon web UI, but strongly inspired by Twitter. | | mov-cli | A cli tool to browse and watch Movies/Shows/TV/Sports | | rat | Linux shell port of the horizontally spinning rat meme, complete with soundtrack and spin counter. | | reposilite-bin | A derivation for the reposilite maven repository. | diff --git a/pkgs/default.nix b/pkgs/default.nix index d179a0a..a51bd7c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -35,8 +35,9 @@ # static packages # need manual intervention with each update cloneit = callPackage ./cloneit {}; - reposilite-bin = callPackage ./reposilite-bin {}; headscale-ui = callPackage ./headscale-ui {}; + mastodon-bird-ui = callPackage ./mastodon-bird-ui {}; + reposilite-bin = callPackage ./reposilite-bin {}; # patched packages foot-transparent = foot.overrideAttrs (prev: { diff --git a/pkgs/mastodon-bird-ui/default.nix b/pkgs/mastodon-bird-ui/default.nix new file mode 100644 index 0000000..2f08a46 --- /dev/null +++ b/pkgs/mastodon-bird-ui/default.nix @@ -0,0 +1,64 @@ +{ + mastodon, + yq-go, + fetchurl, + ... +}: +mastodon.overrideAttrs (_: { + mastodonModules = mastodon.mastodonModules.overrideAttrs (oldMods: let + # https://github.com/ronilaukkarinen/mastodon-bird-ui + birdui-version = "1.8.2"; + + birdui-single-column = fetchurl { + url = "https://raw.githubusercontent.com/ronilaukkarinen/mastodon-bird-ui/${birdui-version}/layout-single-column.css"; + sha256 = "sha256-hzBWRRx9TjE8PdjL7WsNq46+W68kVG/4zPhUHOn0lnY="; + }; + + birdui-multi-column = fetchurl { + url = "https://raw.githubusercontent.com/ronilaukkarinen/mastodon-bird-ui/${birdui-version}/layout-multiple-columns.css"; + sha256 = "sha256-MakviIcmIQxqQUCDtKbLXxBq4UDUSAyAo0fpcIec4HM="; + }; + 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 = [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 + ''; +})