Loading pkgs/by-name/af/affine/package.nix +194 −203 Original line number Diff line number Diff line { cacert, cargo, copyDesktopItems, fetchFromGitHub, fetchurl, findutils, jq, lib, makeDesktopItem, makeWrapper, rsync, rustPlatform, rustc, stdenv, stdenvNoCC, yarn-berry, zip, fetchFromGitHub, rustPlatform, electron_33, nodejs_20, yarn-berry, cacert, writableTmpDirAsHomeHook, cargo, rustc, findutils, zip, rsync, jq, copyDesktopItems, makeWrapper, makeDesktopItem, nix-update-script, buildType ? "stable", commandLineArgs ? "", }: Loading @@ -34,92 +35,68 @@ let electron = electron_33; nodejs = nodejs_20; yarn = yarn-berry.override { inherit nodejs; }; productName = if buildType != "stable" then "AFFiNE-${buildType}" else "AFFiNE"; binName = lib.toLower productName; in stdenv.mkDerivation ( finalAttrs: ( { productName = if buildType == "stable" then "AFFiNE" else "AFFiNE-" + buildType; binName = lib.toLower finalAttrs.productName; pname = finalAttrs.binName; stdenv.mkDerivation (finalAttrs: { pname = binName; # https://github.com/toeverything/AFFiNE/releases/tag/v0.18.1 version = "0.18.1"; GITHUB_SHA = "8b066a4b398aace25a20508a8e3c1a381721971f"; version = "0.19.6"; src = fetchFromGitHub { owner = "toeverything"; repo = "AFFiNE"; rev = finalAttrs.GITHUB_SHA; hash = "sha256-TWwojG3lqQlQFX3BKoFjJ27a3T/SawXgNDO6fP6gW4k="; }; meta = { description = "Workspace with fully merged docs, whiteboards and databases"; longDescription = '' AFFiNE is an open-source, all-in-one workspace and an operating system for all the building blocks that assemble your knowledge base and much more -- wiki, knowledge management, presentation and digital assets ''; homepage = "https://affine.pro/"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ xiaoxiangmoe ]; platforms = [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ]; sourceProvenance = [ lib.sourceTypes.fromSource ]; } // lib.optionalAttrs hostPlatform.isLinux { mainProgram = finalAttrs.binName; tag = "v${finalAttrs.version}"; hash = "sha256-BydTNE36oRIxr2lTnc2+EY0lvMXn4NTLB4EjqzhdjGk="; }; env = { BUILD_TYPE = buildType; }; cargoDeps = rustPlatform.fetchCargoVendor { src = finalAttrs.src; hash = "sha256-5s/X9CD/H9rSn7SqMHioLg1KRP7y9fsozdFRY3hNiP8="; inherit (finalAttrs) pname version src; hash = "sha256-racjpf0VgNod6OxWKSaCbKS9fEkInpDyhVbAHfYWIDo="; }; yarnOfflineCache = stdenvNoCC.mkDerivation { name = "yarn-offline-cache"; src = finalAttrs.src; inherit (finalAttrs) src; nativeBuildInputs = [ yarn cacert writableTmpDirAsHomeHook ]; # force yarn install run in CI mode env.CI = "1"; buildPhase = let supportedArchitectures = builtins.toJSON { os = [ "darwin" "linux" ]; cpu = [ "arm64" "x64" "ia32" "arm64" ]; libc = [ "glibc" "musl" ]; }; buildPhase = '' export HOME="$NIX_BUILD_TOP" export CI=1 in '' runHook preBuild mkdir -p $out yarn config set enableTelemetry false yarn config set cacheFolder $out yarn config set enableGlobalCache false yarn config set supportedArchitectures --json "$supportedArchitectures" yarn config set supportedArchitectures --json '${supportedArchitectures}' yarn install --immutable --mode=skip-build runHook postBuild ''; dontInstall = true; outputHashMode = "recursive"; outputHash = "sha256-HueTia+1ApfvbBK/b+iE84TB1DCWIDLoQ9XhjYlGCUs="; outputHash = "sha256-E9l5zjOOfyDBzYJOU94VrRvt7Hi4XkRTDav9bVlXvlQ="; }; nativeBuildInputs = [ Loading @@ -131,31 +108,27 @@ stdenv.mkDerivation ( zip jq rsync writableTmpDirAsHomeHook ] ++ lib.optionals hostPlatform.isLinux [ copyDesktopItems makeWrapper ]; patchPhase = '' runHook prePatchPhase sed -i '/packagerConfig/a \ electronZipDir: process.env.ELECTRON_FORGE_ELECTRON_ZIP_DIR,' packages/frontend/apps/electron/forge.config.mjs # force yarn install run in CI mode env.CI = "1"; runHook postPatchPhase # Remove code under The AFFiNE Enterprise Edition (EE) license. # Keep file package.json for `yarn install --immutable` lockfile check. postPatch = '' BACKEND_SERVER_PACKAGE_JSON="$(jq 'del(.scripts.postinstall)' packages/backend/server/package.json)" rm -rf packages/backend/server/{.*,*} echo "$BACKEND_SERVER_PACKAGE_JSON" > packages/backend/server/package.json ''; configurePhase = let electronContentPath = electron + (if hostPlatform.isLinux then "/libexec/electron/" else "/Applications/"); in '' configurePhase = '' runHook preConfigurePhase export HOME="$NIX_BUILD_TOP" export CI=1 # cargo config mkdir -p .cargo cat $cargoDeps/.cargo/config.toml >> .cargo/config.toml Loading @@ -168,7 +141,7 @@ stdenv.mkDerivation ( # electron config ELECTRON_VERSION_IN_LOCKFILE=$(yarn why electron --json | tail --lines 1 | jq --raw-output '.children | to_entries | first | .key ' | cut -d : -f 2) rsync --archive --chmod=u+w ${electronContentPath} $HOME/.electron-prebuilt-zip-tmp rsync --archive --chmod=u+w "${electron.dist}/" $HOME/.electron-prebuilt-zip-tmp export ELECTRON_FORGE_ELECTRON_ZIP_DIR=$PWD/.electron_zip_dir mkdir -p $ELECTRON_FORGE_ELECTRON_ZIP_DIR (cd $HOME/.electron-prebuilt-zip-tmp && zip --recurse-paths - .) > $ELECTRON_FORGE_ELECTRON_ZIP_DIR/electron-v$ELECTRON_VERSION_IN_LOCKFILE-${nodePlatform}-${nodeArch}.zip Loading @@ -176,27 +149,26 @@ stdenv.mkDerivation ( runHook postConfigurePhase ''; buildPhase = '' runHook preBuild # first build yarn workspaces focus @affine/electron @affine/monorepo CARGO_NET_OFFLINE=true yarn workspace @affine/native build BUILD_TYPE=${buildType} SKIP_NX_CACHE=1 yarn workspace @affine/electron generate-assets yarn install CARGO_NET_OFFLINE=true yarn affine @affine/native build GITHUB_SHA=ffffffffffffffffffffffffffffffffffffffff BUILD_TYPE=${buildType} SKIP_NX_CACHE=1 yarn affine @affine/electron generate-assets # second build yarn config set nmMode classic yarn config set nmHoistingLimits workspaces find . -name 'node_modules' -type d -prune -exec rm -rf '{}' + yarn workspaces focus @affine/electron @affine/monorepo BUILD_TYPE=${buildType} SKIP_WEB_BUILD=1 SKIP_BUNDLE=1 HOIST_NODE_MODULES=1 yarn workspace @affine/electron make yarn install BUILD_TYPE=${buildType} SKIP_WEB_BUILD=1 SKIP_BUNDLE=1 HOIST_NODE_MODULES=1 yarn affine @affine/electron make runHook postBuild ''; installPhase = let inherit (finalAttrs) binName productName; in if hostPlatform.isDarwin then '' runHook preInstall Loading @@ -214,7 +186,7 @@ stdenv.mkDerivation ( mv packages/frontend/apps/electron/out/${buildType}/${productName}-linux-${nodeArch}/{resources,LICENSE*} $out/lib/${binName}/ install -Dm644 packages/frontend/apps/electron/resources/icons/icon_${buildType}_64x64.png $out/share/icons/hicolor/64x64/apps/${binName}.png makeWrapper "${electron}/bin/electron" $out/bin/${binName} \ makeWrapper "${lib.getExe electron}" $out/bin/${binName} \ --inherit-argv0 \ --add-flags $out/lib/${binName}/resources/app.asar \ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ Loading @@ -222,13 +194,8 @@ stdenv.mkDerivation ( runHook postInstall ''; } // (lib.optionalAttrs hostPlatform.isLinux { desktopItems = let inherit (finalAttrs) binName productName; in [ desktopItems = [ (makeDesktopItem { name = binName; desktopName = productName; Loading @@ -241,6 +208,30 @@ stdenv.mkDerivation ( mimeTypes = [ "x-scheme-handler/${binName}" ]; }) ]; passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex=^v(\\d+\\.\\d+\\.\\d+)$" ]; }; meta = { description = "Workspace with fully merged docs, whiteboards and databases"; longDescription = '' AFFiNE is an open-source, all-in-one workspace and an operating system for all the building blocks that assemble your knowledge base and much more -- wiki, knowledge management, presentation and digital assets ''; homepage = "https://affine.pro/"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ xiaoxiangmoe ]; platforms = [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ]; sourceProvenance = [ lib.sourceTypes.fromSource ]; }; }) ) ) Loading
pkgs/by-name/af/affine/package.nix +194 −203 Original line number Diff line number Diff line { cacert, cargo, copyDesktopItems, fetchFromGitHub, fetchurl, findutils, jq, lib, makeDesktopItem, makeWrapper, rsync, rustPlatform, rustc, stdenv, stdenvNoCC, yarn-berry, zip, fetchFromGitHub, rustPlatform, electron_33, nodejs_20, yarn-berry, cacert, writableTmpDirAsHomeHook, cargo, rustc, findutils, zip, rsync, jq, copyDesktopItems, makeWrapper, makeDesktopItem, nix-update-script, buildType ? "stable", commandLineArgs ? "", }: Loading @@ -34,92 +35,68 @@ let electron = electron_33; nodejs = nodejs_20; yarn = yarn-berry.override { inherit nodejs; }; productName = if buildType != "stable" then "AFFiNE-${buildType}" else "AFFiNE"; binName = lib.toLower productName; in stdenv.mkDerivation ( finalAttrs: ( { productName = if buildType == "stable" then "AFFiNE" else "AFFiNE-" + buildType; binName = lib.toLower finalAttrs.productName; pname = finalAttrs.binName; stdenv.mkDerivation (finalAttrs: { pname = binName; # https://github.com/toeverything/AFFiNE/releases/tag/v0.18.1 version = "0.18.1"; GITHUB_SHA = "8b066a4b398aace25a20508a8e3c1a381721971f"; version = "0.19.6"; src = fetchFromGitHub { owner = "toeverything"; repo = "AFFiNE"; rev = finalAttrs.GITHUB_SHA; hash = "sha256-TWwojG3lqQlQFX3BKoFjJ27a3T/SawXgNDO6fP6gW4k="; }; meta = { description = "Workspace with fully merged docs, whiteboards and databases"; longDescription = '' AFFiNE is an open-source, all-in-one workspace and an operating system for all the building blocks that assemble your knowledge base and much more -- wiki, knowledge management, presentation and digital assets ''; homepage = "https://affine.pro/"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ xiaoxiangmoe ]; platforms = [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ]; sourceProvenance = [ lib.sourceTypes.fromSource ]; } // lib.optionalAttrs hostPlatform.isLinux { mainProgram = finalAttrs.binName; tag = "v${finalAttrs.version}"; hash = "sha256-BydTNE36oRIxr2lTnc2+EY0lvMXn4NTLB4EjqzhdjGk="; }; env = { BUILD_TYPE = buildType; }; cargoDeps = rustPlatform.fetchCargoVendor { src = finalAttrs.src; hash = "sha256-5s/X9CD/H9rSn7SqMHioLg1KRP7y9fsozdFRY3hNiP8="; inherit (finalAttrs) pname version src; hash = "sha256-racjpf0VgNod6OxWKSaCbKS9fEkInpDyhVbAHfYWIDo="; }; yarnOfflineCache = stdenvNoCC.mkDerivation { name = "yarn-offline-cache"; src = finalAttrs.src; inherit (finalAttrs) src; nativeBuildInputs = [ yarn cacert writableTmpDirAsHomeHook ]; # force yarn install run in CI mode env.CI = "1"; buildPhase = let supportedArchitectures = builtins.toJSON { os = [ "darwin" "linux" ]; cpu = [ "arm64" "x64" "ia32" "arm64" ]; libc = [ "glibc" "musl" ]; }; buildPhase = '' export HOME="$NIX_BUILD_TOP" export CI=1 in '' runHook preBuild mkdir -p $out yarn config set enableTelemetry false yarn config set cacheFolder $out yarn config set enableGlobalCache false yarn config set supportedArchitectures --json "$supportedArchitectures" yarn config set supportedArchitectures --json '${supportedArchitectures}' yarn install --immutable --mode=skip-build runHook postBuild ''; dontInstall = true; outputHashMode = "recursive"; outputHash = "sha256-HueTia+1ApfvbBK/b+iE84TB1DCWIDLoQ9XhjYlGCUs="; outputHash = "sha256-E9l5zjOOfyDBzYJOU94VrRvt7Hi4XkRTDav9bVlXvlQ="; }; nativeBuildInputs = [ Loading @@ -131,31 +108,27 @@ stdenv.mkDerivation ( zip jq rsync writableTmpDirAsHomeHook ] ++ lib.optionals hostPlatform.isLinux [ copyDesktopItems makeWrapper ]; patchPhase = '' runHook prePatchPhase sed -i '/packagerConfig/a \ electronZipDir: process.env.ELECTRON_FORGE_ELECTRON_ZIP_DIR,' packages/frontend/apps/electron/forge.config.mjs # force yarn install run in CI mode env.CI = "1"; runHook postPatchPhase # Remove code under The AFFiNE Enterprise Edition (EE) license. # Keep file package.json for `yarn install --immutable` lockfile check. postPatch = '' BACKEND_SERVER_PACKAGE_JSON="$(jq 'del(.scripts.postinstall)' packages/backend/server/package.json)" rm -rf packages/backend/server/{.*,*} echo "$BACKEND_SERVER_PACKAGE_JSON" > packages/backend/server/package.json ''; configurePhase = let electronContentPath = electron + (if hostPlatform.isLinux then "/libexec/electron/" else "/Applications/"); in '' configurePhase = '' runHook preConfigurePhase export HOME="$NIX_BUILD_TOP" export CI=1 # cargo config mkdir -p .cargo cat $cargoDeps/.cargo/config.toml >> .cargo/config.toml Loading @@ -168,7 +141,7 @@ stdenv.mkDerivation ( # electron config ELECTRON_VERSION_IN_LOCKFILE=$(yarn why electron --json | tail --lines 1 | jq --raw-output '.children | to_entries | first | .key ' | cut -d : -f 2) rsync --archive --chmod=u+w ${electronContentPath} $HOME/.electron-prebuilt-zip-tmp rsync --archive --chmod=u+w "${electron.dist}/" $HOME/.electron-prebuilt-zip-tmp export ELECTRON_FORGE_ELECTRON_ZIP_DIR=$PWD/.electron_zip_dir mkdir -p $ELECTRON_FORGE_ELECTRON_ZIP_DIR (cd $HOME/.electron-prebuilt-zip-tmp && zip --recurse-paths - .) > $ELECTRON_FORGE_ELECTRON_ZIP_DIR/electron-v$ELECTRON_VERSION_IN_LOCKFILE-${nodePlatform}-${nodeArch}.zip Loading @@ -176,27 +149,26 @@ stdenv.mkDerivation ( runHook postConfigurePhase ''; buildPhase = '' runHook preBuild # first build yarn workspaces focus @affine/electron @affine/monorepo CARGO_NET_OFFLINE=true yarn workspace @affine/native build BUILD_TYPE=${buildType} SKIP_NX_CACHE=1 yarn workspace @affine/electron generate-assets yarn install CARGO_NET_OFFLINE=true yarn affine @affine/native build GITHUB_SHA=ffffffffffffffffffffffffffffffffffffffff BUILD_TYPE=${buildType} SKIP_NX_CACHE=1 yarn affine @affine/electron generate-assets # second build yarn config set nmMode classic yarn config set nmHoistingLimits workspaces find . -name 'node_modules' -type d -prune -exec rm -rf '{}' + yarn workspaces focus @affine/electron @affine/monorepo BUILD_TYPE=${buildType} SKIP_WEB_BUILD=1 SKIP_BUNDLE=1 HOIST_NODE_MODULES=1 yarn workspace @affine/electron make yarn install BUILD_TYPE=${buildType} SKIP_WEB_BUILD=1 SKIP_BUNDLE=1 HOIST_NODE_MODULES=1 yarn affine @affine/electron make runHook postBuild ''; installPhase = let inherit (finalAttrs) binName productName; in if hostPlatform.isDarwin then '' runHook preInstall Loading @@ -214,7 +186,7 @@ stdenv.mkDerivation ( mv packages/frontend/apps/electron/out/${buildType}/${productName}-linux-${nodeArch}/{resources,LICENSE*} $out/lib/${binName}/ install -Dm644 packages/frontend/apps/electron/resources/icons/icon_${buildType}_64x64.png $out/share/icons/hicolor/64x64/apps/${binName}.png makeWrapper "${electron}/bin/electron" $out/bin/${binName} \ makeWrapper "${lib.getExe electron}" $out/bin/${binName} \ --inherit-argv0 \ --add-flags $out/lib/${binName}/resources/app.asar \ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ Loading @@ -222,13 +194,8 @@ stdenv.mkDerivation ( runHook postInstall ''; } // (lib.optionalAttrs hostPlatform.isLinux { desktopItems = let inherit (finalAttrs) binName productName; in [ desktopItems = [ (makeDesktopItem { name = binName; desktopName = productName; Loading @@ -241,6 +208,30 @@ stdenv.mkDerivation ( mimeTypes = [ "x-scheme-handler/${binName}" ]; }) ]; passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex=^v(\\d+\\.\\d+\\.\\d+)$" ]; }; meta = { description = "Workspace with fully merged docs, whiteboards and databases"; longDescription = '' AFFiNE is an open-source, all-in-one workspace and an operating system for all the building blocks that assemble your knowledge base and much more -- wiki, knowledge management, presentation and digital assets ''; homepage = "https://affine.pro/"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ xiaoxiangmoe ]; platforms = [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ]; sourceProvenance = [ lib.sourceTypes.fromSource ]; }; }) ) )