From ebab7bd8a8421aa6ae71071d061e498cd58d3dbb Mon Sep 17 00:00:00 2001 From: blindfs Date: Wed, 26 Nov 2025 12:28:57 +0800 Subject: [PATCH] revert(nix): back to the runCommand solution --- package.nix | 133 ++++++++++++++++++++++++++-------------------------- 1 file changed, 66 insertions(+), 67 deletions(-) diff --git a/package.nix b/package.nix index 9fa9cfa..a88719e 100644 --- a/package.nix +++ b/package.nix @@ -1,82 +1,81 @@ { stdenv, lib, + runCommand, writeShellApplication, tree-sitter-nu ? fetchGit "https://github.com/nushell/tree-sitter-nu", topiary, nushell, - writeText, callPackage, - symlinkJoin, }: -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; +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)" + ]; - src = tree-sitter-nu; + 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}"; - makeFlags = [ - # The PREFIX var isn't picking up from stdenv. - "PREFIX=$(out)" - ]; + # Create a directory holding ALL runtime config files + # This makes a single path for GC root. + topiaryConfigDir = runCommand "topiary-nushell-config" { } '' + local_config_dir="$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; - }; - }) - ) { }; + # 1. Copy the nu.scm language directory + mkdir -p $local_config_dir/languages + cp ${./languages/nu.scm} $local_config_dir/languages/nu.scm - extension = - with stdenv; - if isLinux then - ".so" - else if isDarwin then - ".dylib" - else - throw "Unsupported system: ${system}"; - in + cat > $local_config_dir/languages.ncl <