Unverified Commit 8546851b authored by blenderfreaky's avatar blenderfreaky Committed by kilyanni
Browse files

oxdraw: init at 0.2.0

parent 6811cf7e
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
diff --git a/app/layout.tsx b/app/layout.tsx
index f589fac..56ccb67 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,15 +1,15 @@
 import type { Metadata } from "next";
-import { Geist, Geist_Mono } from "next/font/google";
+import localFont from "next/font/local";
 import "./globals.css";
 
-const geistSans = Geist({
+const geistSans = localFont({
+  src: '../Geist-Regular.otf',
   variable: "--font-geist-sans",
-  subsets: ["latin"],
 });
 
-const geistMono = Geist_Mono({
+const geistMono = localFont({
+  src: '../GeistMono-Regular.otf',
   variable: "--font-geist-mono",
-  subsets: ["latin"],
 });
 
 export const metadata: Metadata = {
+79 −0
Original line number Diff line number Diff line
{
  lib,
  rustPlatform,
  fetchFromGitHub,
  pkg-config,
  openssl,
  buildNpmPackage,
  geist-font,
  nix-update-script,
}:
rustPlatform.buildRustPackage (
  finalAttrs:
  let
    # We manually build the frontend because otherwise it'll try to download stuff from within the sandbox and fail
    frontend = buildNpmPackage {
      pname = "oxdraw-frontend";
      inherit (finalAttrs) version src;

      sourceRoot = "source/frontend";

      patches = [
        # By default, NextJS tries to fetch fonts from google
        # Because of sandboxing, that fails, so we use the
        # font from nixpkgs
        ./font-lookup.patch
      ];

      buildPhase = ''
        runHook preBuild
        cp ${geist-font}/share/fonts/opentype/Geist{,Mono}-Regular.otf .
        npm run build
        runHook postBuild
      '';

      installPhase = ''
        runHook preInstall
        cp -r out $out
        runHook postInstall
      '';

      npmDepsHash = "sha256-Yyox/x78spQqCJDJkPVuzfeAbtd/fdyihDHudIqruo4=";
    };
  in
  {
    pname = "oxdraw";
    version = "0.2.0";

    src = fetchFromGitHub {
      owner = "RohanAdwankar";
      repo = "oxdraw";
      tag = "v${finalAttrs.version}";
      hash = "sha256-2B0G5aWRtUvZiCsX1fOw6M2UhShZaDj11r/fXCemGVc=";
    };

    cargoHash = "sha256-YedNESkXKbfl7FWea7VpDR+59b9WLtZ7GNcyJ7D9yPg=";

    nativeBuildInputs = [ pkg-config ];
    buildInputs = [ openssl ];

    preBuild = ''
      # The build.rs builds the frontend, which we manually build via Nix already
      rm build.rs
    '';

    env.OXDRAW_BUNDLED_WEB_DIST = frontend;

    passthru.updateScript = nix-update-script { };

    meta = {
      description = "Diagram as Code Tool Written in Rust with Draggable Editing";
      homepage = "https://github.com/RohanAdwankar/oxdraw";
      changelog = "https://github.com/RohanAdwankar/oxdraw/releases/tag/v${finalAttrs.version}";
      license = lib.licenses.mit;
      maintainers = [ lib.maintainers.kilyanni ];
      mainProgram = "oxdraw";
      platforms = lib.platforms.linux;
    };
  }
)