Skip to content

Commit eaea858

Browse files
authored
revert(nix): back to the runCommand solution (#41)
1 parent 1a1ca49 commit eaea858

File tree

1 file changed

+66
-67
lines changed

1 file changed

+66
-67
lines changed

package.nix

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,81 @@
11
{
22
stdenv,
33
lib,
4+
runCommand,
45
writeShellApplication,
56
tree-sitter-nu ? fetchGit "https://github.com/nushell/tree-sitter-nu",
67
topiary,
78
nushell,
8-
writeText,
99
callPackage,
10-
symlinkJoin,
1110
}:
12-
symlinkJoin {
13-
name = "topiary-nushell";
14-
paths = [
15-
(writeShellApplication (
16-
let
17-
libtree-sitter-nu = callPackage (
18-
{
19-
lib,
20-
stdenv,
21-
}:
22-
stdenv.mkDerivation (finalAttrs: {
23-
pname = "tree-sitter-nu";
24-
version = tree-sitter-nu.rev;
11+
writeShellApplication (
12+
let
13+
libtree-sitter-nu = callPackage (
14+
{
15+
lib,
16+
stdenv,
17+
}:
18+
stdenv.mkDerivation (finalAttrs: {
19+
pname = "tree-sitter-nu";
20+
version = tree-sitter-nu.rev;
21+
22+
src = tree-sitter-nu;
23+
24+
makeFlags = [
25+
# The PREFIX var isn't picking up from stdenv.
26+
"PREFIX=$(out)"
27+
];
2528

26-
src = tree-sitter-nu;
29+
meta = with lib; {
30+
description = "A tree-sitter grammar for nu-lang, the language of nushell";
31+
homepage = "https://github.com/nushell/tree-sitter-nu";
32+
license = licenses.mit;
33+
};
34+
})
35+
) { };
36+
37+
extension =
38+
with stdenv;
39+
if isLinux then
40+
".so"
41+
else if isDarwin then
42+
".dylib"
43+
else
44+
throw "Unsupported system: ${system}";
2745

28-
makeFlags = [
29-
# The PREFIX var isn't picking up from stdenv.
30-
"PREFIX=$(out)"
31-
];
46+
# Create a directory holding ALL runtime config files
47+
# This makes a single path for GC root.
48+
topiaryConfigDir = runCommand "topiary-nushell-config" { } ''
49+
local_config_dir="$out"
3250
33-
meta = with lib; {
34-
description = "A tree-sitter grammar for nu-lang, the language of nushell";
35-
homepage = "https://github.com/nushell/tree-sitter-nu";
36-
license = licenses.mit;
37-
};
38-
})
39-
) { };
51+
# 1. Copy the nu.scm language directory
52+
mkdir -p $local_config_dir/languages
53+
cp ${./languages/nu.scm} $local_config_dir/languages/nu.scm
4054
41-
extension =
42-
with stdenv;
43-
if isLinux then
44-
".so"
45-
else if isDarwin then
46-
".dylib"
47-
else
48-
throw "Unsupported system: ${system}";
49-
in
55+
cat > $local_config_dir/languages.ncl <<EOF
5056
{
51-
name = "topiary-nushell";
52-
runtimeInputs = [
53-
nushell
54-
topiary
55-
];
56-
runtimeEnv = {
57-
TOPIARY_CONFIG_FILE = writeText "languages.ncl" ''
58-
{
59-
languages = {
60-
nu = {
61-
extensions = ["nu"],
62-
grammar.source.path = "${libtree-sitter-nu}/lib/libtree-sitter-nu${extension}",
63-
},
64-
},
65-
}
66-
'';
67-
TOPIARY_LANGUAGE_DIR = ./languages;
68-
};
69-
text = ''
70-
${lib.getExe topiary} "$@"
71-
'';
57+
languages = {
58+
nu = {
59+
extensions = ["nu"],
60+
grammar.source.path = "${libtree-sitter-nu}/lib/libtree-sitter-nu${extension}",
61+
},
62+
},
7263
}
73-
))
74-
./.
75-
];
76-
meta = with lib; {
77-
description = "topiary formatter for nushell";
78-
homepage = "https://github.com/blindFS/topiary-nushell";
79-
license = licenses.mit;
80-
mainProgram = "topiary-nushell";
81-
};
82-
}
64+
EOF
65+
'';
66+
in
67+
{
68+
name = "topiary-nushell";
69+
runtimeInputs = [
70+
nushell
71+
topiary
72+
];
73+
runtimeEnv = {
74+
TOPIARY_CONFIG_FILE = "${topiaryConfigDir}/languages.ncl";
75+
TOPIARY_LANGUAGE_DIR = "${topiaryConfigDir}/languages";
76+
};
77+
text = ''
78+
${lib.getExe topiary} "$@"
79+
'';
80+
}
81+
)

0 commit comments

Comments
 (0)