Skip to content

Commit 975344e

Browse files
committed
vscode-extensions.vadimcn.vscode-lldb: split up derivation
Multiple derivations nested in a single file can be split up to be easier to logically track what's going on.
1 parent 87fe42d commit 975344e

File tree

3 files changed

+119
-77
lines changed

3 files changed

+119
-77
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
lib,
3+
lldb,
4+
makeWrapper,
5+
rustPlatform,
6+
stdenv,
7+
8+
pname,
9+
src,
10+
version,
11+
}:
12+
rustPlatform.buildRustPackage {
13+
pname = "${pname}-adapter";
14+
inherit version src;
15+
16+
cargoHash = "sha256-e/Jki/4pCs0qzaBVR4iiUhdBFmWlTZYREQkuFSoWYFo=";
17+
18+
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ lldb ];
19+
20+
nativeBuildInputs = [ makeWrapper ];
21+
22+
env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { NIX_LDFLAGS = "-llldb -lc++abi"; };
23+
24+
buildAndTestSubdir = "adapter";
25+
26+
buildFeatures = [ "weak-linkage" ];
27+
28+
cargoBuildFlags = [
29+
"--lib"
30+
"--bin=codelldb"
31+
];
32+
33+
postFixup = ''
34+
mkdir -p $out/share/{adapter,formatters}
35+
# codelldb expects libcodelldb.so to be in the same
36+
# directory as the executable, and can't find it in $out/lib.
37+
# To make codelldb executable as a standalone,
38+
# we put all files in $out/share, and then wrap the binary in $out/bin.
39+
mv $out/bin/* $out/share/adapter
40+
cp $out/lib/* $out/share/adapter
41+
cp -r adapter/scripts $out/share/adapter
42+
cp -t $out/share/formatters formatters/*.py
43+
ln -s ${lib.getLib lldb} $out/share/lldb
44+
makeWrapper $out/share/adapter/codelldb $out/bin/codelldb \
45+
--set-default LLDB_DEBUGSERVER_PATH "${lldb.out}/bin/lldb-server"
46+
'';
47+
48+
patches = [ ./adapter-output-shared_object.patch ];
49+
50+
# Tests are linked to liblldb but it is not available here.
51+
doCheck = false;
52+
}

pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/default.nix

Lines changed: 32 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
python3,
1313
pkg-config,
1414
libsecret,
15-
darwin,
1615
}:
1716
assert lib.versionAtLeast python3.version "3.5";
1817
let
@@ -34,80 +33,36 @@ let
3433
# need to build a custom version of lldb and llvm for enhanced rust support
3534
lldb = (import ./lldb.nix { inherit fetchFromGitHub llvmPackages; });
3635

37-
adapter = rustPlatform.buildRustPackage {
38-
pname = "${pname}-adapter";
39-
inherit version src;
40-
41-
cargoHash = "sha256-e/Jki/4pCs0qzaBVR4iiUhdBFmWlTZYREQkuFSoWYFo=";
42-
43-
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ lldb ];
44-
45-
nativeBuildInputs = [ makeWrapper ];
46-
47-
env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { NIX_LDFLAGS = "-llldb -lc++abi"; };
48-
49-
buildAndTestSubdir = "adapter";
50-
51-
buildFeatures = [ "weak-linkage" ];
52-
53-
cargoBuildFlags = [
54-
"--lib"
55-
"--bin=codelldb"
56-
];
57-
58-
postFixup = ''
59-
mkdir -p $out/share/{adapter,formatters}
60-
# codelldb expects libcodelldb.so to be in the same
61-
# directory as the executable, and can't find it in $out/lib.
62-
# To make codelldb executable as a standalone,
63-
# we put all files in $out/share, and then wrap the binary in $out/bin.
64-
mv $out/bin/* $out/share/adapter
65-
cp $out/lib/* $out/share/adapter
66-
cp -r adapter/scripts $out/share/adapter
67-
cp -t $out/share/formatters formatters/*.py
68-
ln -s ${lib.getLib lldb} $out/share/lldb
69-
makeWrapper $out/share/adapter/codelldb $out/bin/codelldb \
70-
--set-default LLDB_DEBUGSERVER_PATH "${lldb.out}/bin/lldb-server"
71-
'';
72-
73-
patches = [ ./adapter-output-shared_object.patch ];
74-
75-
# Tests are linked to liblldb but it is not available here.
76-
doCheck = false;
77-
};
78-
79-
nodeDeps = buildNpmPackage {
80-
pname = "${pname}-node-deps";
81-
inherit version src;
82-
83-
npmDepsHash = "sha256-fMKGi+AJTMlWl7SQtZ21hUwOLgqlFYDhwLvEergQLfI=";
84-
85-
nativeBuildInputs = [
86-
python3
87-
pkg-config
88-
];
89-
90-
buildInputs =
91-
[ libsecret ]
92-
++ lib.optionals stdenv.hostPlatform.isDarwin (
93-
with darwin.apple_sdk.frameworks;
94-
[
95-
Security
96-
AppKit
97-
]
98-
);
99-
100-
dontNpmBuild = true;
101-
102-
installPhase = ''
103-
runHook preInstall
104-
105-
mkdir -p $out/lib
106-
cp -r node_modules $out/lib
107-
108-
runHook postInstall
109-
'';
110-
};
36+
adapter = (
37+
import ./adapter.nix {
38+
inherit
39+
lib
40+
lldb
41+
makeWrapper
42+
rustPlatform
43+
stdenv
44+
45+
pname
46+
src
47+
version
48+
;
49+
}
50+
);
51+
52+
nodeDeps = (
53+
import ./node_deps.nix {
54+
inherit
55+
buildNpmPackage
56+
libsecret
57+
pkg-config
58+
python3
59+
60+
pname
61+
src
62+
version
63+
;
64+
}
65+
);
11166

11267
# debugservers on macOS require the 'com.apple.security.cs.debugger'
11368
# entitlement which nixpkgs' lldb-server does not yet provide; see
@@ -132,17 +87,17 @@ stdenv.mkDerivation {
13287

13388
nativeBuildInputs = [
13489
cmake
90+
makeWrapper
13591
nodejs
13692
unzip
137-
makeWrapper
13893
];
13994

14095
patches = [ ./cmake-build-extension-only.patch ];
14196

14297
postPatch = ''
14398
# temporary patch for forgotten version updates
14499
substituteInPlace CMakeLists.txt \
145-
--replace "1.9.2" ${version}
100+
--replace-fail "1.9.2" ${version}
146101
'';
147102

148103
postConfigure =
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
buildNpmPackage,
3+
4+
libsecret,
5+
python3,
6+
pkg-config,
7+
8+
pname,
9+
src,
10+
version,
11+
}:
12+
buildNpmPackage {
13+
pname = "${pname}-node-deps";
14+
inherit version src;
15+
16+
npmDepsHash = "sha256-fMKGi+AJTMlWl7SQtZ21hUwOLgqlFYDhwLvEergQLfI=";
17+
18+
nativeBuildInputs = [
19+
python3
20+
pkg-config
21+
];
22+
23+
buildInputs = [ libsecret ];
24+
25+
dontNpmBuild = true;
26+
27+
installPhase = ''
28+
runHook preInstall
29+
30+
mkdir -p $out/lib
31+
cp -r node_modules $out/lib
32+
33+
runHook postInstall
34+
'';
35+
}

0 commit comments

Comments
 (0)