Unverified Commit f5fd10f1 authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

overlayed: combine webui into main derivation, use cargo-tauri.hook (#407188)

parents a0282ec5 674f036c
Loading
Loading
Loading
Loading
+27 −13
Original line number Diff line number Diff line
{
  rustPlatform,
  lib,
  callPackage,
  rustPlatform,
  fetchFromGitHub,

  cargo-tauri,
  jq,
  moreutils,
  nodejs,
  pkg-config,
  openssl,
  pnpm_9,

  libayatana-appindicator,
  libsoup_3,
  openssl,
  webkitgtk_4_1,
  fetchFromGitHub,
  libayatana-appindicator,
  nix-update-script,
}:

rustPlatform.buildRustPackage rec {
@@ -22,23 +27,31 @@ rustPlatform.buildRustPackage rec {
    hash = "sha256-3GFg8czBf1csojXUNC51xFXJnGuXltP6D46fCt6q24I=";
  };

  sourceRoot = "${src.name}/apps/desktop/src-tauri";
  cargoRoot = "apps/desktop/src-tauri";
  buildAndTestSubdir = "apps/desktop/src-tauri";

  useFetchCargoVendor = true;
  cargoHash = "sha256-6wN4nZQWrY0J5E+auj17B3iJ/84hzBXYA/bJsX/N5pk=";

  webui = callPackage ./webui.nix {
    inherit meta src version;
  pnpmDeps = pnpm_9.fetchDeps {
    inherit pname version src;
    hash = "sha256-+yyxoodcDfqJ2pkosd6sMk77/71RDsGthedo1Oigwto=";
  };

  nativeBuildInputs = [
    cargo-tauri.hook
    jq
    moreutils
    nodejs
    pkg-config
    pnpm_9.configHook
  ];

  buildInputs = [
    libayatana-appindicator
    libsoup_3
    openssl
    webkitgtk_4_1
    libsoup_3
  ];

  env = {
@@ -48,9 +61,10 @@ rustPlatform.buildRustPackage rec {
  postPatch = ''
    substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \
      --replace-fail "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1"
    substituteInPlace ./tauri.conf.json \
      --replace-fail '../dist' '${webui}' \
      --replace-fail 'pnpm build' ' '

    # disable updater
    jq '.plugins.updater.endpoints = [ ] | .bundle.createUpdaterArtifacts = false' \
      apps/desktop/src-tauri/tauri.conf.json | sponge apps/desktop/src-tauri/tauri.conf.json
  '';

  meta = {
+0 −40
Original line number Diff line number Diff line
{
  src,
  meta,
  version,
  stdenv,
  nodejs,
  pnpm_9,
}:

stdenv.mkDerivation (finalAttrs: {
  inherit version src meta;
  pname = "overlayed-webui";

  pnpmDeps = pnpm_9.fetchDeps {
    inherit (finalAttrs) src pname version;
    hash = "sha256-+yyxoodcDfqJ2pkosd6sMk77/71RDsGthedo1Oigwto=";
  };

  nativeBuildInputs = [
    nodejs
    pnpm_9.configHook
  ];

  buildPhase = ''
    runHook preBuild

    cd apps/desktop
    node --max_old_space_size=1024000 ./node_modules/vite/bin/vite.js build

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    cp -r dist $out

    runHook postInstall
  '';
})