feat(dx/desktop): improve rebuilding experience on NixOS

This commit is contained in:
Elian Doran
2025-09-02 19:56:27 +03:00
parent d058dbe9af
commit 26c7f0b017
3 changed files with 18 additions and 25 deletions

View File

@@ -1,3 +1,4 @@
import { execSync } from "child_process";
import { readFileSync } from "fs";
import { platform } from "os";
@@ -7,7 +8,7 @@ export function isNixOS() {
return osReleaseFile.includes("ID=nixos");
}
export function resetPath() {
function resetPath() {
// On Unix-like systems, PATH is usually inherited from login shell
// but npm prepends node_modules/.bin. Let's remove it:
const origPath = process.env.PATH || "";
@@ -18,3 +19,12 @@ export function resetPath() {
.filter(p => !p.includes("node_modules/.bin"))
.join(":");
}
export function getElectronPath() {
if (isNixOS()) {
resetPath();
return execSync("nix eval --raw nixpkgs#electron_37").toString("utf-8") + "/bin/electron";
} else {
return "electron";
}
}