Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 66 additions & 43 deletions package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,76 @@
nushell,
writeText,
callPackage,
symlinkJoin,
}:
writeShellApplication (let
libtree-sitter-nu = callPackage ({
lib,
stdenv,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "tree-sitter-nu";
version = tree-sitter-nu.rev;
symlinkJoin {
name = "topiary-nushell";
paths = [
(writeShellApplication (
let
libtree-sitter-nu = callPackage (
{
lib,
stdenv,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "tree-sitter-nu";
version = tree-sitter-nu.rev;

src = tree-sitter-nu;
src = tree-sitter-nu;

makeFlags = [
# The PREFIX var isn't picking up from stdenv.
"PREFIX=$(out)"
];
makeFlags = [
# The PREFIX var isn't picking up from stdenv.
"PREFIX=$(out)"
];

meta = with lib; {
description = "A tree-sitter grammar for nu-lang, the language of nushell";
homepage = "https://github.com/nushell/tree-sitter-nu";
license = licenses.mit;
};
})) {};
in {
name = "topiary-nushell";
runtimeInputs = [nushell topiary];
runtimeEnv = let
extension = with stdenv;
if isLinux
then ".so"
else if isDarwin
then ".dylib"
else throw "Unsupported system: ${system}";
in {
TOPIARY_CONFIG_FILE = writeText "languages.ncl" ''
meta = with lib; {
description = "A tree-sitter grammar for nu-lang, the language of nushell";
homepage = "https://github.com/nushell/tree-sitter-nu";
license = licenses.mit;
};
})
) { };

extension =
with stdenv;
if isLinux then
".so"
else if isDarwin then
".dylib"
else
throw "Unsupported system: ${system}";
in
{
languages = {
nu = {
extensions = ["nu"],
grammar.source.path = "${libtree-sitter-nu}/lib/libtree-sitter-nu${extension}",
},
},
name = "topiary-nushell";
runtimeInputs = [
nushell
topiary
];
runtimeEnv = {
TOPIARY_CONFIG_FILE = writeText "languages.ncl" ''
{
languages = {
nu = {
extensions = ["nu"],
grammar.source.path = "${libtree-sitter-nu}/lib/libtree-sitter-nu${extension}",
},
},
}
'';
TOPIARY_LANGUAGE_DIR = ./languages;
};
text = ''
${lib.getExe topiary} "$@"
'';
}
'';
TOPIARY_LANGUAGE_DIR = ./languages;
))
./.
];
meta = with lib; {
description = "topiary formatter for nushell";
homepage = "https://github.com/blindFS/topiary-nushell";
license = licenses.mit;
mainProgram = "topiary-nushell";
};
text = ''
${lib.getExe topiary} "$@"
'';
})
}