{"id":13647680,"url":"https://github.com/haskell-nix/hnix","last_synced_at":"2025-12-18T00:58:22.075Z","repository":{"id":37706229,"uuid":"21312973","full_name":"haskell-nix/hnix","owner":"haskell-nix","description":"A Haskell re-implementation of the Nix expression language","archived":false,"fork":false,"pushed_at":"2024-03-08T05:48:35.000Z","size":4732,"stargazers_count":788,"open_issues_count":142,"forks_count":113,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-04-21T08:54:58.661Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hackage.haskell.org/package/hnix","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haskell-nix.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":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-28T23:30:50.000Z","updated_at":"2025-04-16T19:33:37.000Z","dependencies_parsed_at":"2023-10-14T16:40:05.238Z","dependency_job_id":"e49d34cd-97bf-4894-82fa-e31b7d5a2b5e","html_url":"https://github.com/haskell-nix/hnix","commit_stats":{"total_commits":3252,"total_committers":66,"mean_commits":49.27272727272727,"dds":0.4809348093480935,"last_synced_commit":"2adbc502e62e755ca0372c913e6278ebe564d7d2"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell-nix%2Fhnix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell-nix%2Fhnix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell-nix%2Fhnix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell-nix%2Fhnix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haskell-nix","download_url":"https://codeload.github.com/haskell-nix/hnix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270656,"owners_count":22042860,"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-08-02T01:03:42.353Z","updated_at":"2025-12-18T00:58:22.030Z","avatar_url":"https://github.com/haskell-nix.png","language":"Nix","funding_links":[],"categories":["Nix","Programming Languages"],"sub_categories":[],"readme":"[![Chatroom Gitter](https://img.shields.io/badge/Chatroom-Gitter-%23753a88)](https://gitter.im/haskell-nix/Lobby)\n[![Hackage](https://img.shields.io/hackage/v/hnix?color=%235e5086\u0026label=Latest%20release%20on%20Hackage)](https://hackage.haskell.org/package/hnix)\n[![Hackage Matrix Builder](https://img.shields.io/badge/Hackage%20Matrix-Builder-%235e5086)](https://matrix.hackage.haskell.org/package/hnix)\n[![Bounds](https://img.shields.io/hackage-deps/v/hnix?label=Released%20dep%20bounds)](https://packdeps.haskellers.com/feed?needle=hnix)\n[![Hydra CI](https://img.shields.io/badge/Nixpkgs%20Hydra-CI-%234f72bb)](https://hydra.nixos.org/job/nixpkgs/trunk/haskellPackages.hnix.x86_64-linux#tabs-status)\n[![Repology page](https://img.shields.io/badge/Repology-page-%23005500)](https://repology.org/project/haskell:hnix/versions)\n\n\n# HNix\n\nParser, evaluator and type checker for the Nix language written in Haskell.\n\n\n## Prerequisites\nTooling is WIP, `nix-shell` and `nix-store` are still used for their purpose, so, to access them Nix is required to be installed.\n\n*Disclaimer*: Since still using Nix for some operations, current `derivationStrict` primOp implementation and so evaluations of a derivation into a store path currently rely on the `hnix-store-remote`, which for those operations relies on the running `nix-daemon`, and so operations use/produce effects into the `/nix/store`. Be cautious - it is effectful (produces `/nix/store` entries).\n\n## Building the project\n\n### Git clone\n\n```shell\ngit clone 'https://github.com/haskell-nix/hnix.git' \u0026\u0026 cd hnix\n```\n\n\n### (optional) Cachix prebuild binary caches\n\nIf you would use our Nix-shell environment for development, you can connect to our Cachix HNix build caches:\n\n1. Run:\n    ```shell\n    nix-env -iA cachix -f https://cachix.org/api/v1/install\n    ```\n\n\n2. Run: `cachix use hnix`\n\n\n### Building with Cabal\n\nCabal [Quickstart](https://cabal.readthedocs.io/en/3.4/nix-local-build.html).\n\n1. (Optional), to enter the projects reproducible Nix environment:\n    ```shell\n    nix-shell\n    ```\n    \n2. Building:\n    ```shell\n    cabal v2-configure\n    cabal v2-build\n    ```\n  \n3. Loading the project into `ghci` REPL:\n    ```shell\n    cabal v2-repl\n    ```\n    \n4. Testing:\n\n  * Default suite:\n    ```shell\n    cabal v2-test\n    ```\n  \n  * All available tests:\n    ```shell\n    env ALL_TESTS=yes cabal v2-test\n    ```\n    \n  * Selected (list of tests is in `tests/Main.hs`):\n    ```shell\n    env NIXPKGS_TESTS=yes PRETTY_TESTS=1 cabal v2-test\n    ```\n\n#### Checking the project\n\n##### Benchmarks\n\nTo run benchmarks:\n\n```shell\ncabal v2-bench\n```\n\n##### Profiling\n\nGHC User Manual has a full [\"Profiling\"](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/profiling.html) section of relevant info.\n\nTo build `hnix` with profiling enabled:\n\n```shell\ncabal v2-run hnix --enable-profiling --flags=profiling -- \u003cargs\u003e +RTS -p\n```\n\nOr to put simply:\n```shell\n# Run profiling for evaluation of a Firefox package.\n# Generate:\n#  * for all functions\n#  * time profiling data\n#  * memory allocation profiling data\n#  * in the JSON profiling format\ncabal v2-run --enable-profiling --flags=profiling --enable-library-profiling --profiling-detail='all-functions' hnix -- --eval --expr '(import \u003cnixpkgs\u003e {}).firefox.outPath' +RTS -Pj\n\n# Then, upload the `hnix.prof` to the https://www.speedscope.app/ to analyze it.\n```\n\n\"RTS\" stands for \"RunTime System\" and has a lot of options, GHC User Manual has [\"Running a compiled program\"/\"Setting RTS options\"](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/runtime_control.html) sections describing them.\n\n##### Full debug info\n\nTo run stack traces \u0026 full tracing output on `hnix`:\n\n```shell\ncabal v2-configure --enable-tests --enable-profiling --flags=profiling --flags=tracing\ncabal v2-run hnix -- -v5 --trace \u003cargs\u003e +RTS -xc\n```\n\nThis would give the most information as to what happens during parsing \u0026 evaluation.\n\n\n#### Runing executable\n\n```shell\ncabal v2-run hnix -- --help\n```\n(`--` is for separation between `cabal` \u0026 `hnix` args)\n\n\n### Building with Nix-build\n\nThere is a number of build options to use with `nix-build`, documentation of them is in: `./default.nix`, keys essentially pass-through the [Nixpkgs Haskell Lib API](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/lib.nix).\n\nOptions can be used as:\n```shell\nnix-build \\\n  --arg \u003coption1\u003e \u003cargument1\u003e \\\n  --arg \u003coption2\u003e \u003cargument2\u003e \\\n  --argstr \u003coption3\u003e \"\u003cstrinTypeArg\u003e\"\n```\n\n#### Checking the project\n##### Benchmarks\n\n```shell\nnix-build \\\n  --arg disableOptimization false \\\n  --arg enableDeadCodeElimination true \\\n  --arg doStrip true \\\n  --arg doBenchmark true\n```\n\n##### Profiling\n\n```shell\nnix-build \\\n  --arg disableOptimization false \\\n  --arg enableDeadCodeElimination true \\\n  --arg enableLibraryProfiling true \\\n  --arg enableExecutableProfiling true\n\n./result/bin/hnix \u003cargs\u003e +RTS -p\n```\n\n##### Full debug info\n\n```shell\nnix-build \\\n  --arg disableOptimization false \\\n  --arg enableDeadCodeElimination true \\\n  --arg doBenchmark true \\\n  --arg doStrip false \\\n  --arg enableLibraryProfiling true \\\n  --arg enableExecutableProfiling true \\\n  --arg doTracing true \\\n  --arg enableDWARFDebugging true\n\n./result/bin/hnix -v5 --trace \u003cargs\u003e +RTS -xc\n```\n\n#### Runing executable\n\n```shell\n./result/bin/hnix\n```\n\n## Using HNix\n\nSee:\n```\nhnix --help\n```\n\nIt has a pretty full/good description of the current options.\n\n\n### Parse \u0026 print\n\nTo parse a file with `hnix` and pretty print the result:\n\n```shell\nhnix file.nix\n```\n\n### Evaluating and printing the resulting value\n\nExpression from a file:\n\n```shell\nhnix --eval file.nix\n```\n\nExpression:\n\n```shell\nhnix --eval --expr 'import \u003cnixpkgs\u003e {}'\n```\n\n### Evaluating Nixpkgs\n\nCurrently, the main high-level goal is to be able to evaluate all of Nixpkgs:\n\n```shell\nhnix --eval --expr \"import \u003cnixpkgs\u003e {}\" --find\n```\n\n### Options supported only by HNix\n\nTo see value provenance and thunk context:\n\n```shell\nhnix -v2 --values --thunk --eval --expr 'import \u003cnixpkgs\u003e {}'\n```\n\nTo see tracing as the evaluator runs (note that building with `cabal configure --flags=tracing` will produce much more output than this):\n\n```shell\nhnix --trace --eval --expr 'import \u003cnixpkgs\u003e {}'\n```\n\nTo attempt to generate a reduced test case demonstrating an error:\n\n```shell\nhnix --reduce bug.nix --eval --expr 'import \u003cnixpkgs\u003e {}'\n```\n\n### REPL\n\nTo enter REPL:\n```shell\nhnix --repl\n```\n\nEvaluate an expression and load it into REPL:\n```shell\nhnix --eval --expr '(import \u003cnixpkgs\u003e {}).pkgs.hello' --repl\n```\nThis binds the evaluated expression result to the `input` variable, so that variable can be inspected.\n\nUse the `:help` command for a list of all available REPL commands.\n\n#### Language laziness\n\nNix is a lazy language with the ability of recursion, so by default REPL and eval prints are lazy:\n\n```shell\nhnix \\\n  --eval \\\n  --expr '{ x = true; }'\n  \n{ x = \"\u003cexpr\u003e\"; }\n```\n\nTo disable laziness add the `--strict` to commands or `:set strict` in the REPL.\n\n```shell\nhnix \\\n  --eval \\\n  --strict \\\n  --expr '{ x = true; }'\n  \n{ x = true; }\n```\n\n\n## Contributing\n\n* The Haskell Language Server (HLS) works great with our project.\n\n* [Design of the HNix code base Wiki article](https://github.com/haskell-nix/hnix/wiki/Design-of-the-HNix-code-base).\n\n1. If something in the [quests](https://github.com/haskell-nix/hnix/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22+no%3Aassignee) looks interesting, look through the thread and leave a comment taking it, to let others know you're working on it.\n\n2. You are free to chat with everyone on [Gitter](https://gitter.im/haskell-nix/Lobby).\n\n3. When the pull request is ready to be submitted, to save time - please, test it with:\n    \n    ```shell\n    cabal v2-test\n    ```\n    \n    Please, check that all default tests that were passing prior are still passing. It's OK if no new tests are passing.\n    \n    \n### (optional) Minimalistic development status loop with amazing [`ghcid`](https://github.com/ndmitchell/ghcid)\n\nIf HLS is not your cup of yea:\n\n```shell\nghcid --command=\"cabal v2-repl --repl-options=-fno-code --repl-options=-fno-break-on-exception --repl-options=-fno-break-on-error --repl-options=-v1 --repl-options=-ferror-spans --repl-options=-j\"\n```\n(optional) To use projects reproducible environment, wrap `ghcid ...` command into a `nix-shell --command ' '`.\n\nFor simplicity `alias` the command in your shell.\n\n\n## Current status\n\nTo understand the project implementation state see:\n  * [ChangeLog](https://github.com/haskell-nix/hnix/blob/master/ChangeLog.md)\n  * [Opened reports](https://github.com/haskell-nix/hnix/issues)\n  * [Project status](https://github.com/haskell-nix/hnix/wiki/Project-status)\n  * [Design of the HNix code base](https://github.com/haskell-nix/hnix/wiki/Design-of-the-HNix-code-base)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaskell-nix%2Fhnix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaskell-nix%2Fhnix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaskell-nix%2Fhnix/lists"}