chore(dx/nix): fix flake partially

This commit is contained in:
Elian Doran 2025-09-04 12:12:23 +03:00
parent 62a0a44049
commit df1b87e3ac
No known key found for this signature in database
2 changed files with 25 additions and 19 deletions

View File

@ -36,6 +36,7 @@
stdenv stdenv
wrapGAppsHook3 wrapGAppsHook3
xcodebuild xcodebuild
which
; ;
fullCleanSourceFilter = fullCleanSourceFilter =
@ -46,8 +47,7 @@
baseName = baseNameOf (toString name); baseName = baseNameOf (toString name);
in in
# No need to copy the flake. # No need to copy the flake.
# Don't copy local development instance of NX cache. baseName != "flake.nix" && baseName != "flake.lock"
baseName != "flake.nix" && baseName != "flake.lock" && baseName != ".nx"
); );
fullCleanSource = fullCleanSource =
src: src:
@ -93,12 +93,8 @@
postConfigure = postConfigure =
'' ''
chmod +x node_modules/.pnpm/electron@*/node_modules/electron/install.js chmod +x node_modules/electron/install.js
patchShebangs --build node_modules patchShebangs --build node_modules
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
node_modules/.pnpm/sass-embedded-linux-x64@*/node_modules/sass-embedded-linux-x64/dart-sass/src/dart
''; '';
extraNativeBuildInputs = extraNativeBuildInputs =
@ -113,6 +109,10 @@
# https://github.com/NixOS/nixpkgs/issues/172583 # https://github.com/NixOS/nixpkgs/issues/172583
makeShellWrapper makeShellWrapper
wrapGAppsHook3 wrapGAppsHook3
# For determining the Electron version to rebuild for:
which
electron
] ]
++ lib.optionals (app == "server") [ ++ lib.optionals (app == "server") [
makeBinaryWrapper makeBinaryWrapper
@ -129,7 +129,7 @@
${preBuildCommands} ${preBuildCommands}
''; '';
scriptFull = "pnpm nx ${buildTask} --outputStyle stream --verbose"; scriptFull = "pnpm run ${buildTask}";
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
@ -181,12 +181,12 @@
desktop = makeApp { desktop = makeApp {
app = "desktop"; app = "desktop";
preBuildCommands = "export npm_config_nodedir=${electron.headers}"; preBuildCommands = "export npm_config_nodedir=${electron.headers}; pnpm postinstall";
buildTask = "run desktop:rebuild-deps"; buildTask = "desktop:build";
mainProgram = "trilium"; mainProgram = "trilium";
installCommands = '' installCommands = ''
remove-references-to -t ${electron.headers} apps/desktop/dist/node_modules/better-sqlite3/build/config.gypi #remove-references-to -t ${electron.headers} apps/desktop/dist/node_modules/better-sqlite3/build/config.gypi
remove-references-to -t ${nodejs.python} apps/desktop/dist/node_modules/better-sqlite3/build/config.gypi #remove-references-to -t ${nodejs.python} apps/desktop/dist/node_modules/better-sqlite3/build/config.gypi
mkdir -p $out/{bin,share/icons/hicolor/512x512/apps,opt/trilium} mkdir -p $out/{bin,share/icons/hicolor/512x512/apps,opt/trilium}
cp --archive apps/desktop/dist/* $out/opt/trilium cp --archive apps/desktop/dist/* $out/opt/trilium
@ -203,11 +203,11 @@
server = makeApp { server = makeApp {
app = "server"; app = "server";
preBuildCommands = "pushd apps/server; pnpm rebuild; popd"; preBuildCommands = "pushd apps/server; pnpm rebuild; popd";
buildTask = "--project=server build"; buildTask = "server:build";
mainProgram = "trilium-server"; mainProgram = "trilium-server";
installCommands = '' installCommands = ''
remove-references-to -t ${nodejs.python} apps/server/dist/node_modules/better-sqlite3/build/config.gypi #remove-references-to -t ${nodejs.python} apps/server/dist/node_modules/better-sqlite3/build/config.gypi
remove-references-to -t ${pnpm} apps/server/dist/node_modules/better-sqlite3/build/config.gypi #remove-references-to -t ${pnpm} apps/server/dist/node_modules/better-sqlite3/build/config.gypi
pushd apps/server/dist pushd apps/server/dist
rm -rf node_modules/better-sqlite3/build/Release/obj \ rm -rf node_modules/better-sqlite3/build/Release/obj \

View File

@ -1,11 +1,17 @@
import { execSync } from "child_process"; import { execSync } from "child_process";
import { readFileSync } from "fs"; import { existsSync, readFileSync } from "fs";
import { platform } from "os"; import { platform } from "os";
export function isNixOS() { export function isNixOS() {
if (platform() !== "linux") return false; if (platform() !== "linux") return false;
const osReleaseFile = readFileSync("/etc/os-release", "utf-8");
return osReleaseFile.includes("ID=nixos"); const osReleasePath = "/etc/os-release";
if (existsSync(osReleasePath)) {
const osReleaseFile = readFileSync(osReleasePath, "utf-8");
return osReleaseFile.includes("ID=nixos");
} else {
return !!process.env.NIX_STORE;
}
} }
function resetPath() { function resetPath() {