pkgs/topiary-nu: rewrite, simplify

Changed files
+40 -102
modules
-34
flake.lock
··· 552 552 "sops-nix": "sops-nix", 553 553 "ssh-keys": "ssh-keys", 554 554 "starship-jj": "starship-jj", 555 - "topiary-nushell": "topiary-nushell", 556 - "tree-sitter-nu": "tree-sitter-nu", 557 555 "zjstatus": "zjstatus" 558 556 } 559 557 }, ··· 732 730 "original": { 733 731 "owner": "nix-systems", 734 732 "repo": "default", 735 - "type": "github" 736 - } 737 - }, 738 - "topiary-nushell": { 739 - "flake": false, 740 - "locked": { 741 - "lastModified": 1764637932, 742 - "narHash": "sha256-2DOqs/zIDIS/Fdy36txfncwpetrXxXY6RcQ0v+09cIc=", 743 - "owner": "blindFS", 744 - "repo": "topiary-nushell", 745 - "rev": "71460ddb383a83286437ea951f946131ccca7e3f", 746 - "type": "github" 747 - }, 748 - "original": { 749 - "owner": "blindFS", 750 - "repo": "topiary-nushell", 751 - "type": "github" 752 - } 753 - }, 754 - "tree-sitter-nu": { 755 - "flake": false, 756 - "locked": { 757 - "lastModified": 1765660476, 758 - "narHash": "sha256-h02kb3VxSK/fxQENtj2yaRmAQ5I8rt5s5R8VrWOQWeo=", 759 - "owner": "nushell", 760 - "repo": "tree-sitter-nu", 761 - "rev": "4c149627cc592560f77ead1c384e27ec85926407", 762 - "type": "github" 763 - }, 764 - "original": { 765 - "owner": "nushell", 766 - "repo": "tree-sitter-nu", 767 733 "type": "github" 768 734 } 769 735 },
-8
flake.nix
··· 49 49 url = "github:karitham/knixpkgs"; 50 50 inputs.nixpkgs.follows = "nixpkgs"; 51 51 }; 52 - tree-sitter-nu = { 53 - url = "github:nushell/tree-sitter-nu"; 54 - flake = false; 55 - }; 56 - topiary-nushell = { 57 - url = "github:blindFS/topiary-nushell"; 58 - flake = false; 59 - }; 60 52 sops-nix = { 61 53 url = "github:Mic92/sops-nix"; 62 54 inputs.nixpkgs.follows = "nixpkgs";
+1 -1
modules/default.nix
··· 20 20 packages = { 21 21 pokego = pkgs.callPackage ./pkgs/pokego.nix { }; 22 22 http-nu = pkgs.callPackage ./pkgs/http-nu.nix { }; 23 - topiary-nu = pkgs.callPackage ./pkgs/topiary-nu.nix { inherit (inputs) tree-sitter-nu topiary-nushell; }; 23 + topiary-nu = pkgs.callPackage ./pkgs/topiary-nu.nix { }; 24 24 atproto-lastfm-importer = pkgs.callPackage ./pkgs/atproto-lastfm-importer.nix { }; 25 25 multi-scrobbler = pkgs.callPackage ./pkgs/multi-scrobbler.nix { }; 26 26
+39 -59
modules/pkgs/topiary-nu.nix
··· 1 1 { 2 2 lib, 3 - stdenv, 4 - tree-sitter, 3 + writeShellApplication, 5 4 topiary, 6 - makeWrapper, 7 - runCommand, 8 - nodejs, 9 - tree-sitter-nu, 10 - topiary-nushell, 5 + nushell, 6 + tree-sitter-grammars, 7 + writeText, 8 + linkFarm, 9 + pkgs, # otherwise lint issue because `fetchurl` is a builtin 11 10 }: 12 11 let 13 - treeSitterNu = stdenv.mkDerivation { 14 - name = "tree-sitter-nu"; 15 - src = tree-sitter-nu; 16 - buildInputs = [ 17 - tree-sitter 18 - nodejs 19 - ]; 20 - buildPhase = '' 21 - tree-sitter generate 22 - gcc -o parser.so -Isrc src/parser.c src/scanner.c -shared -fPIC -O2 23 - ''; 24 - installPhase = '' 25 - mkdir -p $out 26 - cp parser.so $out/parser 27 - ''; 28 - }; 29 - 30 - configDir = stdenv.mkDerivation { 31 - name = "topiary-nu-config"; 32 - src = topiary-nushell; 33 - 34 - buildPhase = '' 35 - mkdir -p $out 36 - cat <<EOF > $out/languages.ncl 37 - { 38 - languages = { 39 - nu = { 40 - extensions = ["nu"], 41 - grammar.source.path = "${treeSitterNu}/parser" 42 - }, 43 - }, 44 - } 45 - EOF 46 - ''; 47 - 48 - installPhase = '' 49 - cp -r $src/languages $out 50 - ''; 12 + langDir = linkFarm "topiary-nu-languages" [ 13 + { 14 + name = "nu.scm"; 15 + path = pkgs.fetchurl { 16 + url = "https://raw.githubusercontent.com/blindFS/topiary-nushell/main/languages/nu.scm"; 17 + hash = "sha256-2o7oIFkxuy8u8HNkiEzNnoKekmwaxClCWQnQg3rgVeU="; 18 + }; 19 + } 20 + ]; 21 + configFile = writeText "languages.json" ( 22 + builtins.toJSON { 23 + languages = { 24 + nu = { 25 + extensions = [ "nu" ]; 26 + grammar.source.path = "${tree-sitter-grammars.tree-sitter-nu}/parser"; 27 + }; 28 + }; 29 + } 30 + ); 31 + in 32 + writeShellApplication { 33 + name = "topiary-nu"; 34 + runtimeInputs = [ 35 + nushell 36 + topiary 37 + ]; 38 + runtimeEnv = { 39 + TOPIARY_CONFIG_FILE = configFile; 40 + TOPIARY_LANGUAGE_DIR = langDir; 51 41 }; 52 - in 53 - runCommand "topiary-nu" 54 - { 55 - buildInputs = [ makeWrapper ]; 56 - meta = { 57 - mainProgram = "topiary-nu"; 58 - }; 59 - } 60 - '' 61 - mkdir -p $out/bin 62 - makeWrapper ${lib.getExe topiary} $out/bin/topiary-nu \ 63 - --set TOPIARY_LANGUAGE_DIR "${configDir}/languages" \ 64 - --set TOPIARY_CONFIG_FILE "${configDir}/languages.ncl" 65 - '' 42 + text = '' 43 + ${lib.getExe topiary} "$@" 44 + ''; 45 + }