Last active
January 15, 2026 14:04
-
-
Save WhiteHusky/d5ab2b3bbd958f903172c35a7b988835 to your computer and use it in GitHub Desktop.
F-Chat Horizon, NixOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { pkgs ? import <nixpkgs> {} }: | |
| pkgs.callPackage ./package.nix {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { lib | |
| , stdenvNoCC | |
| , fetchFromGitHub | |
| , makeWrapper | |
| , makeDesktopItem | |
| , copyDesktopItems | |
| , python3 | |
| , nodejs | |
| , pnpm | |
| , electron_39 | |
| , imagemagick | |
| , dart-sass | |
| , writableTmpDirAsHomeHook | |
| , fetchPnpmDeps | |
| , desktopToDarwinBundle | |
| , nix-update-script | |
| }: | |
| let | |
| electron = electron_39; | |
| in | |
| stdenvNoCC.mkDerivation (finalAttrs: { | |
| pname = "fchat-horizon"; | |
| version = "1.35.5"; | |
| src = fetchFromGitHub { | |
| owner = "Fchat-Horizon"; | |
| repo = "Horizon"; | |
| rev = "v${finalAttrs.version}"; | |
| hash = "sha256-81lJGRg4ZWYjZDHkwYg50cbvt6Q57wn1FgsRObOom58="; | |
| }; | |
| pnpmDepsApp = fetchPnpmDeps { | |
| inherit (finalAttrs) | |
| version | |
| src; | |
| pname = "${finalAttrs.pname}-app"; | |
| pnpmInstallFlags = ["--dir=electron"]; | |
| hash = "sha256-YugyqcPnhnOdfTQVDxaetP33kFHNmM6CtX3yom+qdsM="; | |
| fetcherVersion = 3; | |
| }; | |
| pnpmDepsRoot = fetchPnpmDeps { | |
| inherit (finalAttrs) | |
| version | |
| src; | |
| pname = "${finalAttrs.pname}-root"; | |
| hash = "sha256-skWk7GmbHhxjAleuZDxvHsCA0oNuQnnMZPe4rGC34AE="; | |
| fetcherVersion = 3; | |
| }; | |
| patches = [ | |
| /* | |
| (fetchpatch { | |
| name = "wilted-rose-theme"; | |
| url = "https://github.com/Fchat-Horizon/Horizon/commit/50e9a0cd2623b9bc945d67f16e83ba47228e1b08.patch"; | |
| hash = "sha256-2W8jmf6qnmgBV6IJsCwq1IjNF5lGwRJ8q7ciH9OMZcw="; | |
| }) | |
| */ | |
| ]; | |
| nativeBuildInputs = [ | |
| makeWrapper | |
| python3 | |
| nodejs | |
| pnpm | |
| imagemagick | |
| copyDesktopItems | |
| writableTmpDirAsHomeHook | |
| ] ++ lib.optionals stdenvNoCC.isDarwin [ | |
| desktopToDarwinBundle | |
| ]; | |
| env = { | |
| ELECTRON_SKIP_BINARY_DOWNLOAD = 1; | |
| }; | |
| buildInputs = []; | |
| configurePhase = '' | |
| runHook preConfigure | |
| # Because of multiple package.json's, we have to do our own pnpmConfigHook | |
| echo "Preparing packages..." | |
| export DEP_STORE_PATH=$(mktemp -d) | |
| export APP_STORE_PATH=$(mktemp -d) | |
| echo "Decompressing into store..." | |
| tar --zstd -xf "${finalAttrs.pnpmDepsRoot}/pnpm-store.tar.zst" -C "$DEP_STORE_PATH" | |
| tar --zstd -xf "${finalAttrs.pnpmDepsApp}/pnpm-store.tar.zst" -C "$APP_STORE_PATH" | |
| pushd .. | |
| pnpm config set manage-package-manager-versions false | |
| popd | |
| echo "Installing root dependencies..." | |
| pnpm install \ | |
| --store-dir=$DEP_STORE_PATH \ | |
| --offline --ignore-scripts --frozen-lockfile | |
| pushd electron | |
| echo "Installing app dependencies..." | |
| pnpm install \ | |
| --store-dir=$APP_STORE_PATH \ | |
| --offline --ignore-scripts --frozen-lockfile | |
| popd | |
| # force the sass npm dependency to use our own sass binary instead of the bundled one | |
| substituteInPlace node_modules/sass-embedded/dist/lib/src/compiler-path.js \ | |
| --replace-fail 'compilerCommand = (() => {' 'compilerCommand = (() => { return ["${lib.getExe dart-sass}"];' | |
| runHook postConfigure | |
| ''; | |
| buildPhase = '' | |
| runHook preBuild | |
| pushd electron | |
| pnpm webpack:prod | |
| pnpm exec electron-builder \ | |
| --dir \ | |
| -c.electronDist=${electron.dist} \ | |
| -c.electronVersion=${electron.version} | |
| popd | |
| runHook postBuild | |
| ''; | |
| installPhase = '' | |
| runHook preInstall | |
| mkdir -p $out/share/lib/${finalAttrs.pname} | |
| cp -r electron/dist/*-unpacked/{locales,resources{,.pak}} $out/share/lib/${finalAttrs.pname} | |
| pushd electron/build | |
| for i in 16 24 48 64 96 128 256; do | |
| mkdir -p $out/share/icons/hicolor/''${i}x''${i}/apps | |
| magick icon.png -background none -resize ''${i}x''${i} $out/share/icons/hicolor/''${i}x''${i}/apps/${finalAttrs.pname}.png | |
| done | |
| popd | |
| makeWrapper ${electron}/bin/electron $out/bin/${finalAttrs.pname} \ | |
| --add-flags $out/share/lib/${finalAttrs.pname}/resources/app.asar \ | |
| --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ | |
| --inherit-argv0 | |
| runHook postInstall | |
| ''; | |
| desktopItems = [ | |
| (makeDesktopItem { | |
| name = "${finalAttrs.pname}"; | |
| exec = "${finalAttrs.pname} %u"; | |
| icon = "${finalAttrs.pname}"; | |
| desktopName = "F-Chat Horizon"; | |
| genericName = "F-Chat Client"; | |
| comment = finalAttrs.meta.description; | |
| categories = [ "Network" "Chat" "Adult" ]; | |
| startupWMClass = "horizon-electron"; | |
| }) | |
| ]; | |
| passthru = { | |
| updateScript = nix-update-script { }; | |
| }; | |
| meta = with lib; { | |
| description = "The Best F-Chat 3.0 Client, No exceptions!"; | |
| homepage = "https://horizn.moe/"; | |
| changelog = "https://github.com/Fchat-Horizon/Horizon/blob/v${finalAttrs.version}/CHANGELOG.md"; | |
| license = licenses.gpl3; | |
| maintainers = with lib.maintainers; [ | |
| #whitehusky | |
| ]; | |
| inherit (electron.meta) platforms; | |
| mainProgram = "${finalAttrs.pname}"; | |
| }; | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment