{"id":15822902,"url":"https://github.com/sambacha/nix-linguist","last_synced_at":"2025-07-02T07:32:35.127Z","repository":{"id":40490189,"uuid":"507568946","full_name":"sambacha/nix-linguist","owner":"sambacha","description":"Legacy GitHub Linguist Grammar for Nix","archived":false,"fork":false,"pushed_at":"2023-07-09T16:11:58.000Z","size":89,"stargazers_count":4,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-02T06:14:39.479Z","etag":null,"topics":["flakes","github","linguist","nix","nix-flakes","nix-language","nix-shell","nixos","syntax"],"latest_commit_sha":null,"homepage":"https://github.com/nix-community/tree-sitter-nix","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sambacha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-26T12:31:18.000Z","updated_at":"2023-07-09T16:12:20.000Z","dependencies_parsed_at":"2024-10-26T12:49:01.201Z","dependency_job_id":"fe711b47-d6e9-4a02-8248-23b630176acb","html_url":"https://github.com/sambacha/nix-linguist","commit_stats":{"total_commits":9,"total_committers":3,"mean_commits":3.0,"dds":0.2222222222222222,"last_synced_commit":"121b33169b266b6cb3d615dd580a6a8ddd17ab55"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sambacha/nix-linguist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fnix-linguist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fnix-linguist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fnix-linguist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fnix-linguist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sambacha","download_url":"https://codeload.github.com/sambacha/nix-linguist/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Fnix-linguist/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263093792,"owners_count":23412880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["flakes","github","linguist","nix","nix-flakes","nix-language","nix-shell","nixos","syntax"],"created_at":"2024-10-05T08:01:45.763Z","updated_at":"2025-07-02T07:32:35.080Z","avatar_url":"https://github.com/sambacha.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [nix-linguist](https://nixos.org/)\n\n\u003e **Warning** \u003cbr /\u003e\n\u003e As of July 2023, GitHub Linguist has began adopting tree-sitter based grammars. \u003cbr /\u003e\n\u003e [The Nix Community now maintains the relevant language grammar](https://github.com/nix-community/tree-sitter-nix) \u003cbr /\u003e\n\u003e https://github.com/github-linguist/linguist/commit/e855ef2b6f90c34074061a2e17acbe853e61b483\n\n\n\u003e **Note** \u003cbr /\u003e\n\u003e The _Legacy_ GitHub Linguist Grammar for Nix\n\n\n- [nix-linguist](https://nixos.org/)\n  * [Overview](#overview)\n- [Nix](#nix)\n  * [Language constructs](#language-constructs)\n  * [Primitives / literals](#primitives---literals)\n  * [Operators](#operators)\n      - [Canonical Nix Grammar](#canonical-nix-grammar)\n      - [Nix BNF Grammar](#nix-bnf-grammar)\n      \n\n## Overview\n\nThis repo provide's GitHub's Linguist with a grammar file to enhance syntax highlighting when viewed on `github.com`. \n\n\u003e **Warning** \u003cbr /\u003e\n\u003e As such, for other parsing usages, this syntax file should not be used as it is lax (not strict).\n\n# Nix\n\n\u003e **Note** \u003cbr /\u003e\n\u003e [source, nixery 1pager](https://nixery.dev/nix-1p.html)\n\n-   **purely functional**. It has no concept of sequential steps being executed, any dependency between operations is established by depending on _data_ from previous operations.\n    \n    Everything in Nix is an expression, meaning that every directive returns some kind of data.\n    \n    Evaluating a Nix expression _yields a single data structure_, it does not execute a sequence of operations.\n    \n    Every Nix file evaluates to a _single expression_.\n    \n-   **lazy**. It will only evaluate expressions when their result is actually requested.\n    \n    For example, the builtin function `throw` causes evaluation to stop. Entering the following expression works fine however, because we never actually ask for the part of the structure that causes the `throw`.\n    \n    ```nix\n    let attrs = { a = 15; b = builtins.throw \"Oh no!\"; };\n    in \"The value of 'a' is ${toString attrs.a}\"\n    ```\n    \n-   **purpose-built**. Nix only exists to be the language for Nix, the package manager. While people have occasionally used it for other use-cases, it is explicitly not a general-purpose language.\n    \n\n## [Language constructs](#)\n\nThis section describes the language constructs in Nix. It is a small language and most of these should be self-explanatory.\n\n## [Primitives / literals](#)\n\nNix has a handful of data types which can be represented literally in source code, similar to many other languages.\n\n```nix\n# numbers\n42\n1.72394\n\n# strings \u0026 paths\n\"hello\"\n./some-file.json\n\n# strings support interpolation\n\"Hello ${name}\"\n\n# multi-line strings (common prefix whitespace is dropped)\n''\nfirst line\nsecond line\n''\n\n# lists (note: no commas!)\n[ 1 2 3 ]\n\n# attribute sets (field access with dot syntax)\n{ a = 15; b = \"something else\"; }\n\n# recursive attribute sets (fields can reference each other)\nrec { a = 15; b = a * 2; }\n```\n\n## [Operators](#)\n\nNix has several operators, most of which are unsurprising:\n\n| Syntax | Description |\n| --- | --- |\n| `+`, `-`, `*`, `/` | Numerical operations |\n| `+` | String concatenation |\n| `++` | List concatenation |\n| `==` | Equality |\n| `\u003e`, `\u003e=`, `\u003c`, `\u003c=` | Ordering comparators |\n| `\u0026\u0026` | Logical `AND` |\n| `||` | Logical `OR` |\n| `e1 -\u003e e2` | Logical implication (i.e. `!e1 || e2`) |\n| `!` | Boolean negation |\n| `set.attr` | Access attribute `attr` in attribute set `set` |\n| `set ? attribute` | Test whether attribute set contains an attribute |\n| `left // right` | Merge `left` \u0026 `right` attribute sets, with the right set taking precedence |\n\nMake sure to understand the `//`\\-operator, as it is used quite a lot and is probably the least familiar one.\n\n\n#### Canonical Nix Grammar\n[canonical grammar for `nix` can be sourced via NixOS/nix/blob/master/src/libexpr/lexer.l](https://github.com/NixOS/nix/blob/master/src/libexpr/lexer.l#L27-#L314)\n\n#### Nix BNF Grammar\n\n[Another grammar spec format is available in BNF format, here is the grammar file.](https://github.com/NixOS/nix-idea/blob/4d710f3c2a33f70e0057a35b2bab9917cffbdb57/src/main/lang/Nix.bnf)\n\n\n---\n\n[![built with nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)\n\n[via the MIT License](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambacha%2Fnix-linguist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsambacha%2Fnix-linguist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambacha%2Fnix-linguist/lists"}