feat: add flake.nix (#1843)
Some checks are pending
tinymist::ci / E2E Tests (darwin-arm64 on macos-latest) (push) Blocked by required conditions
tinymist::ci / build-vscode-others (push) Blocked by required conditions
tinymist::ci / publish-vscode (push) Blocked by required conditions
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / E2E Tests (linux-x64 on ubuntu-22.04) (push) Blocked by required conditions
tinymist::ci / E2E Tests (linux-x64 on ubuntu-latest) (push) Blocked by required conditions
tinymist::ci / E2E Tests (win32-x64 on windows-2019) (push) Blocked by required conditions
tinymist::ci / E2E Tests (win32-x64 on windows-latest) (push) Blocked by required conditions
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / build-binary (push) Blocked by required conditions
tinymist::ci / build-vsc-assets (push) Blocked by required conditions
tinymist::ci / build-vscode (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run

* dev: add flake.nix

* feat: init dev, unstable, and nixvim config

* docs: update description

* dev: split neovim with nixvim

* feat: init tinymist server

* x

* g

* g
This commit is contained in:
Myriad-Dreamin 2025-06-24 14:24:25 +08:00 committed by GitHub
parent d76cd90ef5
commit 878d8aaf08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 671 additions and 0 deletions

94
contrib/nix/dev/flake.nix Normal file
View file

@ -0,0 +1,94 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs @ { self, flake-parts, nixpkgs, }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = ["x86_64-linux"];
perSystem = {config, lib, pkgs, ...}:
let tinymist = pkgs.rustPlatform.buildRustPackage (finalAttrs: {
pname = "tinymist";
# Please update the corresponding vscode extension when updating
# this derivation.
version = "0.13.14";
src = pkgs.lib.cleanSource ../../..;
useFetchCargoVendor = true;
cargoHash = "sha256-aD50+awwVds9zwW5hM0Hgxv8NGV7J63BOSpU9907O+k=";
nativeBuildInputs = [
pkgs.installShellFiles
pkgs.pkg-config
];
checkFlags = [
"--skip=e2e"
# Require internet access
"--skip=docs::package::tests::cetz"
"--skip=docs::package::tests::fletcher"
"--skip=docs::package::tests::tidy"
"--skip=docs::package::tests::touying"
# Tests are flaky for unclear reasons since the 0.12.3 release
# Reported upstream: https://github.com/Myriad-Dreamin/tinymist/issues/868
"--skip=analysis::expr_tests::scope"
"--skip=analysis::post_type_check_tests::test"
"--skip=analysis::type_check_tests::test"
"--skip=completion::tests::test_pkgs"
"--skip=folding_range::tests::test"
"--skip=goto_definition::tests::test"
"--skip=hover::tests::test"
"--skip=inlay_hint::tests::smart"
"--skip=prepare_rename::tests::prepare"
"--skip=references::tests::test"
"--skip=rename::tests::test"
"--skip=semantic_tokens_full::tests::test"
];
postInstall = lib.optionalString (pkgs.stdenv.hostPlatform.emulatorAvailable pkgs.buildPackages) (
let
emulator = pkgs.stdenv.hostPlatform.emulator pkgs.buildPackages;
in
''
installShellCompletion --cmd tinymist \
--bash <(${emulator} $out/bin/tinymist completion bash) \
--fish <(${emulator} $out/bin/tinymist completion fish) \
--zsh <(${emulator} $out/bin/tinymist completion zsh)
''
);
nativeInstallCheckInputs = [
pkgs.versionCheckHook
];
versionCheckProgramArg = "-V";
doInstallCheck = true;
meta = {
description = "Tinymist is an integrated language service for Typst";
homepage = "https://github.com/Myriad-Dreamin/tinymist";
changelog = "https://github.com/Myriad-Dreamin/tinymist/blob/v${finalAttrs.version}/editors/vscode/CHANGELOG.md";
license = lib.licenses.asl20;
mainProgram = "tinymist";
maintainers = with lib.maintainers; [
GaetanLepage
lampros
];
};
});
in {
# export the project devshell as the default devshell
devShells.default = pkgs.mkShell {
buildInputs = [
tinymist
];
shellHook = ''
echo "Docs: docs/tinymist/nix.typ."
'';
};
};
};
}

View file

@ -0,0 +1,23 @@
# https://wiki.nixos.org/wiki/Flakes
{
description = "A flake configuration to use tinymist CLI from unstable nixpkgs";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in {
devShells.x86_64-linux.default = pkgs.mkShell {
buildInputs = with pkgs; [
tinymist
];
shellHook = ''
echo "Got tinymist from nixpkgs unstable channel"
'';
};
};
}

27
crates.nix Normal file
View file

