diff --git a/contrib/nix/dev/flake.nix b/contrib/nix/dev/flake.nix index 5225669d0..6fb1f06f9 100644 --- a/contrib/nix/dev/flake.nix +++ b/contrib/nix/dev/flake.nix @@ -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 ]; diff --git a/flake.lock b/flake.lock index 32f10fd67..cc836515f 100644 --- a/flake.lock +++ b/flake.lock @@ -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", diff --git a/flake.nix b/flake.nix index 3ab924049..fd7486744 100644 --- a/flake.nix +++ b/flake.nix @@ -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