Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = {
self,
nixpkgs,
...
}: let
systems = ["x86_64-linux" "aarch64-darwin"];
buildEachSystem = output: builtins.map output systems;
buildAllSystems = output: (
builtins.foldl' nixpkgs.lib.recursiveUpdate {} (buildEachSystem output)
);
in
buildAllSystems (system: let
pkgs = import nixpkgs {inherit system;};
in {
packages.${system} = {
topiary-nushell = pkgs.callPackage ./package.nix {
tree-sitter-nu = builtins.fetchGit {
url = "https://github.com/nushell/tree-sitter-nu";
rev = "47d4b4f5369c0cae866724758ae88ef07e10e4f1";
};
};
default = self.packages.${system}.topiary-nushell;
};
apps.${system} = {
topiary-nushell = {
type = "app";
program = "${pkgs.lib.getExe self.packages.${system}.topiary-nushell}";
meta = {
description = "Topiary with NuShell support";
};
};
default = self.apps.${system}.topiary-nushell;
};
});
}
59 changes: 59 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
stdenv,
lib,
writeShellApplication,
tree-sitter-nu ? fetchGit "https://github.com/nushell/tree-sitter-nu",
topiary,
nushell,
writeText,
callPackage,
}:
writeShellApplication (let
libtree-sitter-nu = callPackage ({
lib,
stdenv,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "tree-sitter-nu";
version = tree-sitter-nu.rev;

src = tree-sitter-nu;

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" ''
{
languages = {
nu = {
extensions = ["nu"],
grammar.source.path = "${libtree-sitter-nu}/lib/libtree-sitter-nu${extension}",
},
},
}
'';
TOPIARY_LANGUAGE_DIR = ./languages;
};
text = ''
${lib.getExe topiary} "$@"
'';
})