@ -0,0 +1,27 @@
{...}: {
perSystem = {pkgs, ...}: {
# declare projects
# TODO: change this to your workspace's path
nci.projects."my-project" = {
path = ./.;
# export all crates (packages and devshell) in flake outputs
# alternatively you can access the outputs and export them yourself
export = true;
};
# configure crates
nci.crates = {
"tinymist" = {
drvConfig = {
# env.HELLO_WORLD = true;
};
# look at documentation for more options
};
# "my-other-workspace-crate" = {
# drvConfig = {
# mkDerivation.buildInputs = [pkgs.hello];
# };
# # look at documentation for more options
# };
};
};
}

28
docs/tinymist/nix.typ Normal file
View file

@ -0,0 +1,28 @@
= System Configuration
Add following content to the end of your `~/.config/nix/nix.conf` file to enable flakes and nix-command experimental-features:
```conf
experimental-features = nix-command flakes
```
To debug bundle size:
```
nix-shell -p nix-tree.out --run nix-tree
```
= Running devShell
Run with built binaries from source:
```
nix develop
```
Run with the binaries from the nixpkgs unstable:
```
nix develop .#unstable
```

5
editors/nixvim/README.md Normal file
View file

@ -0,0 +1,5 @@
# Tinymist Nixvim Support for Typst
```
nix develop
```

View file

@ -0,0 +1,6 @@
{
plugins = {
bufferline.enable = true;
web-devicons.enable = true;
};
}

View file

@ -0,0 +1,10 @@
# https://github.com/GaetanLepage/nix-config/blob/81a6c06fa6fc04a0436a55be344609418f4c4fd9/modules/home/core/dev/typst.nix#L22
{
# Import all your configuration modules here
imports = [
./bufferline.nix
./tinymist.nix
# ./typst-preview.nix
# ./typst-vim.nix
];
}

View file

@ -0,0 +1,8 @@
{
lsp.servers.tinymist = {
enable = true;
# uncomment this to use tinymist from mason.
settings.cmd = ["tinymist"];
settings.formatterMode = "typstyle";
};
}

View file

@ -0,0 +1,9 @@
{
typst-preview = {
enable = true;
settings = {
dependencies_bin.tinymist = "tinymist";
};
};
}

View file

@ -0,0 +1,10 @@
{
typst-vim = {
enable = true;
settings = {
auto_open_quickfix = false;
pdf_viewer = "zathura";
typst_syntax_highlight = false;
};
};
}

66
editors/nixvim/flake.nix Normal file
View file

@ -0,0 +1,66 @@
{
description = "A nixvim configuration to use tinymist from unstable nixpkgs";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
nixvim = {
url = "github:nix-community/nixvim";
# If you are not running an unstable channel of nixpkgs, select the corresponding branch of nixvim.
# url = "github:nix-community/nixvim/nixos-25.05";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs =
{ nixpkgs, nixvim, flake-parts, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
perSystem =
{ system, ... }:
let
pkgs = import nixpkgs { inherit system; };
nixvimLib = nixvim.lib.${system};
nixvim' = nixvim.legacyPackages.${system};
nixvimModule = {
inherit system; # or alternatively, set `pkgs`
module = import ./config; # import the module directly
# You can use `extraSpecialArgs` to pass additional arguments to your module files
extraSpecialArgs = {
# inherit (inputs) foo;
};
};
nvim = nixvim'.makeNixvimWithModule nixvimModule;
in
{
checks = {
# Run `nix flake check .` to verify that your config is not broken
default = nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule;
};
packages = {
# Lets you run `nix run .` to start nixvim
default = nvim;
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
typst
typstyle
tinymist
nvim
];
shellHook = ''
echo "Run \"nvim\" to enter the editor."
'';
};
};
};
}

354
flake.lock generated Normal file
View file

