-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathpackage.nix
More file actions
104 lines (85 loc) · 3.03 KB
/
package.nix
File metadata and controls
104 lines (85 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{
lib,
stdenv,
bun2nix,
bun,
fetchFromGitHub,
jq,
}:
let
versionData = builtins.fromJSON (builtins.readFile ./hashes.json);
inherit (versionData) version hash;
in
stdenv.mkDerivation {
pname = "backlog-md";
inherit version;
src = fetchFromGitHub {
owner = "MrLesk";
repo = "Backlog.md";
rev = "v${version}";
inherit hash;
};
nativeBuildInputs = [
bun2nix.hook
bun
];
bunDeps = bun2nix.fetchBunDeps {
bunNix = ./bun.nix;
};
# We handle build and install ourselves since we need a custom
# two-step build: CSS compilation then bun build --compile
dontUseBunBuild = true;
dontUseBunInstall = true;
# postinstall runs bun2nix (needs .git), prepare runs husky (needs .git)
dontRunLifecycleScripts = true;
# bun resolves caret-range specifiers (^x.y.z) via the npm registry even
# when the pinned version is already in the local cache. In the Nix
# sandbox this fails because the network is blocked. Work around by
# stripping ^ and ~ prefixes from version specs in both package.json
# and bun.lock so bun treats them as exact and skips registry lookups.
postPatch = ''
${lib.getExe jq} '
if .dependencies then .dependencies |= with_entries(.value |= ltrimstr("^") | .value |= ltrimstr("~")) else . end |
if .devDependencies then .devDependencies |= with_entries(.value |= ltrimstr("^") | .value |= ltrimstr("~")) else . end
' package.json > package.json.tmp && mv package.json.tmp package.json
# Also strip ^ and ~ from the workspace deps in bun.lock.
# bun.lock uses a JSONC-like format; sed is sufficient for the
# simple "key": "^version" patterns in the workspace section.
sed -i 's/: "\^/: "/g; s/: "~/: "/g' bun.lock
'';
buildPhase = ''
runHook preBuild
# Native node modules like @parcel/watcher need libstdc++ at build time
${lib.optionalString stdenv.hostPlatform.isLinux ''
export LD_LIBRARY_PATH="${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}"
''}
# Step 1: Build CSS with tailwindcss
bun ./node_modules/@tailwindcss/cli/dist/index.mjs \
-i src/web/styles/source.css \
-o src/web/styles/style.css \
--minify
# Step 2: Compile standalone binary
bun build --production --compile --minify \
--outfile=dist/backlog src/cli.ts
runHook postBuild
'';
# bun compile embeds JS in the binary; stripping would break it
dontStrip = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp dist/backlog $out/bin/backlog
runHook postInstall
'';
passthru.category = "Workflow & Project Management";
meta = with lib; {
description = "Backlog.md - A tool for managing project collaboration between humans and AI Agents in a git ecosystem";
homepage = "https://github.com/MrLesk/Backlog.md";
changelog = "https://github.com/MrLesk/Backlog.md/releases";
license = licenses.mit;
sourceProvenance = with lib.sourceTypes; [ fromSource ];
maintainers = with maintainers; [ ];
mainProgram = "backlog";
platforms = platforms.unix;
};
}