{"id":15282008,"url":"https://github.com/xe/nixexpr","last_synced_at":"2025-04-12T21:28:15.075Z","repository":{"id":187627816,"uuid":"677392463","full_name":"Xe/nixexpr","owner":"Xe","description":"Nix expressions for JavaScript","archived":false,"fork":false,"pushed_at":"2023-08-11T13:36:37.000Z","size":16,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T05:50:00.333Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Xe.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2023-08-11T13:08:56.000Z","updated_at":"2023-10-03T20:18:42.000Z","dependencies_parsed_at":"2023-08-11T14:22:21.721Z","dependency_job_id":null,"html_url":"https://github.com/Xe/nixexpr","commit_stats":null,"previous_names":["xe/nixexpr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xe%2Fnixexpr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xe%2Fnixexpr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xe%2Fnixexpr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xe%2Fnixexpr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xe","download_url":"https://codeload.github.com/Xe/nixexpr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248633916,"owners_count":21136939,"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":[],"created_at":"2024-09-30T14:05:11.408Z","updated_at":"2025-04-12T21:28:15.018Z","avatar_url":"https://github.com/Xe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nixexpr\n\n![enbyware](https://pride-badges.pony.workers.dev/static/v1?label=enbyware\u0026labelColor=%23555\u0026stripeWidth=8\u0026stripeColors=FCF434%2CFFFFFF%2C9C59D1%2C2C2C2C)\n![license](https://img.shields.io/github/license/Xe/nixexpr)\n![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/Xe/nixexpr)\n[![Node.js CI](https://github.com/Xe/nixexpr/actions/workflows/node.js.yml/badge.svg)](https://github.com/Xe/nixexpr/actions/workflows/node.js.yml)\n\nJavaScript is great as a programming language, but sometimes it can be\nreally inconvenient when you are using it as a way to write\nconfiguration data. nixexpr allows you to use [Nix](https://nixos.org)\nsyntax to make dealing with complicated configuration that much\neasier.\n\nTo get started, install the package `@xeserv/nixexpr`:\n\n```\nnpm install --save @xeserv/nixexpr\n```\n\nAnd then import it from your code:\n\n```js\nimport { nix } from \"@xeserv/nixexpr\";\n```\n\nThen use it like you would any other tagged template:\n\n```js\nconst highlight = nix`{\n  pre_tags = [ \"em\" ];\n  post_tags = [ \"\u003c/em\u003e\" ];\n  require_fields_match = false;\n  fields.body_content.fragment_size = 200;\n  fields.body_content.number_of_fragments = 1;\n}\n```\n\n## Why?\n\nConsider the differences between these two snippets of code:\n\n```js\n{\n  highlight: {\n    pre_tags: ['\u003cem\u003e'],\n    post_tags: ['\u003c/em\u003e'],\n    require_field_match: false,\n    fields: {\n      body_content: {\n        fragment_size: 200,\n        number_of_fragments: 1,\n      },\n    },\n  },\n}\n```\n\nvs\n\n```nix\nhighlight = {\n  pre_tags = [ \"em\" ];\n  post_tags = [ \"\u003c/em\u003e\" ];\n  require_fields_match = false;\n  fields.body_content.fragment_size = 200;\n  fields.body_content.number_of_fragments = 1;\n};\n```\n\nThe one on the bottom has a lot less boilerplate and is overall a lot\neasier to deal with.\n\n## Disclaimer\n\nIf you use this in production and have issues with it, please\nreconsider your life decisions. If you still think it's a good idea to\nuse this library, [get in contact](https://xeiaso.net/contact) to\narrange a consulting meeting to help optimize the library for your\nunique needs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxe%2Fnixexpr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxe%2Fnixexpr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxe%2Fnixexpr/lists"}