@ -0,0 +1,354 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1749398372,
"narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_2"
},
"locked": {
"lastModified": 1749398372,
"narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_3": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_3"
},
"locked": {
"lastModified": 1749398372,
"narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_4": {
"inputs": {
"nixpkgs-lib": [
"tinymist-nixvim",
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1749398372,
"narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"ixx": {
"inputs": {
"flake-utils": [
"tinymist-nixvim",
"nixvim",
"nuschtosSearch",
"flake-utils"
],
"nixpkgs": [
"tinymist-nixvim",
"nixvim",
"nuschtosSearch",
"nixpkgs"
]
},
"locked": {
"lastModified": 1748294338,
"narHash": "sha256-FVO01jdmUNArzBS7NmaktLdGA5qA3lUMJ4B7a05Iynw=",
"owner": "NuschtOS",
"repo": "ixx",
"rev": "cc5f390f7caf265461d4aab37e98d2292ebbdb85",
"type": "github"
},
"original": {
"owner": "NuschtOS",
"ref": "v0.0.8",
"repo": "ixx",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1750506804,
"narHash": "sha256-VLFNc4egNjovYVxDGyBYTrvVCgDYgENp5bVi9fPTDYc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "4206c4cb56751df534751b058295ea61357bbbaa",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1748740939,
"narHash": "sha256-rQaysilft1aVMwF14xIdGS3sj1yHlI6oKQNBRTF40cc=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "656a64127e9d791a334452c6b6606d17539476e2",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs-lib_2": {
"locked": {
"lastModified": 1748740939,
"narHash": "sha256-rQaysilft1aVMwF14xIdGS3sj1yHlI6oKQNBRTF40cc=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "656a64127e9d791a334452c6b6606d17539476e2",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs-lib_3": {
"locked": {
"lastModified": 1748740939,
"narHash": "sha256-rQaysilft1aVMwF14xIdGS3sj1yHlI6oKQNBRTF40cc=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "656a64127e9d791a334452c6b6606d17539476e2",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1750506804,
"narHash": "sha256-VLFNc4egNjovYVxDGyBYTrvVCgDYgENp5bVi9fPTDYc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "4206c4cb56751df534751b058295ea61357bbbaa",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1750506804,
"narHash": "sha256-VLFNc4egNjovYVxDGyBYTrvVCgDYgENp5bVi9fPTDYc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "4206c4cb56751df534751b058295ea61357bbbaa",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixvim": {
"inputs": {
"flake-parts": "flake-parts_4",
"nixpkgs": [
"tinymist-nixvim",
"nixpkgs"
],
"nuschtosSearch": "nuschtosSearch",
"systems": "systems_2"
},
"locked": {
"lastModified": 1750691276,
"narHash": "sha256-F507hXG4ORVpvuFeuoyDo/bmO/rR2PJRB7XhtDuBnBE=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "1f3e5741a927b5b0a983f08ab9d3bcf313bc141e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixvim",
"type": "github"
}
},
"nuschtosSearch": {
"inputs": {
"flake-utils": "flake-utils",
"ixx": "ixx",
"nixpkgs": [
"tinymist-nixvim",
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1749730855,
"narHash": "sha256-L3x2nSlFkXkM6tQPLJP3oCBMIsRifhIDPMQQdHO5xWo=",
"owner": "NuschtOS",
"repo": "search",
"rev": "8dfe5879dd009ff4742b668d9c699bc4b9761742",
"type": "github"
},
"original": {
"owner": "NuschtOS",
"repo": "search",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"tinymist-dev": "tinymist-dev",
"tinymist-nixvim": "tinymist-nixvim",
"tinymist-unstable": "tinymist-unstable"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"tinymist-dev": {
"inputs": {
"flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs"
},
"locked": {
"path": "././././././././contrib/nix/dev",
"type": "path"
},
"original": {
"path": "././././././././contrib/nix/dev",
"type": "path"
},
"parent": []
},
"tinymist-nixvim": {
"inputs": {
"flake-parts": "flake-parts_3",
"nixpkgs": "nixpkgs_2",
"nixvim": "nixvim"
},
"locked": {
"path": "editors/nixvim",
"type": "path"
},
"original": {
"path": "editors/nixvim",
"type": "path"
},
"parent": []
},
"tinymist-unstable": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"path": "contrib/nix/unstable",
"type": "path"
},
"original": {
"path": "contrib/nix/unstable",
"type": "path"
},
"parent": []
}
},
"root": "root",
"version": 7
}

30
flake.nix Normal file
View file

@ -0,0 +1,30 @@
# Docs: ./docs/tinymist/nix.typ
{
description = "Collecting nix configurations in tinymist repository.";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
tinymist-unstable.url = "path:contrib/nix/unstable";
tinymist-dev.url = "path:././././././././contrib/nix/dev";
tinymist-nixvim.url = "path:editors/nixvim";
};
outputs = inputs@{
flake-parts, tinymist-unstable, tinymist-dev, tinymist-nixvim, self, ... }: flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" ];
perSystem =
{ system, ... }:
{
# apps.default = tinymist-dev.apps.${system}.default;
devShells = {
# nix develop
default = tinymist-dev.devShells.${system}.default;
# nix develop .#unstable
unstable = tinymist-unstable.devShells.${system}.default;
# nix develop .#nixvim
nixvim = tinymist-nixvim.devShells.${system}.default;
};
};
};
}

View file

@ -34,6 +34,7 @@
"typlite": "target/debug/typlite",
"check-msrv": "node scripts/check-msrv.mjs",
"generate-ci": "dist generate",
"generate-nix": "nix run github:cargo2nix/cargo2nix --locked",
"project-build-script:ps1": "cargo run --bin tinymist -- generate-script -o ./scripts/project-build.ps1",
"draft-release": "node scripts/draft-release.mjs"
},