{"id":47738453,"url":"https://github.com/ubugeeei/tnix","last_synced_at":"2026-04-07T03:00:52.875Z","repository":{"id":348253420,"uuid":"1197020330","full_name":"ubugeeei/tnix","owner":"ubugeeei","description":"[WIP] tnix (typed-nix) is gradual type system for nix","archived":false,"fork":false,"pushed_at":"2026-04-02T12:03:42.000Z","size":90863,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-06T02:03:03.466Z","etag":null,"topics":["checker","functional-programming","gradual-typing","haskell","nix","types"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ubugeeei.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"docs/roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-31T08:57:18.000Z","updated_at":"2026-04-02T12:41:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ubugeeei/tnix","commit_stats":null,"previous_names":["ubugeeei/tnix"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ubugeeei/tnix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubugeeei%2Ftnix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubugeeei%2Ftnix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubugeeei%2Ftnix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubugeeei%2Ftnix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ubugeeei","download_url":"https://codeload.github.com/ubugeeei/tnix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubugeeei%2Ftnix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31498070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T17:22:55.647Z","status":"online","status_checked_at":"2026-04-07T02:00:07.164Z","response_time":105,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checker","functional-programming","gradual-typing","haskell","nix","types"],"created_at":"2026-04-02T23:09:58.673Z","updated_at":"2026-04-07T03:00:52.853Z","avatar_url":"https://github.com/ubugeeei.png","language":"Haskell","readme":"# tnix\n\n`tnix` is a gradual type system and tooling stack for Nix. It compiles `.tnix` to `.nix`, provides static checking, and emits `.d.tnix` declaration files. It has no runtime and is intentionally limited to complementing existing Nix semantics rather than replacing them.\n\n## Goals\n\n- Add types to `.nix` without breaking its syntax or culture\n- Allow ambient declarations for existing `.nix` files\n- Adopt the parts of the TypeScript strategy that worked\n  - incremental adoption\n  - semantic preservation\n  - strong editor tooling\n- Be expressive enough for type-level programming\n  - parametric polymorphism\n  - higher-kinded types\n  - conditional types\n  - `infer`-style type decomposition\n- Use structural subtyping and `dynamic`, `unknown`, and `any` as the core gradual typing tools\n\n## File Kinds\n\n- `.tnix`\n  - source files with type annotations\n  - compiled to `.nix`\n- `.d.tnix`\n  - declaration-only ambient files\n  - used to type existing `.nix` modules and external code\n- `.nix`\n  - runtime artifact\n  - `tnix` does not change its behavior\n\n## Example\n\n```tnix\ntype Option a = { _tag :: \"some\"; value :: a; } | { _tag :: \"none\"; };\n\ndeclare \"./legacy/default.nix\" {\n  mkPkg :: { name :: String; version :: String; } -\u003e Derivation;\n};\n\nlet\n  map :: forall f a b. Functor f =\u003e (a -\u003e b) -\u003e f a -\u003e f b;\n  map = f: xs: builtins.map f xs;\nin\n  import ./legacy/default.nix {\n    name = \"hello\";\n    version = \"1.0.0\";\n  }\n```\n\nAfter compilation, type information is erased and only ordinary Nix code remains.\n\n## Design Docs\n\n- [Getting Started](./docs/getting-started.md)\n- [Language Reference](./docs/language-reference.md)\n- [Language Design](./docs/language-design.md)\n- [Type System](./docs/type-system.md)\n- [Architecture](./docs/architecture.md)\n- [Roadmap](./docs/roadmap.md)\n\n## Current Status\n\n`tnix` is now in its first integrated toolchain release.\n\n- Haskell monorepo for parser, checker, compiler, emitter, CLI, and LSP\n- Nix-based development environment\n- `pnpm`-managed editor tooling\n- VS Code, Zed, and Neovim integrations\n- gradual typing with ambient declarations, HKT support, indexed `Vec` / `Matrix` / `Tensor`, and heterogeneous `Tuple`\n- numeric singleton/primitive support via `Float`, `Number`, `Nat`, `Range`, and `Unit`\n- explicit `expr as Type` casts for widening, narrowing, and gradual-boundary assertions\n- TypeScript-style checker directives via `# @tnix-ignore` and `# @tnix-expected`\n- project bootstrapping via `tnix init`, `tnix scaffold`, and `tnix.config.tnix`\n- shipped declaration files for `builtins`, `flake.nix`, and `tnix.config.tnix`\n- bundled declaration packs under `registry/` for workspace files and popular Nix ecosystem surfaces\n\n## Installation\n\nInstall the CLI and language server from the published flake:\n\n```bash\nnix profile install github:ubugeeei/tnix#tnix\nnix profile install github:ubugeeei/tnix#tnix-lsp\n```\n\nOr download the prebuilt archives attached to each GitHub release and place\n`tnix` / `tnix-lsp` somewhere on your `PATH`.\n\nQuick verification:\n\n```bash\ntnix --version\ntnix-lsp --version\ntnix check ./examples/main.tnix\ntnix check-project ./examples\n```\n\nFor local development, enter the reproducible shell first:\n\n```bash\nnix develop\nnix flake check --accept-flake-config\nvp run check\nvp cli\nvp ide\n```\n\n`nix flake check` now exercises the published flake outputs, version metadata,\nsmoke-tests the built `tnix` / `tnix-lsp` binaries, runs the Haskell package\ntest suites, and validates the dogfood/example corpus with the packaged CLI.\n`vp run check` remains the full workspace verification suite, including editor\nintegrations.\n`vp cli` installs the local `tnix` / `tnix-lsp` toolchain into your active Nix\nprofile. `vp ide` reuses that toolchain install, packages the VS Code\nextension, and installs the local Zed extension when its support directory is\navailable.\n\n## Bundled Registry Packs\n\nThe repository includes reusable `.d.tnix` packs under `registry/` so projects\ncan vendor common declarations instead of rewriting ambient files from scratch.\n\nWorkspace-oriented packs live under `registry/workspace/`:\n\n- `registry/workspace/builtins.d.tnix`\n- `registry/workspace/flake.d.tnix`\n- `registry/workspace/tnix.config.d.tnix`\n\nEcosystem alias packs live under `registry/ecosystem/`:\n\n- `registry/ecosystem/nixpkgs-lib.d.tnix`\n- `registry/ecosystem/nixpkgs-pkgs.d.tnix`\n- `registry/ecosystem/flake-ecosystem.d.tnix`\n- `registry/ecosystem/community-flakes.d.tnix`\n\nTypical usage is to copy the pack you want into your declaration directory and\nreuse its aliases from local `declare` blocks:\n\n```tnix\ndeclare \"./flake-utils.nix\" { default :: NixFlakeUtilsFlake; };\ndeclare \"./devenv.nix\" { default :: DevenvFlake; };\ndeclare \"./treefmt-nix.nix\" { default :: TreefmtNixFlake; };\n```\n\nProjects can also point `tnix.config.tnix` at external pack files or\ndirectories directly:\n\n```tnix\n{\n  declarationPacks = [\n    ../vendor/tnix/registry/ecosystem\n    ../vendor/tnix/registry/workspace\n  ];\n}\n```\n\nWhen a configured pack comes from `registry/workspace/`, tnix rebases its\nambient `declare` targets to your project root so upstream workspace packs can\nbe used without copying them into the repo first.\n\nThe workspace packs assume they live under `registry/workspace/` so their\nrelative `declare` targets resolve back to the project root.\n\n## Example Catalog\n\nThe repository ships a larger sample set under [`examples/`](./examples/README.md).\nIt includes basic language features, gradual typing examples, indexed container\nsamples, and legacy interop fixtures that can be checked with one command:\n\n```bash\ntnix check-project ./examples\n```\n\nSee [CHANGELOG.md](./CHANGELOG.md) for the release history.\n\n## Distribution\n\nThe primary distribution channel is GitHub Releases. Tagged releases publish\nprebuilt `tnix` and `tnix-lsp` archives for supported platforms together with\nchecksums, plus a packaged VS Code `.vsix` extension. When marketplace tokens\nare configured, the same tag also publishes the extension to VS Code\nMarketplace and Open VSX.\n\nThe flake also exports installable packages and runnable apps:\n\n```bash\nnix build github:ubugeeei/tnix#tnix\nnix run github:ubugeeei/tnix#tnix -- check ./main.tnix\nnix run github:ubugeeei/tnix#tnix-lsp\nnix flake check github:ubugeeei/tnix --accept-flake-config\n```\n\nSee [RELEASING.md](./RELEASING.md) for the release flow.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubugeeei%2Ftnix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fubugeeei%2Ftnix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubugeeei%2Ftnix/lists"}