feat: add rust and yarn to nix devShell (#1953)

by default, we assume people would like develop the language server and
editor tools. The building of tinymist-cli is moved to the neovim shell.
This commit is contained in:
Myriad-Dreamin 2025-07-31 22:22:32 +08:00 committed by GitHub
parent 3aa9c9def0
commit cf82fc78c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 83 additions and 5 deletions

View file

@ -2,13 +2,24 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-manifest = {
url = "https://static.rust-lang.org/dist/channel-rust-1.85.1.toml";
flake = false;
};
};
outputs = inputs @ { self, flake-parts, nixpkgs, }:
outputs = inputs @ { self, flake-parts, nixpkgs, fenix, rust-manifest, }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = ["x86_64-linux"];
perSystem = {config, lib, pkgs, ...}:
let tinymist = pkgs.rustPlatform.buildRustPackage (finalAttrs: {
systems = [ "x86_64-linux" ];
perSystem = {config, lib, pkgs, system, ...}:
let
rust-toolchain = (fenix.packages.${system}.fromManifestFile rust-manifest).defaultToolchain;
tinymist = pkgs.rustPlatform.buildRustPackage (finalAttrs: {
pname = "tinymist";
# Please update the corresponding vscode extension when updating
# this derivation.
@ -82,6 +93,18 @@
in {
# export the project devshell as the default devshell
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
rust-analyzer
nodejs_24
(yarn.override { nodejs = nodejs_24; })
];
shellHook = ''
echo "Docs: docs/tinymist/nix.typ."
'';
};
# Developing neovim integration requires a fresh tinymist binary
devShells.neovim = pkgs.mkShell {
buildInputs = [
tinymist
];

55
flake.lock generated
View file

@ -1,5 +1,27 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"tinymist-dev",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1753944209,
"narHash": "sha256-dcGdqxhRRGoA/S38BsWOrwIiLYEBOqXKauHdFwKR310=",
"owner": "nix-community",
"repo": "fenix",
"rev": "5ef8607d6e8a08cfb3946aaacaa0494792adf4ae",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
@ -273,6 +295,35 @@
"tinymist-unstable": "tinymist-unstable"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1753838657,
"narHash": "sha256-4FA7NTmrAqW5yt4A3hhzgDmAFD0LbGRMGKhb1LBSItI=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "8611b714597c89b092f3d4874f14acd3f72f44fd",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"rust-manifest": {
"flake": false,
"locked": {
"narHash": "sha256-hqDb78PazBKoHw8IJqOfiiR2kBI1VTzo+HiPSswf4zk=",
"type": "file",
"url": "https://static.rust-lang.org/dist/channel-rust-1.85.1.toml"
},
"original": {
"type": "file",
"url": "https://static.rust-lang.org/dist/channel-rust-1.85.1.toml"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
@ -305,8 +356,10 @@
},
"tinymist-dev": {
"inputs": {
"fenix": "fenix",
"flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"rust-manifest": "rust-manifest"
},
"locked": {
"path": "contrib/nix/dev",

View file

@ -20,6 +20,8 @@
devShells = {
# nix develop
default = tinymist-dev.devShells.${system}.default;
# nix develop .#neovim
neovim = tinymist-dev.devShells.${system}.neovim;
# nix develop .#unstable
unstable = tinymist-unstable.devShells.${system}.default;
# nix develop .#nixvim