{"id":30071010,"url":"https://github.com/nix-community/nixt","last_synced_at":"2026-02-11T13:34:15.320Z","repository":{"id":45410855,"uuid":"270448714","full_name":"nix-community/nixt","owner":"nix-community","description":"Simple unit-testing for Nix [maintainer=@Lord-Valen]","archived":false,"fork":false,"pushed_at":"2026-02-08T02:53:31.000Z","size":490,"stargazers_count":123,"open_issues_count":9,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-02-08T10:41:19.681Z","etag":null,"topics":["flake","flakes","nix","nixos","standard","std","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/nix-community.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"nix-community","open_collective":"nix-community"}},"created_at":"2020-06-07T22:21:41.000Z","updated_at":"2026-01-29T14:48:39.000Z","dependencies_parsed_at":"2023-11-12T02:24:47.263Z","dependency_job_id":"262de7e6-58fd-44c8-b68d-5b36dedaa1f3","html_url":"https://github.com/nix-community/nixt","commit_stats":{"total_commits":116,"total_committers":5,"mean_commits":23.2,"dds":"0.13793103448275867","last_synced_commit":"ad8863c9f9e5a166d663f2f1f0eef74ab913a883"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nix-community/nixt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nix-community%2Fnixt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nix-community%2Fnixt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nix-community%2Fnixt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nix-community%2Fnixt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nix-community","download_url":"https://codeload.github.com/nix-community/nixt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nix-community%2Fnixt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29333564,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T12:42:24.625Z","status":"ssl_error","status_checked_at":"2026-02-11T12:41:23.344Z","response_time":97,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["flake","flakes","nix","nixos","standard","std","unit-testing"],"created_at":"2025-08-08T12:07:57.039Z","updated_at":"2026-02-11T13:34:15.304Z","avatar_url":"https://github.com/nix-community.png","language":"TypeScript","funding_links":["https://github.com/sponsors/nix-community","https://opencollective.com/nix-community"],"categories":["Development"],"sub_categories":[],"readme":"#+title: Nixt\n\nNixt is a unit-testing tool for Nix.\n\n* Installation\n\n** Imperatively\nUsing nix-env:\n#+begin_src shell\n$ nix-env -if https://github.com/nix-community/nixt/archive/master.tar.gz\n#+end_src\n\nUsing nix profile:\n#+begin_src shell\n$ nix profile install github:nix-community/nixt\n#+end_src\n\n** Declaratively\nAdd Nixt as a flake to your configuration:\n\n#+begin_src nix\n{\n  inputs.nixt = {\n    url = \"github:nix-community/nixt\";\n    inputs.nixpkgs.follows = \"nixpkgs\";\n  };\n}\n#+end_src\n\nThen add the package to your packages:\n\n#+begin_src nix\n{\n  environment.systemPackages = [\n    inputs.nixt.defaultPackage.x86_64-linux\n  ];\n}\n#+end_src\n\n* Help\n#+begin_src text\nnixt\n\n  Test-runner for nixlang.\n\nOptions\n\n  -p, --path string   Path to the test suite\n  -w, --watch         Watch for changes at path\n  -v, --verbose       Show additional test info\n  -l, --list          List, but don't run, tests\n  -d, --debug         Show nixt-developent relevant info\n  -h, --help          Prints this usage guide\n#+end_src\n\n* Running Tests\n\nIf it does not find a registry, the =nixt= CLI discovers and runs tests located at =-p/--path=:\n\n#+begin_src text\n$ nixt ./nix/\n\nFound 14 cases in 8 suites over 3 files.\n\n  ✗ 2 cases failed.\n\n┏ /home/ldlework/src/nixt/cli/nix/get-testset.test.nix\n┃   mkSuites\n┃     ✗ always fails\n\n┏ /home/ldlework/src/nixt/cli/nix/utils.test.nix\n┃   broken test\n┃     ✗ undefined variable\n\n  ⚠ Couldn't import 1 files:\n    - /home/ldlework/src/nixt/cli/nix/invalid.test.nix\n      Import error: called with unexpected argument 'nixt'\n      Did you forgot to add the 'nixt' argument to your test expression?\n#+end_src\n\nAdding in the =-v/--verbose= flag will show passing cases and additional\ninformation on failed cases:\n\n#+begin_src text\n$ nixt ./nix/ -v\n\nFound 14 cases in 8 suites over 3 files.\n\n  ✗ 2 cases failed.\n\n┏ /home/ldlework/src/nixt/cli/nix/get-testset.test.nix\n┃   mkSuite\n┃     ✓ creates correct structure\n┃   mkSuites\n┃     ✗ always fails\n┗     ✓ creates correct structure\n\n┏ /home/ldlework/src/nixt/cli/nix/utils.test.nix\n┃   broken test\n┃     ✗ undefined variable\n┃       error: undefined variable 'baz'\n┃       at /home/ldlework/src/nixt/cli/nix/utils.test.nix:12:30:\n┃       11|     \"broken test\" = {\n┃       12|       \"undefined variable\" = baz;\n┃       |                              ^\n┃       13|     };\n┃       (use '--show-trace' to show detailed location information)\n┃   dirFiles\n┃     ✓ empty list for non-existent path\n┃     ✓ non-empty list for existing path\n┃   findNixFiles\n┃     ✓ empty list for non-existent path\n┃     ✓ non-empty list for existing path\n┃   getDir\n┃     ✓ empty list for non-existent path\n┃     ✓ non-empty list for existing path\n┃   isNix\n┃     ✓ false for non-nix files\n┃     ✓ true for nix files\n┃   isTestSuite\n┃     ✓ false for non-test suites\n┗     ✓ true for test suites\n\n  ⚠ Couldn't import 1 files:\n    - /home/ldlework/src/nixt/cli/nix/invalid.test.nix\n      Import error: called with unexpected argument 'nixt'\n      Did you forgot to add the 'nixt' argument to your test expression?\n#+end_src\n\nTwo =-v -v= verbose flags implies =--show-trace=.\n\n** Listing Tests\n\nTo list discovered tests without actually evaluating their cases use the\n=--l/-list= flag:\n\n#+begin_src text\n$ nixt ./nix/ -l\n\nFound 14 cases in 8 suites over 3 files.\n\n  ⚠ Couldn't import 1 files:\n    - /home/ldlework/src/nixt/cli/nix/invalid.test.nix\n      Import error: called with unexpected argument 'nixt'\n      Did you forgot to add the 'nixt' argument to your test expression?\n#+end_src\n\nOr with the =-v/--verbose= flag:\n\n#+begin_src text\n$ nixt ./nix/ -l -v\n\nFound 14 cases in 8 suites over 3 files.\n\n┏ /home/ldlework/src/nixt/cli/nix/get-testset.test.nix\n┃   mkSuite\n┃     - creates correct structure\n┃   mkSuites\n┃     - always fails\n┗     - creates correct structure\n\n┏ /home/ldlework/src/nixt/cli/nix/utils.test.nix\n┃   broken test\n┃     - undefined variable\n┃   dirFiles\n┃     - empty list for non-existent path\n┃     - non-empty list for existing path\n┃   findNixFiles\n┃     - empty list for non-existent path\n┃     - non-empty list for existing path\n┃   getDir\n┃     - empty list for non-existent path\n┃     - non-empty list for existing path\n┃   isNix\n┃     - false for non-nix files\n┃     - true for nix files\n┃   isTestSuite\n┃     - false for non-test suites\n┗     - true for test suites\n\n  ⚠ Couldn't import 1 files:\n    - /home/ldlework/src/nixt/cli/nix/invalid.test.nix\n      Import error: called with unexpected argument 'nixt'\n      Did you forgot to add the 'nixt' argument to your test expression?\n#+end_src\n\n* Writing Tests\n\nNixt tests are written in blocks. Users may use flakes or standalone testing.\n\nWith standalone testing, a block is put in its own file which:\n\n- Contains a function taking attrset args =nixt= and =pkgs=\n- Evaluates to a =Block=\n\nEach block is composed of one or more suites;  Each suite is composed of one or more cases.\nEach case should be an expression or list of expressions that evaluate to booleans.\n\nFor those curious:\n#+begin_src nix\nBlock = struct \"Block\" {\n  path = path;\n  suites = list TestSuite;\n};\n#+end_src\n\n#+begin_src nix\nTestSuite = struct \"TestSuite\" {\n  name = string;\n  cases = list TestCase;\n};\n#+end_src\n\n#+begin_src nix\nTestCase = struct \"TestCase\" {\n  name = string;\n  expressions = list bool;\n};\n#+end_src\n\n* Library Functions\n** grow\n\nArgs:\n- =attrset= containing\n  + blocks: =list= of =Block=\n  + settings: Optional =attrset= of settings\n\nBuilds the nixt registry for cli consumption. Only relevant to flakes.\n\n#+begin_src nix\n{\n  inputs = {\n    nixt.url = \"github:nix-community/nixt\";\n  };\n\n  outputs = {\n    nixt,\n    ...\n  } @ inputs:\n  {\n    __nixt = nixt.lib.grow {\n      blocks = [\n        nixt.lib.block' ./flake.nix {\n          \"nixt\".\"passes this test\" = true;\n          \"nixt\".\"fails this test\" = false;\n        }\n      ];\n    };\n  };\n}\n#+end_src\n\n** block\n\nArgs:\n- path: =path= to the current file\n- suites: =list= of =TestSuites=\n\nCreates a =Block= from a =path= and =list= of =TestSuite=.\n\n#+begin_src nix\n{\n  nixt,\n  pkgs ? import \u003cnixpkgs\u003e {}\n}: let\n  inherit (nixt) block describe';\nin\n  block ./block.spec.nix [\n    (describe' \"nixt\" {\n      \"passes this test\" = true;\n      \"fails this test\" = false;\n    })\n  ]\n#+end_src\n\n** block'\n\nArgs:\n- path: =path= to the current file\n- suites: =attrset= of suites\n\nCreates a =Block= from a =path= and =attrset=.\n\n#+begin_src nix\n{\n  nixt,\n  pkgs ? import \u003cnixpkgs\u003e {}\n}:\nnixt.block ./block.spec.nix {\n  \"nixt\".\"passes this test\" = true;\n  \"nixt\".\"fails this test\" = false;\n}\n#+end_src\n\n** describe\n\nArgs:\n- name: =string=\n- cases: =list= of =TestCase=\n\nCreates a =TestSuite= from a =string= and =list= of =TestCase=\n\n#+begin_src nix\n{\n  nixt,\n  pkgs ? import \u003cnixpkgs\u003e {}\n}: let\n  inherit (nixt) block describe it;\nin\n  block ./block.spec.nix [\n    (describe \"nixt\" [\n      (it \"passes this test\" true)\n      (it \"fails this test\" false)\n    ])\n  ]\n#+end_src\n\n** describe'\n\nArgs:\n- name: =string=\n- cases: =attrset= of cases\n\nCreates a =TestSuite= from a =string= and =attrset=\n\n#+begin_src nix\n{\n  nixt,\n  pkgs ? import \u003cnixpkgs\u003e {}\n}: let\n  inherit (nixt) block describe';\nin\n  block ./block.spec.nix [\n    (describe' \"nixt\" {\n      \"passes this test\" = true;\n      \"fails this test\" = false;\n    })\n  ]\n#+end_src\n\n** it\n\nArgs:\n- name: =string=\n- expressions: =bool= or =list= of =bool=\n\nCreates a =TestCase= from a =string= and =bool= or =list= of =bool=\n\n#+begin_src nix\n{\n  nixt,\n  pkgs ? import \u003cnixpkgs\u003e {}\n}: let\n  inherit (nixt) block describe it;\nin\n  block ./block.spec.nix [\n    (describe \"nixt\" [\n      (it \"passes this test\" true)\n      (it \"fails this test\" false)\n    ])\n  ]\n#+end_src\n\n** inject\n\nArgs:\n- path: =path= to a test file\n\nProvides arguments to compliant files. For standalone support and cli use.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnix-community%2Fnixt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnix-community%2Fnixt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnix-community%2Fnixt/lists"}