nix all the things

better packaging for topiary-nu

karitham.dev ab6bc18a af70d0a7

verified
+86 -103
+1 -93
flake.lock
··· 196 196 "type": "github" 197 197 } 198 198 }, 199 - "flake-utils_4": { 200 - "inputs": { 201 - "systems": "systems_5" 202 - }, 203 - "locked": { 204 - "lastModified": 1731533236, 205 - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", 206 - "owner": "numtide", 207 - "repo": "flake-utils", 208 - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", 209 - "type": "github" 210 - }, 211 - "original": { 212 - "owner": "numtide", 213 - "repo": "flake-utils", 214 - "type": "github" 215 - } 216 - }, 217 199 "ghostty": { 218 200 "inputs": { 219 201 "flake-compat": "flake-compat", ··· 614 596 "stable": "stable", 615 597 "starship-jj": "starship-jj", 616 598 "systems": "systems_3", 617 - "topiary-nu": "topiary-nu", 618 599 "zjstatus": "zjstatus" 619 600 } 620 601 }, ··· 807 788 "type": "github" 808 789 } 809 790 }, 810 - "systems_5": { 811 - "locked": { 812 - "lastModified": 1681028828, 813 - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 814 - "owner": "nix-systems", 815 - "repo": "default", 816 - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 817 - "type": "github" 818 - }, 819 - "original": { 820 - "owner": "nix-systems", 821 - "repo": "default", 822 - "type": "github" 823 - } 824 - }, 825 - "topiary-nu": { 826 - "inputs": { 827 - "flake-utils": "flake-utils_3", 828 - "nixpkgs": [ 829 - "nixpkgs" 830 - ], 831 - "topiary-nushell": "topiary-nushell", 832 - "tree-sitter-nu": "tree-sitter-nu" 833 - }, 834 - "locked": { 835 - "dir": "topiary-nu", 836 - "lastModified": 1750272458, 837 - "narHash": "sha256-LqwCgzdBVh0Yz4fm/hJXDDGK1jPVkXhkxgoklPz5HLY=", 838 - "owner": "ck3mp3r", 839 - "repo": "flakes", 840 - "rev": "cd30d7afc9457c650ef719f9cf11a11dedefaf0d", 841 - "type": "github" 842 - }, 843 - "original": { 844 - "dir": "topiary-nu", 845 - "owner": "ck3mp3r", 846 - "ref": "cd30d7afc9457c650ef719f9cf11a11dedefaf0d", 847 - "repo": "flakes", 848 - "type": "github" 849 - } 850 - }, 851 - "topiary-nushell": { 852 - "flake": false, 853 - "locked": { 854 - "lastModified": 1748947526, 855 - "narHash": "sha256-mLcJR6tZclbRKbnPObqrO57AM1vjWfG13VpJCB7m5Vk=", 856 - "owner": "blindFS", 857 - "repo": "topiary-nushell", 858 - "rev": "9c770f22e54609e17cacfaf02e4943936b3f4119", 859 - "type": "github" 860 - }, 861 - "original": { 862 - "owner": "blindFS", 863 - "repo": "topiary-nushell", 864 - "type": "github" 865 - } 866 - }, 867 - "tree-sitter-nu": { 868 - "flake": false, 869 - "locked": { 870 - "lastModified": 1750158656, 871 - "narHash": "sha256-v4Nr+dN7VT4AMuejvDWJZK0+wH9/Q3h29vvAKYABaXE=", 872 - "owner": "nushell", 873 - "repo": "tree-sitter-nu", 874 - "rev": "7983592fe54750b750f2ee9dc8e89449257855d4", 875 - "type": "github" 876 - }, 877 - "original": { 878 - "owner": "nushell", 879 - "repo": "tree-sitter-nu", 880 - "type": "github" 881 - } 882 - }, 883 791 "xwayland-satellite-stable": { 884 792 "flake": false, 885 793 "locked": { ··· 945 853 "zjstatus": { 946 854 "inputs": { 947 855 "crane": "crane_2", 948 - "flake-utils": "flake-utils_4", 856 + "flake-utils": "flake-utils_3", 949 857 "nixpkgs": "nixpkgs_9", 950 858 "rust-overlay": "rust-overlay_3" 951 859 },
+2 -4
flake.nix
··· 2 2 inputs = { 3 3 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 4 4 stable.url = "github:NixOS/nixpkgs/nixos-25.05"; 5 - topiary-nu = { 6 - url = "github:ck3mp3r/flakes?dir=topiary-nu&ref=cd30d7afc9457c650ef719f9cf11a11dedefaf0d"; 7 - inputs.nixpkgs.follows = "nixpkgs"; 8 - }; 5 + 9 6 home-manager = { 10 7 url = "github:nix-community/home-manager"; 11 8 inputs.nixpkgs.follows = "nixpkgs"; ··· 121 118 packages = forAllSystems (pkgs: { 122 119 pokego = pkgs.callPackage ./pkgs/pokego.nix {}; 123 120 http-nu = pkgs.callPackage ./pkgs/http-nu.nix {}; 121 + topiary-nu = pkgs.callPackage ./pkgs/topiary-nu.nix {}; 124 122 }); 125 123 126 124 overlays.default = import ./overlays;
+1 -6
modules/home/helix.nix
··· 473 473 name = "nu"; 474 474 language-servers = ["nu-lsp"]; 475 475 formatter = { 476 - command = "${pkgs.writers.writeBashBin "topiary" '' 477 - export TOPIARY_LANGUAGE_DIR="${inputs'.topiary-nu.packages.default}/languages"; 478 - export TOPIARY_CONFIG_FILE="${inputs'.topiary-nu.packages.default}/languages.ncl"; 479 - 480 - ${lib.getExe pkgs.topiary} "$@" 481 - ''}/bin/topiary"; 476 + command = "${lib.getExe pkgs.topiary-nu}"; 482 477 args = [ 483 478 "format" 484 479 "--language"
+1
overlays/default.nix
··· 1 1 _: prev: { 2 2 pokego = prev.callPackage ../pkgs/pokego.nix {}; 3 + topiary-nu = prev.callPackage ../pkgs/topiary-nu.nix {}; 3 4 golangci-lint-langserver = prev.golangci-lint-langserver.overrideAttrs (_: { 4 5 patches = prev.fetchurl { 5 6 url = "https://github.com/karitham/golangci-lint-langserver/commit/31e6806187d431a8865261b5441ef5a65b589ae5.patch";
+81
pkgs/topiary-nu.nix
··· 1 + { 2 + lib, 3 + stdenv, 4 + fetchFromGitHub, 5 + tree-sitter, 6 + nodejs, 7 + topiary, 8 + makeWrapper, 9 + runCommand, 10 + }: 11 + 12 + let 13 + treeSitterNu = stdenv.mkDerivation { 14 + name = "tree-sitter-nu"; 15 + src = fetchFromGitHub { 16 + owner = "nushell"; 17 + repo = "tree-sitter-nu"; 18 + rev = "18b7f951e0c511f854685dfcc9f6a34981101dd6"; 19 + hash = "sha256-OSazwPrUD7kWz/oVeStnnXEJiDDmI7itiDPmg062Kl8="; 20 + }; 21 + 22 + buildInputs = [ 23 + tree-sitter 24 + nodejs 25 + ]; 26 + 27 + buildPhase = '' 28 + tree-sitter generate --abi=14 29 + ''; 30 + 31 + installPhase = '' 32 + mkdir -p $out/lib 33 + if [[ -e src/scanner.c ]]; then 34 + $CC -fPIC -c src/scanner.c -o scanner.o -Isrc -O2 35 + fi 36 + $CC -fPIC -c src/parser.c -o parser.o -Isrc -O2 37 + $CC -shared -o $out/lib/tree_sitter_nu.so *.o 38 + ''; 39 + }; 40 + 41 + topiaryNushell = fetchFromGitHub { 42 + owner = "blindFS"; 43 + repo = "topiary-nushell"; 44 + rev = "fd78be393af5a64e56b493f52e4a9ad1482c07f4"; 45 + hash = "sha256-5gmLFnbHbQHnE+s1uAhFkUrhEvUWB/hg3/8HSYC9L14="; 46 + }; 47 + 48 + configDir = stdenv.mkDerivation { 49 + name = "topiary-nu-config"; 50 + src = topiaryNushell; 51 + 52 + buildPhase = '' 53 + mkdir -p $out 54 + cat <<EOF > $out/languages.ncl 55 + { 56 + languages = { 57 + nu = { 58 + extensions = ["nu"], 59 + grammar.source.path = "${treeSitterNu}/lib/tree_sitter_nu.so" 60 + }, 61 + }, 62 + } 63 + EOF 64 + ''; 65 + 66 + installPhase = '' 67 + cp -r $src/languages $out 68 + ''; 69 + }; 70 + in 71 + runCommand "topiary-nu" { 72 + buildInputs = [ makeWrapper ]; 73 + meta = { 74 + mainProgram = "topiary-nu"; 75 + }; 76 + } '' 77 + mkdir -p $out/bin 78 + makeWrapper ${lib.getExe topiary} $out/bin/topiary-nu \ 79 + --set TOPIARY_LANGUAGE_DIR "${configDir}/languages" \ 80 + --set TOPIARY_CONFIG_FILE "${configDir}/languages.ncl" 81 + ''