{"id":13688411,"url":"https://github.com/juspay/nix-health","last_synced_at":"2025-06-22T16:42:04.703Z","repository":{"id":231483096,"uuid":"781856892","full_name":"juspay/nix-health","owner":"juspay","description":"Check the health of your Nix install","archived":false,"fork":false,"pushed_at":"2024-05-28T21:29:55.000Z","size":97,"stargazers_count":17,"open_issues_count":11,"forks_count":2,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-05-29T13:05:06.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juspay.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2024-04-04T07:07:32.000Z","updated_at":"2024-05-30T18:31:40.113Z","dependencies_parsed_at":"2024-04-06T09:26:38.371Z","dependency_job_id":"82e99efa-7035-4697-b4d9-fd3c387a74b6","html_url":"https://github.com/juspay/nix-health","commit_stats":null,"previous_names":["juspay/nix-health"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juspay%2Fnix-health","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juspay%2Fnix-health/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juspay%2Fnix-health/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juspay%2Fnix-health/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juspay","download_url":"https://codeload.github.com/juspay/nix-health/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251932625,"owners_count":21667183,"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-02T15:01:13.206Z","updated_at":"2025-05-01T19:30:57.103Z","avatar_url":"https://github.com/juspay.png","language":"Rust","funding_links":[],"categories":["Development","Rust"],"sub_categories":["Discovery"],"readme":"---\nslug: /health\n---\n\n# Nix Health\n\n[nix-health](https://github.com/juspay/nix-health)[^1] is a program that checks the health of your Nix install. Furthermore, individual projects can configure their own health checks in their `flake.nix`. For example, the nammayatri project checks that [the cachix cache is in use](https://github.com/nammayatri/nammayatri/blob/2201f618af69dc78070fefeb4f082420b1d226cc/flake.nix#L29-L31).\n\n[^1]: nix-health originally began as a script \u003chttps://github.com/srid/nix-health\u003e which is now deprecated.\n\n![](https://github.com/juspay/nix-browser/assets/3998/abbbc54b-d888-42fb-a2a8-31d9ae142d6a)\n\n## Checks performed\n\n| Check | Configurable in `flake.nix`? |\n| --- | --- |\n| Flakes are enabled | - |\n| Nix version is not too old | Yes |\n| Nix runs natively (no rosetta)[^2] | Yes |\n| Builds use multiple cores (`max-jobs`) | Yes |\n| Nix Caches in use | Yes |\n| $USER is in `trusted-users` | - |\n| Direnv: installed and activated | Yes |\n| Min RAM / Disk space | Yes |\n\n[^2]: This check is only performed on macOS with Apple Silicon.\n\nNote that some checks are considered non-essential. For eg., the disk space check looks for 1TB+ disk space, but if the user is on a laptop with 256GB SSD, the check will report a warning instead of failing. This can also be configured in per-project basis from `flake.nix` (see below).\n\n## Usage\n\n\u003e[!note]\n\u003enix-health `0.3.0` is [available](https://github.com/NixOS/nixpkgs/pull/303283) on nixpkgs.\n\nTo run the development version,\n\n```bash\n# NOTE: You may have to add `--extra-experimental-features \"flakes nix-command\"`\n# if flakes are not already enabled\nnix --accept-flake-config run github:juspay/nix-health\n```\n\nTo run nix-health along with health check configuration specified in a project flake, pass that flake as an argument. For eg., to run nix-health with additional checks from the nammayatri project, run:\n\n```bash\n# The argument can be any flake URL (including a local path)\nnix --accept-flake-config run github:juspay/nix-health github:nammayatri/nammayatri\n```\n\n## Configuring in `flake.nix` {#conf}\n\nTo add project specific health checks or configure health checks, add the following flake output:\n\n```nix\n{\n  outputs = inputs: {\n    nix-health.default = {\n      # Add configuration here\n      caches.required = [ \"https://ourproject.cachix.org\" ];\n    };\n  };\n}\n```\n\nTo see all available configuration options, run `nix-health --dump-schema`. This will dump the schema of the configuration in JSON format. Convert that to a Nix attrset to see what can be added under the `nix-health.default` attrset of your flake.\n\n```sh-session\n$ nix-health --dump-schema \u003e schema.json\n$ nix eval --impure --expr 'builtins.fromJSON (builtins.readFile ./schema.json)' | nix run nixpkgs#alejandra -- --quiet\n{\n  caches = {required = [\"https://cache.nixos.org/\"];};\n  direnv = {\n    enable = true;\n    required = false;\n  };\n  flake-enabled = {};\n  max-jobs = {};\n  nix-version = {min-required = \"2.13.0\";};\n  rosetta = {\n    enable = true;\n    required = true;\n  };\n  system = {\n    enable = true;\n    min_disk_space = \"1024.0 GB\";\n    min_ram = null;\n    required = false;\n  };\n  trusted-users = {};\n}\n```\n\n### Adding devShell check\n\nYou can automatically run `nix-health` whenever your Nix dev shell starts. To do this, import the flake module in your flake and use it in your devShell:\n\n```nix\n{\n  inputs = {\n    # NOTE: refers to ./module flake.\n    nix-health.url = \"github:juspay/nix-health?dir=module\";\n  };\n  outputs = inputs:\n    inputs.flake-parts.lib.mkFlake { inherit inputs; } {\n      imports = [\n        inputs.nix-health.flakeModule\n      ];\n      perSystem = { config, pkgs, ... }: {\n        devShells.default = pkgs.mkShell {\n          inputsFrom = [\n            config.nix-health.outputs.devShell\n          ]\n        };\n      };\n    };\n}\n```\n\nNow suppose you have Nix 2.18 installed, but your project requires 2.19 or above due to the following config in its `flake.nix`:\n\n```nix\nflake.nix-health.default = {\n  nix-version.min-required = \"2.19.0\";\n};\n```\n\nyou can expect the devShell to print a giant message like this:\n\n\u003cimg width=\"501\" alt=\"image\" src=\"https://github.com/juspay/nix-health/assets/3998/9f3b3141-611f-484f-b897-3e375c02dff5\"\u003e\n\nNote that you will still be dropped into the Nix dev shell (there's no way to abrupt the launching of a dev Shell).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuspay%2Fnix-health","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuspay%2Fnix-health","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuspay%2Fnix-health/lists"}