diff --git a/package.nix b/package.nix index b1ca258..9fa9cfa 100644 --- a/package.nix +++ b/package.nix @@ -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} "$@" - ''; -}) +}