@typerighter/rpc-server 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/install.js +17 -6
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { execFileSync } from "node:child_process";
2
- import { mkdirSync, chmodSync, copyFileSync } from "node:fs";
2
+ import { mkdirSync, chmodSync, copyFileSync, existsSync } from "node:fs";
3
3
  import path from "node:path";
4
4
  import {
5
5
  dev,
@@ -29,10 +29,15 @@ if (dev()) {
29
29
  process.exit(0);
30
30
  }
31
31
 
32
- // On NixOS, build using the Nix derivation
32
+ // On NixOS, build using Nix derivation
33
33
  if (isNixOS()) {
34
+ const tag = releaseTag();
35
+ const flakeTarget = existsSync(path.join(repoRoot(), "flake.nix"))
36
+ ? ".#typedown-rpc"
37
+ : `github:huydo862003/typerighter/${tag}#typedown-rpc`;
38
+
34
39
  console.log(
35
- "[rpc-server] NixOS detected: building typedown-rpc using Nix derivation",
40
+ `[rpc-server] NixOS detected: building typedown-rpc using Nix derivation (${flakeTarget})`,
36
41
  );
37
42
  const binDir = path.dirname(bin);
38
43
  mkdirSync(binDir, { recursive: true });
@@ -40,7 +45,14 @@ if (isNixOS()) {
40
45
  try {
41
46
  const outPath = execFileSync(
42
47
  "nix",
43
- ["build", ".#typedown-rpc", "--no-link", "--print-out-paths"],
48
+ [
49
+ "--extra-experimental-features",
50
+ "nix-command flakes",
51
+ "build",
52
+ flakeTarget,
53
+ "--no-link",
54
+ "--print-out-paths",
55
+ ],
44
56
  {
45
57
  cwd: repoRoot(),
46
58
  encoding: "utf8",
@@ -55,8 +67,7 @@ if (isNixOS()) {
55
67
  console.log("[rpc-server] typedown-rpc built and installed successfully via Nix");
56
68
  process.exit(0);
57
69
  } catch {
58
- console.error("[rpc-server] nix build failed");
59
- process.exit(1);
70
+ console.warn("[rpc-server] nix build failed, falling back to binary download");
60
71
  }
61
72
  }
62
73
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@typerighter/rpc-server",
4
- "version": "0.4.2",
4
+ "version": "0.4.4",
5
5
  "description": "Typedown RPC server binary.",
6
6
  "repository": {
7
7
  "type": "git",